documentation.d.ts 3.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  823. static readonly SCALEMODE_FLOOR: number;
  824. /** Defines that texture rescaling will look for the nearest power of 2 size */
  825. static readonly SCALEMODE_NEAREST: number;
  826. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  827. static readonly SCALEMODE_CEILING: number;
  828. /**
  829. * The dirty texture flag value
  830. */
  831. static readonly MATERIAL_TextureDirtyFlag: number;
  832. /**
  833. * The dirty light flag value
  834. */
  835. static readonly MATERIAL_LightDirtyFlag: number;
  836. /**
  837. * The dirty fresnel flag value
  838. */
  839. static readonly MATERIAL_FresnelDirtyFlag: number;
  840. /**
  841. * The dirty attribute flag value
  842. */
  843. static readonly MATERIAL_AttributesDirtyFlag: number;
  844. /**
  845. * The dirty misc flag value
  846. */
  847. static readonly MATERIAL_MiscDirtyFlag: number;
  848. /**
  849. * The all dirty flag value
  850. */
  851. static readonly MATERIAL_AllDirtyFlag: number;
  852. /**
  853. * Returns the triangle fill mode
  854. */
  855. static readonly MATERIAL_TriangleFillMode: number;
  856. /**
  857. * Returns the wireframe mode
  858. */
  859. static readonly MATERIAL_WireFrameFillMode: number;
  860. /**
  861. * Returns the point fill mode
  862. */
  863. static readonly MATERIAL_PointFillMode: number;
  864. /**
  865. * Returns the point list draw mode
  866. */
  867. static readonly MATERIAL_PointListDrawMode: number;
  868. /**
  869. * Returns the line list draw mode
  870. */
  871. static readonly MATERIAL_LineListDrawMode: number;
  872. /**
  873. * Returns the line loop draw mode
  874. */
  875. static readonly MATERIAL_LineLoopDrawMode: number;
  876. /**
  877. * Returns the line strip draw mode
  878. */
  879. static readonly MATERIAL_LineStripDrawMode: number;
  880. /**
  881. * Returns the triangle strip draw mode
  882. */
  883. static readonly MATERIAL_TriangleStripDrawMode: number;
  884. /**
  885. * Returns the triangle fan draw mode
  886. */
  887. static readonly MATERIAL_TriangleFanDrawMode: number;
  888. /**
  889. * Stores the clock-wise side orientation
  890. */
  891. static readonly MATERIAL_ClockWiseSideOrientation: number;
  892. /**
  893. * Stores the counter clock-wise side orientation
  894. */
  895. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  896. /**
  897. * Nothing
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_NothingTrigger: number;
  901. /**
  902. * On pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickTrigger: number;
  906. /**
  907. * On left pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLeftPickTrigger: number;
  911. /**
  912. * On right pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnRightPickTrigger: number;
  916. /**
  917. * On center pick
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnCenterPickTrigger: number;
  921. /**
  922. * On pick down
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnPickDownTrigger: number;
  926. /**
  927. * On double pick
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnDoublePickTrigger: number;
  931. /**
  932. * On pick up
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnPickUpTrigger: number;
  936. /**
  937. * On pick out.
  938. * This trigger will only be raised if you also declared a OnPickDown
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickOutTrigger: number;
  942. /**
  943. * On long press
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnLongPressTrigger: number;
  947. /**
  948. * On pointer over
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOverTrigger: number;
  952. /**
  953. * On pointer out
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPointerOutTrigger: number;
  957. /**
  958. * On every frame
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnEveryFrameTrigger: number;
  962. /**
  963. * On intersection enter
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionEnterTrigger: number;
  967. /**
  968. * On intersection exit
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnIntersectionExitTrigger: number;
  972. /**
  973. * On key down
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyDownTrigger: number;
  977. /**
  978. * On key up
  979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnKeyUpTrigger: number;
  982. /**
  983. * Billboard mode will only apply to Y axis
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  986. /**
  987. * Billboard mode will apply to all axes
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  990. /**
  991. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  994. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  995. * Test order :
  996. * Is the bounding sphere outside the frustum ?
  997. * If not, are the bounding box vertices outside the frustum ?
  998. * It not, then the cullable object is in the frustum.
  999. */
  1000. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1001. /** Culling strategy : Bounding Sphere Only.
  1002. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1003. * It's also less accurate than the standard because some not visible objects can still be selected.
  1004. * Test : is the bounding sphere outside the frustum ?
  1005. * If not, then the cullable object is in the frustum.
  1006. */
  1007. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1008. /** Culling strategy : Optimistic Inclusion.
  1009. * This in an inclusion test first, then the standard exclusion test.
  1010. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1011. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1012. * Anyway, it's as accurate as the standard strategy.
  1013. * Test :
  1014. * Is the cullable object bounding sphere center in the frustum ?
  1015. * If not, apply the default culling strategy.
  1016. */
  1017. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1018. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1019. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1020. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1021. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1022. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1023. * Test :
  1024. * Is the cullable object bounding sphere center in the frustum ?
  1025. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1026. */
  1027. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1028. /**
  1029. * No logging while loading
  1030. */
  1031. static readonly SCENELOADER_NO_LOGGING: number;
  1032. /**
  1033. * Minimal logging while loading
  1034. */
  1035. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1036. /**
  1037. * Summary logging while loading
  1038. */
  1039. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1040. /**
  1041. * Detailled logging while loading
  1042. */
  1043. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1044. }
  1045. }
  1046. declare module BABYLON {
  1047. /**
  1048. * This represents the required contract to create a new type of texture loader.
  1049. */
  1050. export interface IInternalTextureLoader {
  1051. /**
  1052. * Defines wether the loader supports cascade loading the different faces.
  1053. */
  1054. supportCascades: boolean;
  1055. /**
  1056. * This returns if the loader support the current file information.
  1057. * @param extension defines the file extension of the file being loaded
  1058. * @returns true if the loader can load the specified file
  1059. */
  1060. canLoad(extension: string): boolean;
  1061. /**
  1062. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1063. * @param data contains the texture data
  1064. * @param texture defines the BabylonJS internal texture
  1065. * @param createPolynomials will be true if polynomials have been requested
  1066. * @param onLoad defines the callback to trigger once the texture is ready
  1067. * @param onError defines the callback to trigger in case of error
  1068. */
  1069. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1070. /**
  1071. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1072. * @param data contains the texture data
  1073. * @param texture defines the BabylonJS internal texture
  1074. * @param callback defines the method to call once ready to upload
  1075. */
  1076. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1077. }
  1078. }
  1079. declare module BABYLON {
  1080. /**
  1081. * Class used to store and describe the pipeline context associated with an effect
  1082. */
  1083. export interface IPipelineContext {
  1084. /**
  1085. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1086. */
  1087. isAsync: boolean;
  1088. /**
  1089. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1090. */
  1091. isReady: boolean;
  1092. /** @hidden */
  1093. _getVertexShaderCode(): string | null;
  1094. /** @hidden */
  1095. _getFragmentShaderCode(): string | null;
  1096. /** @hidden */
  1097. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. get underlyingResource(): any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. get currentLine(): string;
  1173. get canRead(): boolean;
  1174. set lines(value: string[]);
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. private static _OperatorPriority;
  1192. private static _Stack;
  1193. static postfixToInfix(postfix: string[]): string;
  1194. static infixToPostfix(infix: string): string[];
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderCodeTestNode extends ShaderCodeNode {
  1200. testExpression: ShaderDefineExpression;
  1201. isValid(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1209. define: string;
  1210. not: boolean;
  1211. constructor(define: string, not?: boolean);
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1220. leftOperand: ShaderDefineExpression;
  1221. rightOperand: ShaderDefineExpression;
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /** @hidden */
  1229. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1230. leftOperand: ShaderDefineExpression;
  1231. rightOperand: ShaderDefineExpression;
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module BABYLON {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module BABYLON {
  1301. /**
  1302. * Class used to define a retry strategy when error happens while loading assets
  1303. */
  1304. export class RetryStrategy {
  1305. /**
  1306. * Function used to defines an exponential back off strategy
  1307. * @param maxRetries defines the maximum number of retries (3 by default)
  1308. * @param baseInterval defines the interval between retries
  1309. * @returns the strategy function to use
  1310. */
  1311. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /**
  1316. * @ignore
  1317. * Application error to support additional information when loading a file
  1318. */
  1319. export abstract class BaseError extends Error {
  1320. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /** @ignore */
  1325. export class LoadFileError extends BaseError {
  1326. request?: WebRequest;
  1327. file?: File;
  1328. /**
  1329. * Creates a new LoadFileError
  1330. * @param message defines the message of the error
  1331. * @param request defines the optional web request
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, object?: WebRequest | File);
  1335. }
  1336. /** @ignore */
  1337. export class RequestFileError extends BaseError {
  1338. request: WebRequest;
  1339. /**
  1340. * Creates a new LoadFileError
  1341. * @param message defines the message of the error
  1342. * @param request defines the optional web request
  1343. */
  1344. constructor(message: string, request: WebRequest);
  1345. }
  1346. /** @ignore */
  1347. export class ReadFileError extends BaseError {
  1348. file: File;
  1349. /**
  1350. * Creates a new ReadFileError
  1351. * @param message defines the message of the error
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, file: File);
  1355. }
  1356. /**
  1357. * @hidden
  1358. */
  1359. export class FileTools {
  1360. /**
  1361. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1362. */
  1363. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1364. /**
  1365. * Gets or sets the base URL to use to load assets
  1366. */
  1367. static BaseUrl: string;
  1368. /**
  1369. * Default behaviour for cors in the application.
  1370. * It can be a string if the expected behavior is identical in the entire app.
  1371. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1372. */
  1373. static CorsBehavior: string | ((url: string | string[]) => string);
  1374. /**
  1375. * Gets or sets a function used to pre-process url before using them to load assets
  1376. */
  1377. static PreprocessUrl: (url: string) => string;
  1378. /**
  1379. * Removes unwanted characters from an url
  1380. * @param url defines the url to clean
  1381. * @returns the cleaned url
  1382. */
  1383. private static _CleanUrl;
  1384. /**
  1385. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1386. * @param url define the url we are trying
  1387. * @param element define the dom element where to configure the cors policy
  1388. */
  1389. static SetCorsBehavior(url: string | string[], element: {
  1390. crossOrigin: string | null;
  1391. }): void;
  1392. /**
  1393. * Loads an image as an HTMLImageElement.
  1394. * @param input url string, ArrayBuffer, or Blob to load
  1395. * @param onLoad callback called when the image successfully loads
  1396. * @param onError callback called when the image fails to load
  1397. * @param offlineProvider offline provider for caching
  1398. * @param mimeType optional mime type
  1399. * @returns the HTMLImageElement of the loaded image
  1400. */
  1401. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1402. /**
  1403. * Reads a file from a File object
  1404. * @param file defines the file to load
  1405. * @param onSuccess defines the callback to call when data is loaded
  1406. * @param onProgress defines the callback to call during loading process
  1407. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1408. * @param onError defines the callback to call when an error occurs
  1409. * @returns a file request object
  1410. */
  1411. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1412. /**
  1413. * Loads a file from a url
  1414. * @param url url to load
  1415. * @param onSuccess callback called when the file successfully loads
  1416. * @param onProgress callback called while file is loading (if the server supports this mode)
  1417. * @param offlineProvider defines the offline provider for caching
  1418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1419. * @param onError callback called when the file fails to load
  1420. * @returns a file request object
  1421. */
  1422. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1423. /**
  1424. * Loads a file
  1425. * @param url url to load
  1426. * @param onSuccess callback called when the file successfully loads
  1427. * @param onProgress callback called while file is loading (if the server supports this mode)
  1428. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1429. * @param onError callback called when the file fails to load
  1430. * @param onOpened callback called when the web request is opened
  1431. * @returns a file request object
  1432. */
  1433. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1434. /**
  1435. * Checks if the loaded document was accessed via `file:`-Protocol.
  1436. * @returns boolean
  1437. */
  1438. static IsFileURL(): boolean;
  1439. }
  1440. }
  1441. declare module BABYLON {
  1442. /** @hidden */
  1443. export class ShaderProcessor {
  1444. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1445. private static _ProcessPrecision;
  1446. private static _ExtractOperation;
  1447. private static _BuildSubExpression;
  1448. private static _BuildExpression;
  1449. private static _MoveCursorWithinIf;
  1450. private static _MoveCursor;
  1451. private static _EvaluatePreProcessors;
  1452. private static _PreparePreProcessors;
  1453. private static _ProcessShaderConversion;
  1454. private static _ProcessIncludes;
  1455. /**
  1456. * Loads a file from a url
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param offlineProvider defines the offline provider for caching
  1461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1462. * @param onError callback called when the file fails to load
  1463. * @returns a file request object
  1464. * @hidden
  1465. */
  1466. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1467. }
  1468. }
  1469. declare module BABYLON {
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor4Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. a: float;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor3Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector4Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. w: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector3Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector2Like {
  1508. x: float;
  1509. y: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IMatrixLike {
  1515. toArray(): DeepImmutable<Float32Array>;
  1516. updateFlag: int;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IViewportLike {
  1522. x: float;
  1523. y: float;
  1524. width: float;
  1525. height: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IPlaneLike {
  1531. normal: IVector3Like;
  1532. d: float;
  1533. normalize(): void;
  1534. }
  1535. }
  1536. declare module BABYLON {
  1537. /**
  1538. * Interface used to define common properties for effect fallbacks
  1539. */
  1540. export interface IEffectFallbacks {
  1541. /**
  1542. * Removes the defines that should be removed when falling back.
  1543. * @param currentDefines defines the current define statements for the shader.
  1544. * @param effect defines the current effect we try to compile
  1545. * @returns The resulting defines with defines of the current rank removed.
  1546. */
  1547. reduce(currentDefines: string, effect: Effect): string;
  1548. /**
  1549. * Removes the fallback from the bound mesh.
  1550. */
  1551. unBindMesh(): void;
  1552. /**
  1553. * Checks to see if more fallbacks are still availible.
  1554. */
  1555. hasMoreFallbacks: boolean;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to evalaute queries containing `and` and `or` operators
  1561. */
  1562. export class AndOrNotEvaluator {
  1563. /**
  1564. * Evaluate a query
  1565. * @param query defines the query to evaluate
  1566. * @param evaluateCallback defines the callback used to filter result
  1567. * @returns true if the query matches
  1568. */
  1569. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1570. private static _HandleParenthesisContent;
  1571. private static _SimplifyNegation;
  1572. }
  1573. }
  1574. declare module BABYLON {
  1575. /**
  1576. * Class used to store custom tags
  1577. */
  1578. export class Tags {
  1579. /**
  1580. * Adds support for tags on the given object
  1581. * @param obj defines the object to use
  1582. */
  1583. static EnableFor(obj: any): void;
  1584. /**
  1585. * Removes tags support
  1586. * @param obj defines the object to use
  1587. */
  1588. static DisableFor(obj: any): void;
  1589. /**
  1590. * Gets a boolean indicating if the given object has tags
  1591. * @param obj defines the object to use
  1592. * @returns a boolean
  1593. */
  1594. static HasTags(obj: any): boolean;
  1595. /**
  1596. * Gets the tags available on a given object
  1597. * @param obj defines the object to use
  1598. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1599. * @returns the tags
  1600. */
  1601. static GetTags(obj: any, asString?: boolean): any;
  1602. /**
  1603. * Adds tags to an object
  1604. * @param obj defines the object to use
  1605. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1606. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1607. */
  1608. static AddTagsTo(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _AddTagTo(obj: any, tag: string): void;
  1613. /**
  1614. * Removes specific tags from a specific object
  1615. * @param obj defines the object to use
  1616. * @param tagsString defines the tags to remove
  1617. */
  1618. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1619. /**
  1620. * @hidden
  1621. */
  1622. static _RemoveTagFrom(obj: any, tag: string): void;
  1623. /**
  1624. * Defines if tags hosted on an object match a given query
  1625. * @param obj defines the object to use
  1626. * @param tagsQuery defines the tag query
  1627. * @returns a boolean
  1628. */
  1629. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1630. }
  1631. }
  1632. declare module BABYLON {
  1633. /**
  1634. * Scalar computation library
  1635. */
  1636. export class Scalar {
  1637. /**
  1638. * Two pi constants convenient for computation.
  1639. */
  1640. static TwoPi: number;
  1641. /**
  1642. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1643. * @param a number
  1644. * @param b number
  1645. * @param epsilon (default = 1.401298E-45)
  1646. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1647. */
  1648. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1649. /**
  1650. * Returns a string : the upper case translation of the number i to hexadecimal.
  1651. * @param i number
  1652. * @returns the upper case translation of the number i to hexadecimal.
  1653. */
  1654. static ToHex(i: number): string;
  1655. /**
  1656. * Returns -1 if value is negative and +1 is value is positive.
  1657. * @param value the value
  1658. * @returns the value itself if it's equal to zero.
  1659. */
  1660. static Sign(value: number): number;
  1661. /**
  1662. * Returns the value itself if it's between min and max.
  1663. * Returns min if the value is lower than min.
  1664. * Returns max if the value is greater than max.
  1665. * @param value the value to clmap
  1666. * @param min the min value to clamp to (default: 0)
  1667. * @param max the max value to clamp to (default: 1)
  1668. * @returns the clamped value
  1669. */
  1670. static Clamp(value: number, min?: number, max?: number): number;
  1671. /**
  1672. * the log2 of value.
  1673. * @param value the value to compute log2 of
  1674. * @returns the log2 of value.
  1675. */
  1676. static Log2(value: number): number;
  1677. /**
  1678. * Loops the value, so that it is never larger than length and never smaller than 0.
  1679. *
  1680. * This is similar to the modulo operator but it works with floating point numbers.
  1681. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1682. * With t = 5 and length = 2.5, the result would be 0.0.
  1683. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1684. * @param value the value
  1685. * @param length the length
  1686. * @returns the looped value
  1687. */
  1688. static Repeat(value: number, length: number): number;
  1689. /**
  1690. * Normalize the value between 0.0 and 1.0 using min and max values
  1691. * @param value value to normalize
  1692. * @param min max to normalize between
  1693. * @param max min to normalize between
  1694. * @returns the normalized value
  1695. */
  1696. static Normalize(value: number, min: number, max: number): number;
  1697. /**
  1698. * Denormalize the value from 0.0 and 1.0 using min and max values
  1699. * @param normalized value to denormalize
  1700. * @param min max to denormalize between
  1701. * @param max min to denormalize between
  1702. * @returns the denormalized value
  1703. */
  1704. static Denormalize(normalized: number, min: number, max: number): number;
  1705. /**
  1706. * Calculates the shortest difference between two given angles given in degrees.
  1707. * @param current current angle in degrees
  1708. * @param target target angle in degrees
  1709. * @returns the delta
  1710. */
  1711. static DeltaAngle(current: number, target: number): number;
  1712. /**
  1713. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1714. * @param tx value
  1715. * @param length length
  1716. * @returns The returned value will move back and forth between 0 and length
  1717. */
  1718. static PingPong(tx: number, length: number): number;
  1719. /**
  1720. * Interpolates between min and max with smoothing at the limits.
  1721. *
  1722. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1723. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1724. * @param from from
  1725. * @param to to
  1726. * @param tx value
  1727. * @returns the smooth stepped value
  1728. */
  1729. static SmoothStep(from: number, to: number, tx: number): number;
  1730. /**
  1731. * Moves a value current towards target.
  1732. *
  1733. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1734. * Negative values of maxDelta pushes the value away from target.
  1735. * @param current current value
  1736. * @param target target value
  1737. * @param maxDelta max distance to move
  1738. * @returns resulting value
  1739. */
  1740. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1741. /**
  1742. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1743. *
  1744. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1745. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1746. * @param current current value
  1747. * @param target target value
  1748. * @param maxDelta max distance to move
  1749. * @returns resulting angle
  1750. */
  1751. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1752. /**
  1753. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static Lerp(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1762. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static LerpAngle(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1771. * @param a start value
  1772. * @param b target value
  1773. * @param value value between a and b
  1774. * @returns the inverseLerp value
  1775. */
  1776. static InverseLerp(a: number, b: number, value: number): number;
  1777. /**
  1778. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1779. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1780. * @param value1 spline value
  1781. * @param tangent1 spline value
  1782. * @param value2 spline value
  1783. * @param tangent2 spline value
  1784. * @param amount input value
  1785. * @returns hermite result
  1786. */
  1787. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1788. /**
  1789. * Returns a random float number between and min and max values
  1790. * @param min min value of random
  1791. * @param max max value of random
  1792. * @returns random value
  1793. */
  1794. static RandomRange(min: number, max: number): number;
  1795. /**
  1796. * This function returns percentage of a number in a given range.
  1797. *
  1798. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1799. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1800. * @param number to convert to percentage
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the percentage
  1804. */
  1805. static RangeToPercent(number: number, min: number, max: number): number;
  1806. /**
  1807. * This function returns number that corresponds to the percentage in a given range.
  1808. *
  1809. * PercentToRange(0.34,0,100) will return 34.
  1810. * @param percent to convert to number
  1811. * @param min min range
  1812. * @param max max range
  1813. * @returns the number
  1814. */
  1815. static PercentToRange(percent: number, min: number, max: number): number;
  1816. /**
  1817. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1818. * @param angle The angle to normalize in radian.
  1819. * @return The converted angle.
  1820. */
  1821. static NormalizeRadians(angle: number): number;
  1822. }
  1823. }
  1824. declare module BABYLON {
  1825. /**
  1826. * Constant used to convert a value to gamma space
  1827. * @ignorenaming
  1828. */
  1829. export const ToGammaSpace: number;
  1830. /**
  1831. * Constant used to convert a value to linear space
  1832. * @ignorenaming
  1833. */
  1834. export const ToLinearSpace = 2.2;
  1835. /**
  1836. * Constant used to define the minimal number value in Babylon.js
  1837. * @ignorenaming
  1838. */
  1839. let Epsilon: number;
  1840. }
  1841. declare module BABYLON {
  1842. /**
  1843. * Class used to represent a viewport on screen
  1844. */
  1845. export class Viewport {
  1846. /** viewport left coordinate */
  1847. x: number;
  1848. /** viewport top coordinate */
  1849. y: number;
  1850. /**viewport width */
  1851. width: number;
  1852. /** viewport height */
  1853. height: number;
  1854. /**
  1855. * Creates a Viewport object located at (x, y) and sized (width, height)
  1856. * @param x defines viewport left coordinate
  1857. * @param y defines viewport top coordinate
  1858. * @param width defines the viewport width
  1859. * @param height defines the viewport height
  1860. */
  1861. constructor(
  1862. /** viewport left coordinate */
  1863. x: number,
  1864. /** viewport top coordinate */
  1865. y: number,
  1866. /**viewport width */
  1867. width: number,
  1868. /** viewport height */
  1869. height: number);
  1870. /**
  1871. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1872. * @param renderWidth defines the rendering width
  1873. * @param renderHeight defines the rendering height
  1874. * @returns a new Viewport
  1875. */
  1876. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1877. /**
  1878. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1879. * @param renderWidth defines the rendering width
  1880. * @param renderHeight defines the rendering height
  1881. * @param ref defines the target viewport
  1882. * @returns the current viewport
  1883. */
  1884. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1885. /**
  1886. * Returns a new Viewport copied from the current one
  1887. * @returns a new Viewport
  1888. */
  1889. clone(): Viewport;
  1890. }
  1891. }
  1892. declare module BABYLON {
  1893. /**
  1894. * Class containing a set of static utilities functions for arrays.
  1895. */
  1896. export class ArrayTools {
  1897. /**
  1898. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1899. * @param size the number of element to construct and put in the array
  1900. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1901. * @returns a new array filled with new objects
  1902. */
  1903. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1904. }
  1905. }
  1906. declare module BABYLON {
  1907. /**
  1908. * Class representing a vector containing 2 coordinates
  1909. */
  1910. export class Vector2 {
  1911. /** defines the first coordinate */
  1912. x: number;
  1913. /** defines the second coordinate */
  1914. y: number;
  1915. /**
  1916. * Creates a new Vector2 from the given x and y coordinates
  1917. * @param x defines the first coordinate
  1918. * @param y defines the second coordinate
  1919. */
  1920. constructor(
  1921. /** defines the first coordinate */
  1922. x?: number,
  1923. /** defines the second coordinate */
  1924. y?: number);
  1925. /**
  1926. * Gets a string with the Vector2 coordinates
  1927. * @returns a string with the Vector2 coordinates
  1928. */
  1929. toString(): string;
  1930. /**
  1931. * Gets class name
  1932. * @returns the string "Vector2"
  1933. */
  1934. getClassName(): string;
  1935. /**
  1936. * Gets current vector hash code
  1937. * @returns the Vector2 hash code as a number
  1938. */
  1939. getHashCode(): number;
  1940. /**
  1941. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1942. * @param array defines the source array
  1943. * @param index defines the offset in source array
  1944. * @returns the current Vector2
  1945. */
  1946. toArray(array: FloatArray, index?: number): Vector2;
  1947. /**
  1948. * Copy the current vector to an array
  1949. * @returns a new array with 2 elements: the Vector2 coordinates.
  1950. */
  1951. asArray(): number[];
  1952. /**
  1953. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1954. * @param source defines the source Vector2
  1955. * @returns the current updated Vector2
  1956. */
  1957. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1958. /**
  1959. * Sets the Vector2 coordinates with the given floats
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. * @returns the current updated Vector2
  1963. */
  1964. copyFromFloats(x: number, y: number): Vector2;
  1965. /**
  1966. * Sets the Vector2 coordinates with the given floats
  1967. * @param x defines the first coordinate
  1968. * @param y defines the second coordinate
  1969. * @returns the current updated Vector2
  1970. */
  1971. set(x: number, y: number): Vector2;
  1972. /**
  1973. * Add another vector with the current one
  1974. * @param otherVector defines the other vector
  1975. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1976. */
  1977. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1980. * @param otherVector defines the other vector
  1981. * @param result defines the target vector
  1982. * @returns the unmodified current Vector2
  1983. */
  1984. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1985. /**
  1986. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1987. * @param otherVector defines the other vector
  1988. * @returns the current updated Vector2
  1989. */
  1990. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1993. * @param otherVector defines the other vector
  1994. * @returns a new Vector2
  1995. */
  1996. addVector3(otherVector: Vector3): Vector2;
  1997. /**
  1998. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1999. * @param otherVector defines the other vector
  2000. * @returns a new Vector2
  2001. */
  2002. subtract(otherVector: Vector2): Vector2;
  2003. /**
  2004. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2005. * @param otherVector defines the other vector
  2006. * @param result defines the target vector
  2007. * @returns the unmodified current Vector2
  2008. */
  2009. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2010. /**
  2011. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2012. * @param otherVector defines the other vector
  2013. * @returns the current updated Vector2
  2014. */
  2015. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2016. /**
  2017. * Multiplies in place the current Vector2 coordinates by the given ones
  2018. * @param otherVector defines the other vector
  2019. * @returns the current updated Vector2
  2020. */
  2021. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2022. /**
  2023. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2028. /**
  2029. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2037. * @param x defines the first coordinate
  2038. * @param y defines the second coordinate
  2039. * @returns a new Vector2
  2040. */
  2041. multiplyByFloats(x: number, y: number): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. divide(otherVector: Vector2): Vector2;
  2048. /**
  2049. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Divides the current Vector2 coordinates by the given ones
  2057. * @param otherVector defines the other vector
  2058. * @returns the current updated Vector2
  2059. */
  2060. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2061. /**
  2062. * Gets a new Vector2 with current Vector2 negated coordinates
  2063. * @returns a new Vector2
  2064. */
  2065. negate(): Vector2;
  2066. /**
  2067. * Negate this vector in place
  2068. * @returns this
  2069. */
  2070. negateInPlace(): Vector2;
  2071. /**
  2072. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2073. * @param result defines the Vector3 object where to store the result
  2074. * @returns the current Vector2
  2075. */
  2076. negateToRef(result: Vector2): Vector2;
  2077. /**
  2078. * Multiply the Vector2 coordinates by scale
  2079. * @param scale defines the scaling factor
  2080. * @returns the current updated Vector2
  2081. */
  2082. scaleInPlace(scale: number): Vector2;
  2083. /**
  2084. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2085. * @param scale defines the scaling factor
  2086. * @returns a new Vector2
  2087. */
  2088. scale(scale: number): Vector2;
  2089. /**
  2090. * Scale the current Vector2 values by a factor to a given Vector2
  2091. * @param scale defines the scale factor
  2092. * @param result defines the Vector2 object where to store the result
  2093. * @returns the unmodified current Vector2
  2094. */
  2095. scaleToRef(scale: number, result: Vector2): Vector2;
  2096. /**
  2097. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2098. * @param scale defines the scale factor
  2099. * @param result defines the Vector2 object where to store the result
  2100. * @returns the unmodified current Vector2
  2101. */
  2102. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2103. /**
  2104. * Gets a boolean if two vectors are equals
  2105. * @param otherVector defines the other vector
  2106. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2107. */
  2108. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2109. /**
  2110. * Gets a boolean if two vectors are equals (using an epsilon value)
  2111. * @param otherVector defines the other vector
  2112. * @param epsilon defines the minimal distance to consider equality
  2113. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2114. */
  2115. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2116. /**
  2117. * Gets a new Vector2 from current Vector2 floored values
  2118. * @returns a new Vector2
  2119. */
  2120. floor(): Vector2;
  2121. /**
  2122. * Gets a new Vector2 from current Vector2 floored values
  2123. * @returns a new Vector2
  2124. */
  2125. fract(): Vector2;
  2126. /**
  2127. * Gets the length of the vector
  2128. * @returns the vector length (float)
  2129. */
  2130. length(): number;
  2131. /**
  2132. * Gets the vector squared length
  2133. * @returns the vector squared length (float)
  2134. */
  2135. lengthSquared(): number;
  2136. /**
  2137. * Normalize the vector
  2138. * @returns the current updated Vector2
  2139. */
  2140. normalize(): Vector2;
  2141. /**
  2142. * Gets a new Vector2 copied from the Vector2
  2143. * @returns a new Vector2
  2144. */
  2145. clone(): Vector2;
  2146. /**
  2147. * Gets a new Vector2(0, 0)
  2148. * @returns a new Vector2
  2149. */
  2150. static Zero(): Vector2;
  2151. /**
  2152. * Gets a new Vector2(1, 1)
  2153. * @returns a new Vector2
  2154. */
  2155. static One(): Vector2;
  2156. /**
  2157. * Gets a new Vector2 set from the given index element of the given array
  2158. * @param array defines the data source
  2159. * @param offset defines the offset in the data source
  2160. * @returns a new Vector2
  2161. */
  2162. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2163. /**
  2164. * Sets "result" from the given index element of the given array
  2165. * @param array defines the data source
  2166. * @param offset defines the offset in the data source
  2167. * @param result defines the target vector
  2168. */
  2169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2170. /**
  2171. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2172. * @param value1 defines 1st point of control
  2173. * @param value2 defines 2nd point of control
  2174. * @param value3 defines 3rd point of control
  2175. * @param value4 defines 4th point of control
  2176. * @param amount defines the interpolation factor
  2177. * @returns a new Vector2
  2178. */
  2179. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2180. /**
  2181. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2182. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2183. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2184. * @param value defines the value to clamp
  2185. * @param min defines the lower limit
  2186. * @param max defines the upper limit
  2187. * @returns a new Vector2
  2188. */
  2189. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2190. /**
  2191. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2192. * @param value1 defines the 1st control point
  2193. * @param tangent1 defines the outgoing tangent
  2194. * @param value2 defines the 2nd control point
  2195. * @param tangent2 defines the incoming tangent
  2196. * @param amount defines the interpolation factor
  2197. * @returns a new Vector2
  2198. */
  2199. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2200. /**
  2201. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2202. * @param start defines the start vector
  2203. * @param end defines the end vector
  2204. * @param amount defines the interpolation factor
  2205. * @returns a new Vector2
  2206. */
  2207. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2208. /**
  2209. * Gets the dot product of the vector "left" and the vector "right"
  2210. * @param left defines first vector
  2211. * @param right defines second vector
  2212. * @returns the dot product (float)
  2213. */
  2214. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2215. /**
  2216. * Returns a new Vector2 equal to the normalized given vector
  2217. * @param vector defines the vector to normalize
  2218. * @returns a new Vector2
  2219. */
  2220. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2223. * @param left defines 1st vector
  2224. * @param right defines 2nd vector
  2225. * @returns a new Vector2
  2226. */
  2227. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2228. /**
  2229. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2230. * @param left defines 1st vector
  2231. * @param right defines 2nd vector
  2232. * @returns a new Vector2
  2233. */
  2234. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2235. /**
  2236. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2237. * @param vector defines the vector to transform
  2238. * @param transformation defines the matrix to apply
  2239. * @returns a new Vector2
  2240. */
  2241. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2242. /**
  2243. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2244. * @param vector defines the vector to transform
  2245. * @param transformation defines the matrix to apply
  2246. * @param result defines the target vector
  2247. */
  2248. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2249. /**
  2250. * Determines if a given vector is included in a triangle
  2251. * @param p defines the vector to test
  2252. * @param p0 defines 1st triangle point
  2253. * @param p1 defines 2nd triangle point
  2254. * @param p2 defines 3rd triangle point
  2255. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2256. */
  2257. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2258. /**
  2259. * Gets the distance between the vectors "value1" and "value2"
  2260. * @param value1 defines first vector
  2261. * @param value2 defines second vector
  2262. * @returns the distance between vectors
  2263. */
  2264. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2265. /**
  2266. * Returns the squared distance between the vectors "value1" and "value2"
  2267. * @param value1 defines first vector
  2268. * @param value2 defines second vector
  2269. * @returns the squared distance between vectors
  2270. */
  2271. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2272. /**
  2273. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2274. * @param value1 defines first vector
  2275. * @param value2 defines second vector
  2276. * @returns a new Vector2
  2277. */
  2278. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2279. /**
  2280. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2281. * @param p defines the middle point
  2282. * @param segA defines one point of the segment
  2283. * @param segB defines the other point of the segment
  2284. * @returns the shortest distance
  2285. */
  2286. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2287. }
  2288. /**
  2289. * Class used to store (x,y,z) vector representation
  2290. * A Vector3 is the main object used in 3D geometry
  2291. * It can represent etiher the coordinates of a point the space, either a direction
  2292. * Reminder: js uses a left handed forward facing system
  2293. */
  2294. export class Vector3 {
  2295. /**
  2296. * Defines the first coordinates (on X axis)
  2297. */
  2298. x: number;
  2299. /**
  2300. * Defines the second coordinates (on Y axis)
  2301. */
  2302. y: number;
  2303. /**
  2304. * Defines the third coordinates (on Z axis)
  2305. */
  2306. z: number;
  2307. private static _UpReadOnly;
  2308. private static _ZeroReadOnly;
  2309. /**
  2310. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2311. * @param x defines the first coordinates (on X axis)
  2312. * @param y defines the second coordinates (on Y axis)
  2313. * @param z defines the third coordinates (on Z axis)
  2314. */
  2315. constructor(
  2316. /**
  2317. * Defines the first coordinates (on X axis)
  2318. */
  2319. x?: number,
  2320. /**
  2321. * Defines the second coordinates (on Y axis)
  2322. */
  2323. y?: number,
  2324. /**
  2325. * Defines the third coordinates (on Z axis)
  2326. */
  2327. z?: number);
  2328. /**
  2329. * Creates a string representation of the Vector3
  2330. * @returns a string with the Vector3 coordinates.
  2331. */
  2332. toString(): string;
  2333. /**
  2334. * Gets the class name
  2335. * @returns the string "Vector3"
  2336. */
  2337. getClassName(): string;
  2338. /**
  2339. * Creates the Vector3 hash code
  2340. * @returns a number which tends to be unique between Vector3 instances
  2341. */
  2342. getHashCode(): number;
  2343. /**
  2344. * Creates an array containing three elements : the coordinates of the Vector3
  2345. * @returns a new array of numbers
  2346. */
  2347. asArray(): number[];
  2348. /**
  2349. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2350. * @param array defines the destination array
  2351. * @param index defines the offset in the destination array
  2352. * @returns the current Vector3
  2353. */
  2354. toArray(array: FloatArray, index?: number): Vector3;
  2355. /**
  2356. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2357. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2358. */
  2359. toQuaternion(): Quaternion;
  2360. /**
  2361. * Adds the given vector to the current Vector3
  2362. * @param otherVector defines the second operand
  2363. * @returns the current updated Vector3
  2364. */
  2365. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2366. /**
  2367. * Adds the given coordinates to the current Vector3
  2368. * @param x defines the x coordinate of the operand
  2369. * @param y defines the y coordinate of the operand
  2370. * @param z defines the z coordinate of the operand
  2371. * @returns the current updated Vector3
  2372. */
  2373. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2374. /**
  2375. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2376. * @param otherVector defines the second operand
  2377. * @returns the resulting Vector3
  2378. */
  2379. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2380. /**
  2381. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2382. * @param otherVector defines the second operand
  2383. * @param result defines the Vector3 object where to store the result
  2384. * @returns the current Vector3
  2385. */
  2386. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2387. /**
  2388. * Subtract the given vector from the current Vector3
  2389. * @param otherVector defines the second operand
  2390. * @returns the current updated Vector3
  2391. */
  2392. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2395. * @param otherVector defines the second operand
  2396. * @returns the resulting Vector3
  2397. */
  2398. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2399. /**
  2400. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2401. * @param otherVector defines the second operand
  2402. * @param result defines the Vector3 object where to store the result
  2403. * @returns the current Vector3
  2404. */
  2405. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2406. /**
  2407. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2408. * @param x defines the x coordinate of the operand
  2409. * @param y defines the y coordinate of the operand
  2410. * @param z defines the z coordinate of the operand
  2411. * @returns the resulting Vector3
  2412. */
  2413. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2414. /**
  2415. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2416. * @param x defines the x coordinate of the operand
  2417. * @param y defines the y coordinate of the operand
  2418. * @param z defines the z coordinate of the operand
  2419. * @param result defines the Vector3 object where to store the result
  2420. * @returns the current Vector3
  2421. */
  2422. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2423. /**
  2424. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2425. * @returns a new Vector3
  2426. */
  2427. negate(): Vector3;
  2428. /**
  2429. * Negate this vector in place
  2430. * @returns this
  2431. */
  2432. negateInPlace(): Vector3;
  2433. /**
  2434. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. negateToRef(result: Vector3): Vector3;
  2439. /**
  2440. * Multiplies the Vector3 coordinates by the float "scale"
  2441. * @param scale defines the multiplier factor
  2442. * @returns the current updated Vector3
  2443. */
  2444. scaleInPlace(scale: number): Vector3;
  2445. /**
  2446. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2447. * @param scale defines the multiplier factor
  2448. * @returns a new Vector3
  2449. */
  2450. scale(scale: number): Vector3;
  2451. /**
  2452. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2453. * @param scale defines the multiplier factor
  2454. * @param result defines the Vector3 object where to store the result
  2455. * @returns the current Vector3
  2456. */
  2457. scaleToRef(scale: number, result: Vector3): Vector3;
  2458. /**
  2459. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2460. * @param scale defines the scale factor
  2461. * @param result defines the Vector3 object where to store the result
  2462. * @returns the unmodified current Vector3
  2463. */
  2464. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2465. /**
  2466. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2467. * @param otherVector defines the second operand
  2468. * @returns true if both vectors are equals
  2469. */
  2470. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2471. /**
  2472. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2473. * @param otherVector defines the second operand
  2474. * @param epsilon defines the minimal distance to define values as equals
  2475. * @returns true if both vectors are distant less than epsilon
  2476. */
  2477. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2478. /**
  2479. * Returns true if the current Vector3 coordinates equals the given floats
  2480. * @param x defines the x coordinate of the operand
  2481. * @param y defines the y coordinate of the operand
  2482. * @param z defines the z coordinate of the operand
  2483. * @returns true if both vectors are equals
  2484. */
  2485. equalsToFloats(x: number, y: number, z: number): boolean;
  2486. /**
  2487. * Multiplies the current Vector3 coordinates by the given ones
  2488. * @param otherVector defines the second operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2492. /**
  2493. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2494. * @param otherVector defines the second operand
  2495. * @returns the new Vector3
  2496. */
  2497. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2498. /**
  2499. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2500. * @param otherVector defines the second operand
  2501. * @param result defines the Vector3 object where to store the result
  2502. * @returns the current Vector3
  2503. */
  2504. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2505. /**
  2506. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2507. * @param x defines the x coordinate of the operand
  2508. * @param y defines the y coordinate of the operand
  2509. * @param z defines the z coordinate of the operand
  2510. * @returns the new Vector3
  2511. */
  2512. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2513. /**
  2514. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2515. * @param otherVector defines the second operand
  2516. * @returns the new Vector3
  2517. */
  2518. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2521. * @param otherVector defines the second operand
  2522. * @param result defines the Vector3 object where to store the result
  2523. * @returns the current Vector3
  2524. */
  2525. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2526. /**
  2527. * Divides the current Vector3 coordinates by the given ones.
  2528. * @param otherVector defines the second operand
  2529. * @returns the current updated Vector3
  2530. */
  2531. divideInPlace(otherVector: Vector3): Vector3;
  2532. /**
  2533. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2534. * @param other defines the second operand
  2535. * @returns the current updated Vector3
  2536. */
  2537. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2538. /**
  2539. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2540. * @param other defines the second operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2544. /**
  2545. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2562. * Check if is non uniform within a certain amount of decimal places to account for this
  2563. * @param epsilon the amount the values can differ
  2564. * @returns if the the vector is non uniform to a certain number of decimal places
  2565. */
  2566. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2567. /**
  2568. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2569. */
  2570. get isNonUniform(): boolean;
  2571. /**
  2572. * Gets a new Vector3 from current Vector3 floored values
  2573. * @returns a new Vector3
  2574. */
  2575. floor(): Vector3;
  2576. /**
  2577. * Gets a new Vector3 from current Vector3 floored values
  2578. * @returns a new Vector3
  2579. */
  2580. fract(): Vector3;
  2581. /**
  2582. * Gets the length of the Vector3
  2583. * @returns the length of the Vector3
  2584. */
  2585. length(): number;
  2586. /**
  2587. * Gets the squared length of the Vector3
  2588. * @returns squared length of the Vector3
  2589. */
  2590. lengthSquared(): number;
  2591. /**
  2592. * Normalize the current Vector3.
  2593. * Please note that this is an in place operation.
  2594. * @returns the current updated Vector3
  2595. */
  2596. normalize(): Vector3;
  2597. /**
  2598. * Reorders the x y z properties of the vector in place
  2599. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2600. * @returns the current updated vector
  2601. */
  2602. reorderInPlace(order: string): this;
  2603. /**
  2604. * Rotates the vector around 0,0,0 by a quaternion
  2605. * @param quaternion the rotation quaternion
  2606. * @param result vector to store the result
  2607. * @returns the resulting vector
  2608. */
  2609. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2610. /**
  2611. * Rotates a vector around a given point
  2612. * @param quaternion the rotation quaternion
  2613. * @param point the point to rotate around
  2614. * @param result vector to store the result
  2615. * @returns the resulting vector
  2616. */
  2617. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2618. /**
  2619. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2620. * The cross product is then orthogonal to both current and "other"
  2621. * @param other defines the right operand
  2622. * @returns the cross product
  2623. */
  2624. cross(other: Vector3): Vector3;
  2625. /**
  2626. * Normalize the current Vector3 with the given input length.
  2627. * Please note that this is an in place operation.
  2628. * @param len the length of the vector
  2629. * @returns the current updated Vector3
  2630. */
  2631. normalizeFromLength(len: number): Vector3;
  2632. /**
  2633. * Normalize the current Vector3 to a new vector
  2634. * @returns the new Vector3
  2635. */
  2636. normalizeToNew(): Vector3;
  2637. /**
  2638. * Normalize the current Vector3 to the reference
  2639. * @param reference define the Vector3 to update
  2640. * @returns the updated Vector3
  2641. */
  2642. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2643. /**
  2644. * Creates a new Vector3 copied from the current Vector3
  2645. * @returns the new Vector3
  2646. */
  2647. clone(): Vector3;
  2648. /**
  2649. * Copies the given vector coordinates to the current Vector3 ones
  2650. * @param source defines the source Vector3
  2651. * @returns the current updated Vector3
  2652. */
  2653. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2654. /**
  2655. * Copies the given floats to the current Vector3 coordinates
  2656. * @param x defines the x coordinate of the operand
  2657. * @param y defines the y coordinate of the operand
  2658. * @param z defines the z coordinate of the operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. copyFromFloats(x: number, y: number, z: number): Vector3;
  2662. /**
  2663. * Copies the given floats to the current Vector3 coordinates
  2664. * @param x defines the x coordinate of the operand
  2665. * @param y defines the y coordinate of the operand
  2666. * @param z defines the z coordinate of the operand
  2667. * @returns the current updated Vector3
  2668. */
  2669. set(x: number, y: number, z: number): Vector3;
  2670. /**
  2671. * Copies the given float to the current Vector3 coordinates
  2672. * @param v defines the x, y and z coordinates of the operand
  2673. * @returns the current updated Vector3
  2674. */
  2675. setAll(v: number): Vector3;
  2676. /**
  2677. * Get the clip factor between two vectors
  2678. * @param vector0 defines the first operand
  2679. * @param vector1 defines the second operand
  2680. * @param axis defines the axis to use
  2681. * @param size defines the size along the axis
  2682. * @returns the clip factor
  2683. */
  2684. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2685. /**
  2686. * Get angle between two vectors
  2687. * @param vector0 angle between vector0 and vector1
  2688. * @param vector1 angle between vector0 and vector1
  2689. * @param normal direction of the normal
  2690. * @return the angle between vector0 and vector1
  2691. */
  2692. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2693. /**
  2694. * Returns a new Vector3 set from the index "offset" of the given array
  2695. * @param array defines the source array
  2696. * @param offset defines the offset in the source array
  2697. * @returns the new Vector3
  2698. */
  2699. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2700. /**
  2701. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2702. * @param array defines the source array
  2703. * @param offset defines the offset in the source array
  2704. * @returns the new Vector3
  2705. * @deprecated Please use FromArray instead.
  2706. */
  2707. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2708. /**
  2709. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2710. * @param array defines the source array
  2711. * @param offset defines the offset in the source array
  2712. * @param result defines the Vector3 where to store the result
  2713. */
  2714. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2715. /**
  2716. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2717. * @param array defines the source array
  2718. * @param offset defines the offset in the source array
  2719. * @param result defines the Vector3 where to store the result
  2720. * @deprecated Please use FromArrayToRef instead.
  2721. */
  2722. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2723. /**
  2724. * Sets the given vector "result" with the given floats.
  2725. * @param x defines the x coordinate of the source
  2726. * @param y defines the y coordinate of the source
  2727. * @param z defines the z coordinate of the source
  2728. * @param result defines the Vector3 where to store the result
  2729. */
  2730. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2731. /**
  2732. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2733. * @returns a new empty Vector3
  2734. */
  2735. static Zero(): Vector3;
  2736. /**
  2737. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2738. * @returns a new unit Vector3
  2739. */
  2740. static One(): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2743. * @returns a new up Vector3
  2744. */
  2745. static Up(): Vector3;
  2746. /**
  2747. * Gets a up Vector3 that must not be updated
  2748. */
  2749. static get UpReadOnly(): DeepImmutable<Vector3>;
  2750. /**
  2751. * Gets a zero Vector3 that must not be updated
  2752. */
  2753. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2756. * @returns a new down Vector3
  2757. */
  2758. static Down(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2761. * @returns a new forward Vector3
  2762. */
  2763. static Forward(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2766. * @returns a new forward Vector3
  2767. */
  2768. static Backward(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2771. * @returns a new right Vector3
  2772. */
  2773. static Right(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2776. * @returns a new left Vector3
  2777. */
  2778. static Left(): Vector3;
  2779. /**
  2780. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2781. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2782. * @param vector defines the Vector3 to transform
  2783. * @param transformation defines the transformation matrix
  2784. * @returns the transformed Vector3
  2785. */
  2786. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2787. /**
  2788. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2789. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2790. * @param vector defines the Vector3 to transform
  2791. * @param transformation defines the transformation matrix
  2792. * @param result defines the Vector3 where to store the result
  2793. */
  2794. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2795. /**
  2796. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2797. * This method computes tranformed coordinates only, not transformed direction vectors
  2798. * @param x define the x coordinate of the source vector
  2799. * @param y define the y coordinate of the source vector
  2800. * @param z define the z coordinate of the source vector
  2801. * @param transformation defines the transformation matrix
  2802. * @param result defines the Vector3 where to store the result
  2803. */
  2804. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2805. /**
  2806. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2807. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @returns the new Vector3
  2811. */
  2812. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2813. /**
  2814. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2815. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2816. * @param vector defines the Vector3 to transform
  2817. * @param transformation defines the transformation matrix
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2821. /**
  2822. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2823. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2824. * @param x define the x coordinate of the source vector
  2825. * @param y define the y coordinate of the source vector
  2826. * @param z define the z coordinate of the source vector
  2827. * @param transformation defines the transformation matrix
  2828. * @param result defines the Vector3 where to store the result
  2829. */
  2830. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2831. /**
  2832. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2833. * @param value1 defines the first control point
  2834. * @param value2 defines the second control point
  2835. * @param value3 defines the third control point
  2836. * @param value4 defines the fourth control point
  2837. * @param amount defines the amount on the spline to use
  2838. * @returns the new Vector3
  2839. */
  2840. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2841. /**
  2842. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2843. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2844. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2845. * @param value defines the current value
  2846. * @param min defines the lower range value
  2847. * @param max defines the upper range value
  2848. * @returns the new Vector3
  2849. */
  2850. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2851. /**
  2852. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2853. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2854. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2855. * @param value defines the current value
  2856. * @param min defines the lower range value
  2857. * @param max defines the upper range value
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2861. /**
  2862. * Checks if a given vector is inside a specific range
  2863. * @param v defines the vector to test
  2864. * @param min defines the minimum range
  2865. * @param max defines the maximum range
  2866. */
  2867. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2868. /**
  2869. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2870. * @param value1 defines the first control point
  2871. * @param tangent1 defines the first tangent vector
  2872. * @param value2 defines the second control point
  2873. * @param tangent2 defines the second tangent vector
  2874. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2875. * @returns the new Vector3
  2876. */
  2877. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2878. /**
  2879. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2880. * @param start defines the start value
  2881. * @param end defines the end value
  2882. * @param amount max defines amount between both (between 0 and 1)
  2883. * @returns the new Vector3
  2884. */
  2885. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2886. /**
  2887. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2888. * @param start defines the start value
  2889. * @param end defines the end value
  2890. * @param amount max defines amount between both (between 0 and 1)
  2891. * @param result defines the Vector3 where to store the result
  2892. */
  2893. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2894. /**
  2895. * Returns the dot product (float) between the vectors "left" and "right"
  2896. * @param left defines the left operand
  2897. * @param right defines the right operand
  2898. * @returns the dot product
  2899. */
  2900. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2901. /**
  2902. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2903. * The cross product is then orthogonal to both "left" and "right"
  2904. * @param left defines the left operand
  2905. * @param right defines the right operand
  2906. * @returns the cross product
  2907. */
  2908. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2909. /**
  2910. * Sets the given vector "result" with the cross product of "left" and "right"
  2911. * The cross product is then orthogonal to both "left" and "right"
  2912. * @param left defines the left operand
  2913. * @param right defines the right operand
  2914. * @param result defines the Vector3 where to store the result
  2915. */
  2916. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2917. /**
  2918. * Returns a new Vector3 as the normalization of the given vector
  2919. * @param vector defines the Vector3 to normalize
  2920. * @returns the new Vector3
  2921. */
  2922. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2923. /**
  2924. * Sets the given vector "result" with the normalization of the given first vector
  2925. * @param vector defines the Vector3 to normalize
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2929. /**
  2930. * Project a Vector3 onto screen space
  2931. * @param vector defines the Vector3 to project
  2932. * @param world defines the world matrix to use
  2933. * @param transform defines the transform (view x projection) matrix to use
  2934. * @param viewport defines the screen viewport to use
  2935. * @returns the new Vector3
  2936. */
  2937. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2938. /** @hidden */
  2939. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2940. /**
  2941. * Unproject from screen space to object space
  2942. * @param source defines the screen space Vector3 to use
  2943. * @param viewportWidth defines the current width of the viewport
  2944. * @param viewportHeight defines the current height of the viewport
  2945. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2946. * @param transform defines the transform (view x projection) matrix to use
  2947. * @returns the new Vector3
  2948. */
  2949. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2950. /**
  2951. * Unproject from screen space to object space
  2952. * @param source defines the screen space Vector3 to use
  2953. * @param viewportWidth defines the current width of the viewport
  2954. * @param viewportHeight defines the current height of the viewport
  2955. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2956. * @param view defines the view matrix to use
  2957. * @param projection defines the projection matrix to use
  2958. * @returns the new Vector3
  2959. */
  2960. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2961. /**
  2962. * Unproject from screen space to object space
  2963. * @param source defines the screen space Vector3 to use
  2964. * @param viewportWidth defines the current width of the viewport
  2965. * @param viewportHeight defines the current height of the viewport
  2966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2967. * @param view defines the view matrix to use
  2968. * @param projection defines the projection matrix to use
  2969. * @param result defines the Vector3 where to store the result
  2970. */
  2971. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2972. /**
  2973. * Unproject from screen space to object space
  2974. * @param sourceX defines the screen space x coordinate to use
  2975. * @param sourceY defines the screen space y coordinate to use
  2976. * @param sourceZ defines the screen space z coordinate to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Gets the minimal coordinate values between two Vector3
  2987. * @param left defines the first operand
  2988. * @param right defines the second operand
  2989. * @returns the new Vector3
  2990. */
  2991. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2992. /**
  2993. * Gets the maximal coordinate values between two Vector3
  2994. * @param left defines the first operand
  2995. * @param right defines the second operand
  2996. * @returns the new Vector3
  2997. */
  2998. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2999. /**
  3000. * Returns the distance between the vectors "value1" and "value2"
  3001. * @param value1 defines the first operand
  3002. * @param value2 defines the second operand
  3003. * @returns the distance
  3004. */
  3005. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3006. /**
  3007. * Returns the squared distance between the vectors "value1" and "value2"
  3008. * @param value1 defines the first operand
  3009. * @param value2 defines the second operand
  3010. * @returns the squared distance
  3011. */
  3012. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3013. /**
  3014. * Returns a new Vector3 located at the center between "value1" and "value2"
  3015. * @param value1 defines the first operand
  3016. * @param value2 defines the second operand
  3017. * @returns the new Vector3
  3018. */
  3019. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3020. /**
  3021. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3022. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3023. * to something in order to rotate it from its local system to the given target system
  3024. * Note: axis1, axis2 and axis3 are normalized during this operation
  3025. * @param axis1 defines the first axis
  3026. * @param axis2 defines the second axis
  3027. * @param axis3 defines the third axis
  3028. * @returns a new Vector3
  3029. */
  3030. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3031. /**
  3032. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3033. * @param axis1 defines the first axis
  3034. * @param axis2 defines the second axis
  3035. * @param axis3 defines the third axis
  3036. * @param ref defines the Vector3 where to store the result
  3037. */
  3038. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3039. }
  3040. /**
  3041. * Vector4 class created for EulerAngle class conversion to Quaternion
  3042. */
  3043. export class Vector4 {
  3044. /** x value of the vector */
  3045. x: number;
  3046. /** y value of the vector */
  3047. y: number;
  3048. /** z value of the vector */
  3049. z: number;
  3050. /** w value of the vector */
  3051. w: number;
  3052. /**
  3053. * Creates a Vector4 object from the given floats.
  3054. * @param x x value of the vector
  3055. * @param y y value of the vector
  3056. * @param z z value of the vector
  3057. * @param w w value of the vector
  3058. */
  3059. constructor(
  3060. /** x value of the vector */
  3061. x: number,
  3062. /** y value of the vector */
  3063. y: number,
  3064. /** z value of the vector */
  3065. z: number,
  3066. /** w value of the vector */
  3067. w: number);
  3068. /**
  3069. * Returns the string with the Vector4 coordinates.
  3070. * @returns a string containing all the vector values
  3071. */
  3072. toString(): string;
  3073. /**
  3074. * Returns the string "Vector4".
  3075. * @returns "Vector4"
  3076. */
  3077. getClassName(): string;
  3078. /**
  3079. * Returns the Vector4 hash code.
  3080. * @returns a unique hash code
  3081. */
  3082. getHashCode(): number;
  3083. /**
  3084. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3085. * @returns the resulting array
  3086. */
  3087. asArray(): number[];
  3088. /**
  3089. * Populates the given array from the given index with the Vector4 coordinates.
  3090. * @param array array to populate
  3091. * @param index index of the array to start at (default: 0)
  3092. * @returns the Vector4.
  3093. */
  3094. toArray(array: FloatArray, index?: number): Vector4;
  3095. /**
  3096. * Adds the given vector to the current Vector4.
  3097. * @param otherVector the vector to add
  3098. * @returns the updated Vector4.
  3099. */
  3100. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3101. /**
  3102. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3103. * @param otherVector the vector to add
  3104. * @returns the resulting vector
  3105. */
  3106. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3107. /**
  3108. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3109. * @param otherVector the vector to add
  3110. * @param result the vector to store the result
  3111. * @returns the current Vector4.
  3112. */
  3113. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3114. /**
  3115. * Subtract in place the given vector from the current Vector4.
  3116. * @param otherVector the vector to subtract
  3117. * @returns the updated Vector4.
  3118. */
  3119. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3120. /**
  3121. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3122. * @param otherVector the vector to add
  3123. * @returns the new vector with the result
  3124. */
  3125. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3126. /**
  3127. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3128. * @param otherVector the vector to subtract
  3129. * @param result the vector to store the result
  3130. * @returns the current Vector4.
  3131. */
  3132. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3133. /**
  3134. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3135. */
  3136. /**
  3137. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @returns new vector containing the result
  3143. */
  3144. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3145. /**
  3146. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3147. * @param x value to subtract
  3148. * @param y value to subtract
  3149. * @param z value to subtract
  3150. * @param w value to subtract
  3151. * @param result the vector to store the result in
  3152. * @returns the current Vector4.
  3153. */
  3154. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3155. /**
  3156. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3157. * @returns a new vector with the negated values
  3158. */
  3159. negate(): Vector4;
  3160. /**
  3161. * Negate this vector in place
  3162. * @returns this
  3163. */
  3164. negateInPlace(): Vector4;
  3165. /**
  3166. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3167. * @param result defines the Vector3 object where to store the result
  3168. * @returns the current Vector4
  3169. */
  3170. negateToRef(result: Vector4): Vector4;
  3171. /**
  3172. * Multiplies the current Vector4 coordinates by scale (float).
  3173. * @param scale the number to scale with
  3174. * @returns the updated Vector4.
  3175. */
  3176. scaleInPlace(scale: number): Vector4;
  3177. /**
  3178. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3179. * @param scale the number to scale with
  3180. * @returns a new vector with the result
  3181. */
  3182. scale(scale: number): Vector4;
  3183. /**
  3184. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3185. * @param scale the number to scale with
  3186. * @param result a vector to store the result in
  3187. * @returns the current Vector4.
  3188. */
  3189. scaleToRef(scale: number, result: Vector4): Vector4;
  3190. /**
  3191. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3192. * @param scale defines the scale factor
  3193. * @param result defines the Vector4 object where to store the result
  3194. * @returns the unmodified current Vector4
  3195. */
  3196. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3197. /**
  3198. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3199. * @param otherVector the vector to compare against
  3200. * @returns true if they are equal
  3201. */
  3202. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3203. /**
  3204. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3205. * @param otherVector vector to compare against
  3206. * @param epsilon (Default: very small number)
  3207. * @returns true if they are equal
  3208. */
  3209. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3210. /**
  3211. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3212. * @param x x value to compare against
  3213. * @param y y value to compare against
  3214. * @param z z value to compare against
  3215. * @param w w value to compare against
  3216. * @returns true if equal
  3217. */
  3218. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3219. /**
  3220. * Multiplies in place the current Vector4 by the given one.
  3221. * @param otherVector vector to multiple with
  3222. * @returns the updated Vector4.
  3223. */
  3224. multiplyInPlace(otherVector: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3227. * @param otherVector vector to multiple with
  3228. * @returns resulting new vector
  3229. */
  3230. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3231. /**
  3232. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3233. * @param otherVector vector to multiple with
  3234. * @param result vector to store the result
  3235. * @returns the current Vector4.
  3236. */
  3237. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3240. * @param x x value multiply with
  3241. * @param y y value multiply with
  3242. * @param z z value multiply with
  3243. * @param w w value multiply with
  3244. * @returns resulting new vector
  3245. */
  3246. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3247. /**
  3248. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3249. * @param otherVector vector to devide with
  3250. * @returns resulting new vector
  3251. */
  3252. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3255. * @param otherVector vector to devide with
  3256. * @param result vector to store the result
  3257. * @returns the current Vector4.
  3258. */
  3259. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3260. /**
  3261. * Divides the current Vector3 coordinates by the given ones.
  3262. * @param otherVector vector to devide with
  3263. * @returns the updated Vector3.
  3264. */
  3265. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3268. * @param other defines the second operand
  3269. * @returns the current updated Vector4
  3270. */
  3271. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3272. /**
  3273. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3274. * @param other defines the second operand
  3275. * @returns the current updated Vector4
  3276. */
  3277. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3278. /**
  3279. * Gets a new Vector4 from current Vector4 floored values
  3280. * @returns a new Vector4
  3281. */
  3282. floor(): Vector4;
  3283. /**
  3284. * Gets a new Vector4 from current Vector3 floored values
  3285. * @returns a new Vector4
  3286. */
  3287. fract(): Vector4;
  3288. /**
  3289. * Returns the Vector4 length (float).
  3290. * @returns the length
  3291. */
  3292. length(): number;
  3293. /**
  3294. * Returns the Vector4 squared length (float).
  3295. * @returns the length squared
  3296. */
  3297. lengthSquared(): number;
  3298. /**
  3299. * Normalizes in place the Vector4.
  3300. * @returns the updated Vector4.
  3301. */
  3302. normalize(): Vector4;
  3303. /**
  3304. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3305. * @returns this converted to a new vector3
  3306. */
  3307. toVector3(): Vector3;
  3308. /**
  3309. * Returns a new Vector4 copied from the current one.
  3310. * @returns the new cloned vector
  3311. */
  3312. clone(): Vector4;
  3313. /**
  3314. * Updates the current Vector4 with the given one coordinates.
  3315. * @param source the source vector to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to copy from
  3322. * @param y float to copy from
  3323. * @param z float to copy from
  3324. * @param w float to copy from
  3325. * @returns the updated Vector4.
  3326. */
  3327. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Updates the current Vector4 coordinates with the given floats.
  3330. * @param x float to set from
  3331. * @param y float to set from
  3332. * @param z float to set from
  3333. * @param w float to set from
  3334. * @returns the updated Vector4.
  3335. */
  3336. set(x: number, y: number, z: number, w: number): Vector4;
  3337. /**
  3338. * Copies the given float to the current Vector3 coordinates
  3339. * @param v defines the x, y, z and w coordinates of the operand
  3340. * @returns the current updated Vector3
  3341. */
  3342. setAll(v: number): Vector4;
  3343. /**
  3344. * Returns a new Vector4 set from the starting index of the given array.
  3345. * @param array the array to pull values from
  3346. * @param offset the offset into the array to start at
  3347. * @returns the new vector
  3348. */
  3349. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3350. /**
  3351. * Updates the given vector "result" from the starting index of the given array.
  3352. * @param array the array to pull values from
  3353. * @param offset the offset into the array to start at
  3354. * @param result the vector to store the result in
  3355. */
  3356. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3357. /**
  3358. * Updates the given vector "result" from the starting index of the given Float32Array.
  3359. * @param array the array to pull values from
  3360. * @param offset the offset into the array to start at
  3361. * @param result the vector to store the result in
  3362. */
  3363. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3364. /**
  3365. * Updates the given vector "result" coordinates from the given floats.
  3366. * @param x float to set from
  3367. * @param y float to set from
  3368. * @param z float to set from
  3369. * @param w float to set from
  3370. * @param result the vector to the floats in
  3371. */
  3372. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3373. /**
  3374. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3375. * @returns the new vector
  3376. */
  3377. static Zero(): Vector4;
  3378. /**
  3379. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3380. * @returns the new vector
  3381. */
  3382. static One(): Vector4;
  3383. /**
  3384. * Returns a new normalized Vector4 from the given one.
  3385. * @param vector the vector to normalize
  3386. * @returns the vector
  3387. */
  3388. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Updates the given vector "result" from the normalization of the given one.
  3391. * @param vector the vector to normalize
  3392. * @param result the vector to store the result in
  3393. */
  3394. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3395. /**
  3396. * Returns a vector with the minimum values from the left and right vectors
  3397. * @param left left vector to minimize
  3398. * @param right right vector to minimize
  3399. * @returns a new vector with the minimum of the left and right vector values
  3400. */
  3401. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Returns a vector with the maximum values from the left and right vectors
  3404. * @param left left vector to maximize
  3405. * @param right right vector to maximize
  3406. * @returns a new vector with the maximum of the left and right vector values
  3407. */
  3408. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Returns the distance (float) between the vectors "value1" and "value2".
  3411. * @param value1 value to calulate the distance between
  3412. * @param value2 value to calulate the distance between
  3413. * @return the distance between the two vectors
  3414. */
  3415. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3416. /**
  3417. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3418. * @param value1 value to calulate the distance between
  3419. * @param value2 value to calulate the distance between
  3420. * @return the distance between the two vectors squared
  3421. */
  3422. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3423. /**
  3424. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3425. * @param value1 value to calulate the center between
  3426. * @param value2 value to calulate the center between
  3427. * @return the center between the two vectors
  3428. */
  3429. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3430. /**
  3431. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3432. * This methods computes transformed normalized direction vectors only.
  3433. * @param vector the vector to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @returns the new vector
  3436. */
  3437. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3438. /**
  3439. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3440. * This methods computes transformed normalized direction vectors only.
  3441. * @param vector the vector to transform
  3442. * @param transformation the transformation matrix to apply
  3443. * @param result the vector to store the result in
  3444. */
  3445. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3446. /**
  3447. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3448. * This methods computes transformed normalized direction vectors only.
  3449. * @param x value to transform
  3450. * @param y value to transform
  3451. * @param z value to transform
  3452. * @param w value to transform
  3453. * @param transformation the transformation matrix to apply
  3454. * @param result the vector to store the results in
  3455. */
  3456. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3457. /**
  3458. * Creates a new Vector4 from a Vector3
  3459. * @param source defines the source data
  3460. * @param w defines the 4th component (default is 0)
  3461. * @returns a new Vector4
  3462. */
  3463. static FromVector3(source: Vector3, w?: number): Vector4;
  3464. }
  3465. /**
  3466. * Class used to store quaternion data
  3467. * @see https://en.wikipedia.org/wiki/Quaternion
  3468. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3469. */
  3470. export class Quaternion {
  3471. /** defines the first component (0 by default) */
  3472. x: number;
  3473. /** defines the second component (0 by default) */
  3474. y: number;
  3475. /** defines the third component (0 by default) */
  3476. z: number;
  3477. /** defines the fourth component (1.0 by default) */
  3478. w: number;
  3479. /**
  3480. * Creates a new Quaternion from the given floats
  3481. * @param x defines the first component (0 by default)
  3482. * @param y defines the second component (0 by default)
  3483. * @param z defines the third component (0 by default)
  3484. * @param w defines the fourth component (1.0 by default)
  3485. */
  3486. constructor(
  3487. /** defines the first component (0 by default) */
  3488. x?: number,
  3489. /** defines the second component (0 by default) */
  3490. y?: number,
  3491. /** defines the third component (0 by default) */
  3492. z?: number,
  3493. /** defines the fourth component (1.0 by default) */
  3494. w?: number);
  3495. /**
  3496. * Gets a string representation for the current quaternion
  3497. * @returns a string with the Quaternion coordinates
  3498. */
  3499. toString(): string;
  3500. /**
  3501. * Gets the class name of the quaternion
  3502. * @returns the string "Quaternion"
  3503. */
  3504. getClassName(): string;
  3505. /**
  3506. * Gets a hash code for this quaternion
  3507. * @returns the quaternion hash code
  3508. */
  3509. getHashCode(): number;
  3510. /**
  3511. * Copy the quaternion to an array
  3512. * @returns a new array populated with 4 elements from the quaternion coordinates
  3513. */
  3514. asArray(): number[];
  3515. /**
  3516. * Check if two quaternions are equals
  3517. * @param otherQuaternion defines the second operand
  3518. * @return true if the current quaternion and the given one coordinates are strictly equals
  3519. */
  3520. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3521. /**
  3522. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3523. * @param otherQuaternion defines the other quaternion
  3524. * @param epsilon defines the minimal distance to consider equality
  3525. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3526. */
  3527. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3528. /**
  3529. * Clone the current quaternion
  3530. * @returns a new quaternion copied from the current one
  3531. */
  3532. clone(): Quaternion;
  3533. /**
  3534. * Copy a quaternion to the current one
  3535. * @param other defines the other quaternion
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3539. /**
  3540. * Updates the current quaternion with the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Updates the current quaternion from the given float coordinates
  3550. * @param x defines the x coordinate
  3551. * @param y defines the y coordinate
  3552. * @param z defines the z coordinate
  3553. * @param w defines the w coordinate
  3554. * @returns the updated current quaternion
  3555. */
  3556. set(x: number, y: number, z: number, w: number): Quaternion;
  3557. /**
  3558. * Adds two quaternions
  3559. * @param other defines the second operand
  3560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3561. */
  3562. add(other: DeepImmutable<Quaternion>): Quaternion;
  3563. /**
  3564. * Add a quaternion to the current one
  3565. * @param other defines the quaternion to add
  3566. * @returns the current quaternion
  3567. */
  3568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3569. /**
  3570. * Subtract two quaternions
  3571. * @param other defines the second operand
  3572. * @returns a new quaternion as the subtraction result of the given one from the current one
  3573. */
  3574. subtract(other: Quaternion): Quaternion;
  3575. /**
  3576. * Multiplies the current quaternion by a scale factor
  3577. * @param value defines the scale factor
  3578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3579. */
  3580. scale(value: number): Quaternion;
  3581. /**
  3582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3583. * @param scale defines the scale factor
  3584. * @param result defines the Quaternion object where to store the result
  3585. * @returns the unmodified current quaternion
  3586. */
  3587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies in place the current quaternion by a scale factor
  3590. * @param value defines the scale factor
  3591. * @returns the current modified quaternion
  3592. */
  3593. scaleInPlace(value: number): Quaternion;
  3594. /**
  3595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3596. * @param scale defines the scale factor
  3597. * @param result defines the Quaternion object where to store the result
  3598. * @returns the unmodified current quaternion
  3599. */
  3600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3601. /**
  3602. * Multiplies two quaternions
  3603. * @param q1 defines the second operand
  3604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3605. */
  3606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3607. /**
  3608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3609. * @param q1 defines the second operand
  3610. * @param result defines the target quaternion
  3611. * @returns the current quaternion
  3612. */
  3613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3614. /**
  3615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3616. * @param q1 defines the second operand
  3617. * @returns the currentupdated quaternion
  3618. */
  3619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3620. /**
  3621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3622. * @param ref defines the target quaternion
  3623. * @returns the current quaternion
  3624. */
  3625. conjugateToRef(ref: Quaternion): Quaternion;
  3626. /**
  3627. * Conjugates in place (1-q) the current quaternion
  3628. * @returns the current updated quaternion
  3629. */
  3630. conjugateInPlace(): Quaternion;
  3631. /**
  3632. * Conjugates in place (1-q) the current quaternion
  3633. * @returns a new quaternion
  3634. */
  3635. conjugate(): Quaternion;
  3636. /**
  3637. * Gets length of current quaternion
  3638. * @returns the quaternion length (float)
  3639. */
  3640. length(): number;
  3641. /**
  3642. * Normalize in place the current quaternion
  3643. * @returns the current updated quaternion
  3644. */
  3645. normalize(): Quaternion;
  3646. /**
  3647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3648. * @param order is a reserved parameter and is ignore for now
  3649. * @returns a new Vector3 containing the Euler angles
  3650. */
  3651. toEulerAngles(order?: string): Vector3;
  3652. /**
  3653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3654. * @param result defines the vector which will be filled with the Euler angles
  3655. * @param order is a reserved parameter and is ignore for now
  3656. * @returns the current unchanged quaternion
  3657. */
  3658. toEulerAnglesToRef(result: Vector3): Quaternion;
  3659. /**
  3660. * Updates the given rotation matrix with the current quaternion values
  3661. * @param result defines the target matrix
  3662. * @returns the current unchanged quaternion
  3663. */
  3664. toRotationMatrix(result: Matrix): Quaternion;
  3665. /**
  3666. * Updates the current quaternion from the given rotation matrix values
  3667. * @param matrix defines the source matrix
  3668. * @returns the current updated quaternion
  3669. */
  3670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3671. /**
  3672. * Creates a new quaternion from a rotation matrix
  3673. * @param matrix defines the source matrix
  3674. * @returns a new quaternion created from the given rotation matrix values
  3675. */
  3676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3677. /**
  3678. * Updates the given quaternion with the given rotation matrix values
  3679. * @param matrix defines the source matrix
  3680. * @param result defines the target quaternion
  3681. */
  3682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3683. /**
  3684. * Returns the dot product (float) between the quaternions "left" and "right"
  3685. * @param left defines the left operand
  3686. * @param right defines the right operand
  3687. * @returns the dot product
  3688. */
  3689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3690. /**
  3691. * Checks if the two quaternions are close to each other
  3692. * @param quat0 defines the first quaternion to check
  3693. * @param quat1 defines the second quaternion to check
  3694. * @returns true if the two quaternions are close to each other
  3695. */
  3696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3697. /**
  3698. * Creates an empty quaternion
  3699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3700. */
  3701. static Zero(): Quaternion;
  3702. /**
  3703. * Inverse a given quaternion
  3704. * @param q defines the source quaternion
  3705. * @returns a new quaternion as the inverted current quaternion
  3706. */
  3707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3708. /**
  3709. * Inverse a given quaternion
  3710. * @param q defines the source quaternion
  3711. * @param result the quaternion the result will be stored in
  3712. * @returns the result quaternion
  3713. */
  3714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3715. /**
  3716. * Creates an identity quaternion
  3717. * @returns the identity quaternion
  3718. */
  3719. static Identity(): Quaternion;
  3720. /**
  3721. * Gets a boolean indicating if the given quaternion is identity
  3722. * @param quaternion defines the quaternion to check
  3723. * @returns true if the quaternion is identity
  3724. */
  3725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3726. /**
  3727. * Creates a quaternion from a rotation around an axis
  3728. * @param axis defines the axis to use
  3729. * @param angle defines the angle to use
  3730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3731. */
  3732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3733. /**
  3734. * Creates a rotation around an axis and stores it into the given quaternion
  3735. * @param axis defines the axis to use
  3736. * @param angle defines the angle to use
  3737. * @param result defines the target quaternion
  3738. * @returns the target quaternion
  3739. */
  3740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3741. /**
  3742. * Creates a new quaternion from data stored into an array
  3743. * @param array defines the data source
  3744. * @param offset defines the offset in the source array where the data starts
  3745. * @returns a new quaternion
  3746. */
  3747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3748. /**
  3749. * Updates the given quaternion "result" from the starting index of the given array.
  3750. * @param array the array to pull values from
  3751. * @param offset the offset into the array to start at
  3752. * @param result the quaternion to store the result in
  3753. */
  3754. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3755. /**
  3756. * Create a quaternion from Euler rotation angles
  3757. * @param x Pitch
  3758. * @param y Yaw
  3759. * @param z Roll
  3760. * @returns the new Quaternion
  3761. */
  3762. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3763. /**
  3764. * Updates a quaternion from Euler rotation angles
  3765. * @param x Pitch
  3766. * @param y Yaw
  3767. * @param z Roll
  3768. * @param result the quaternion to store the result
  3769. * @returns the updated quaternion
  3770. */
  3771. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Create a quaternion from Euler rotation vector
  3774. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3775. * @returns the new Quaternion
  3776. */
  3777. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3778. /**
  3779. * Updates a quaternion from Euler rotation vector
  3780. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3781. * @param result the quaternion to store the result
  3782. * @returns the updated quaternion
  3783. */
  3784. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3785. /**
  3786. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3787. * @param yaw defines the rotation around Y axis
  3788. * @param pitch defines the rotation around X axis
  3789. * @param roll defines the rotation around Z axis
  3790. * @returns the new quaternion
  3791. */
  3792. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3793. /**
  3794. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3795. * @param yaw defines the rotation around Y axis
  3796. * @param pitch defines the rotation around X axis
  3797. * @param roll defines the rotation around Z axis
  3798. * @param result defines the target quaternion
  3799. */
  3800. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3801. /**
  3802. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3803. * @param alpha defines the rotation around first axis
  3804. * @param beta defines the rotation around second axis
  3805. * @param gamma defines the rotation around third axis
  3806. * @returns the new quaternion
  3807. */
  3808. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3811. * @param alpha defines the rotation around first axis
  3812. * @param beta defines the rotation around second axis
  3813. * @param gamma defines the rotation around third axis
  3814. * @param result defines the target quaternion
  3815. */
  3816. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3817. /**
  3818. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3819. * @param axis1 defines the first axis
  3820. * @param axis2 defines the second axis
  3821. * @param axis3 defines the third axis
  3822. * @returns the new quaternion
  3823. */
  3824. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3825. /**
  3826. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3827. * @param axis1 defines the first axis
  3828. * @param axis2 defines the second axis
  3829. * @param axis3 defines the third axis
  3830. * @param ref defines the target quaternion
  3831. */
  3832. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3833. /**
  3834. * Interpolates between two quaternions
  3835. * @param left defines first quaternion
  3836. * @param right defines second quaternion
  3837. * @param amount defines the gradient to use
  3838. * @returns the new interpolated quaternion
  3839. */
  3840. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3841. /**
  3842. * Interpolates between two quaternions and stores it into a target quaternion
  3843. * @param left defines first quaternion
  3844. * @param right defines second quaternion
  3845. * @param amount defines the gradient to use
  3846. * @param result defines the target quaternion
  3847. */
  3848. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3849. /**
  3850. * Interpolate between two quaternions using Hermite interpolation
  3851. * @param value1 defines first quaternion
  3852. * @param tangent1 defines the incoming tangent
  3853. * @param value2 defines second quaternion
  3854. * @param tangent2 defines the outgoing tangent
  3855. * @param amount defines the target quaternion
  3856. * @returns the new interpolated quaternion
  3857. */
  3858. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3859. }
  3860. /**
  3861. * Class used to store matrix data (4x4)
  3862. */
  3863. export class Matrix {
  3864. private static _updateFlagSeed;
  3865. private static _identityReadOnly;
  3866. private _isIdentity;
  3867. private _isIdentityDirty;
  3868. private _isIdentity3x2;
  3869. private _isIdentity3x2Dirty;
  3870. /**
  3871. * Gets the update flag of the matrix which is an unique number for the matrix.
  3872. * It will be incremented every time the matrix data change.
  3873. * You can use it to speed the comparison between two versions of the same matrix.
  3874. */
  3875. updateFlag: number;
  3876. private readonly _m;
  3877. /**
  3878. * Gets the internal data of the matrix
  3879. */
  3880. get m(): DeepImmutable<Float32Array>;
  3881. /** @hidden */
  3882. _markAsUpdated(): void;
  3883. /** @hidden */
  3884. private _updateIdentityStatus;
  3885. /**
  3886. * Creates an empty matrix (filled with zeros)
  3887. */
  3888. constructor();
  3889. /**
  3890. * Check if the current matrix is identity
  3891. * @returns true is the matrix is the identity matrix
  3892. */
  3893. isIdentity(): boolean;
  3894. /**
  3895. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3896. * @returns true is the matrix is the identity matrix
  3897. */
  3898. isIdentityAs3x2(): boolean;
  3899. /**
  3900. * Gets the determinant of the matrix
  3901. * @returns the matrix determinant
  3902. */
  3903. determinant(): number;
  3904. /**
  3905. * Returns the matrix as a Float32Array
  3906. * @returns the matrix underlying array
  3907. */
  3908. toArray(): DeepImmutable<Float32Array>;
  3909. /**
  3910. * Returns the matrix as a Float32Array
  3911. * @returns the matrix underlying array.
  3912. */
  3913. asArray(): DeepImmutable<Float32Array>;
  3914. /**
  3915. * Inverts the current matrix in place
  3916. * @returns the current inverted matrix
  3917. */
  3918. invert(): Matrix;
  3919. /**
  3920. * Sets all the matrix elements to zero
  3921. * @returns the current matrix
  3922. */
  3923. reset(): Matrix;
  3924. /**
  3925. * Adds the current matrix with a second one
  3926. * @param other defines the matrix to add
  3927. * @returns a new matrix as the addition of the current matrix and the given one
  3928. */
  3929. add(other: DeepImmutable<Matrix>): Matrix;
  3930. /**
  3931. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3932. * @param other defines the matrix to add
  3933. * @param result defines the target matrix
  3934. * @returns the current matrix
  3935. */
  3936. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3937. /**
  3938. * Adds in place the given matrix to the current matrix
  3939. * @param other defines the second operand
  3940. * @returns the current updated matrix
  3941. */
  3942. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3943. /**
  3944. * Sets the given matrix to the current inverted Matrix
  3945. * @param other defines the target matrix
  3946. * @returns the unmodified current matrix
  3947. */
  3948. invertToRef(other: Matrix): Matrix;
  3949. /**
  3950. * add a value at the specified position in the current Matrix
  3951. * @param index the index of the value within the matrix. between 0 and 15.
  3952. * @param value the value to be added
  3953. * @returns the current updated matrix
  3954. */
  3955. addAtIndex(index: number, value: number): Matrix;
  3956. /**
  3957. * mutiply the specified position in the current Matrix by a value
  3958. * @param index the index of the value within the matrix. between 0 and 15.
  3959. * @param value the value to be added
  3960. * @returns the current updated matrix
  3961. */
  3962. multiplyAtIndex(index: number, value: number): Matrix;
  3963. /**
  3964. * Inserts the translation vector (using 3 floats) in the current matrix
  3965. * @param x defines the 1st component of the translation
  3966. * @param y defines the 2nd component of the translation
  3967. * @param z defines the 3rd component of the translation
  3968. * @returns the current updated matrix
  3969. */
  3970. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3971. /**
  3972. * Adds the translation vector (using 3 floats) in the current matrix
  3973. * @param x defines the 1st component of the translation
  3974. * @param y defines the 2nd component of the translation
  3975. * @param z defines the 3rd component of the translation
  3976. * @returns the current updated matrix
  3977. */
  3978. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3979. /**
  3980. * Inserts the translation vector in the current matrix
  3981. * @param vector3 defines the translation to insert
  3982. * @returns the current updated matrix
  3983. */
  3984. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3985. /**
  3986. * Gets the translation value of the current matrix
  3987. * @returns a new Vector3 as the extracted translation from the matrix
  3988. */
  3989. getTranslation(): Vector3;
  3990. /**
  3991. * Fill a Vector3 with the extracted translation from the matrix
  3992. * @param result defines the Vector3 where to store the translation
  3993. * @returns the current matrix
  3994. */
  3995. getTranslationToRef(result: Vector3): Matrix;
  3996. /**
  3997. * Remove rotation and scaling part from the matrix
  3998. * @returns the updated matrix
  3999. */
  4000. removeRotationAndScaling(): Matrix;
  4001. /**
  4002. * Multiply two matrices
  4003. * @param other defines the second operand
  4004. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4005. */
  4006. multiply(other: DeepImmutable<Matrix>): Matrix;
  4007. /**
  4008. * Copy the current matrix from the given one
  4009. * @param other defines the source matrix
  4010. * @returns the current updated matrix
  4011. */
  4012. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4013. /**
  4014. * Populates the given array from the starting index with the current matrix values
  4015. * @param array defines the target array
  4016. * @param offset defines the offset in the target array where to start storing values
  4017. * @returns the current matrix
  4018. */
  4019. copyToArray(array: Float32Array, offset?: number): Matrix;
  4020. /**
  4021. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4022. * @param other defines the second operand
  4023. * @param result defines the matrix where to store the multiplication
  4024. * @returns the current matrix
  4025. */
  4026. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4027. /**
  4028. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4029. * @param other defines the second operand
  4030. * @param result defines the array where to store the multiplication
  4031. * @param offset defines the offset in the target array where to start storing values
  4032. * @returns the current matrix
  4033. */
  4034. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4035. /**
  4036. * Check equality between this matrix and a second one
  4037. * @param value defines the second matrix to compare
  4038. * @returns true is the current matrix and the given one values are strictly equal
  4039. */
  4040. equals(value: DeepImmutable<Matrix>): boolean;
  4041. /**
  4042. * Clone the current matrix
  4043. * @returns a new matrix from the current matrix
  4044. */
  4045. clone(): Matrix;
  4046. /**
  4047. * Returns the name of the current matrix class
  4048. * @returns the string "Matrix"
  4049. */
  4050. getClassName(): string;
  4051. /**
  4052. * Gets the hash code of the current matrix
  4053. * @returns the hash code
  4054. */
  4055. getHashCode(): number;
  4056. /**
  4057. * Decomposes the current Matrix into a translation, rotation and scaling components
  4058. * @param scale defines the scale vector3 given as a reference to update
  4059. * @param rotation defines the rotation quaternion given as a reference to update
  4060. * @param translation defines the translation vector3 given as a reference to update
  4061. * @returns true if operation was successful
  4062. */
  4063. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4064. /**
  4065. * Gets specific row of the matrix
  4066. * @param index defines the number of the row to get
  4067. * @returns the index-th row of the current matrix as a new Vector4
  4068. */
  4069. getRow(index: number): Nullable<Vector4>;
  4070. /**
  4071. * Sets the index-th row of the current matrix to the vector4 values
  4072. * @param index defines the number of the row to set
  4073. * @param row defines the target vector4
  4074. * @returns the updated current matrix
  4075. */
  4076. setRow(index: number, row: Vector4): Matrix;
  4077. /**
  4078. * Compute the transpose of the matrix
  4079. * @returns the new transposed matrix
  4080. */
  4081. transpose(): Matrix;
  4082. /**
  4083. * Compute the transpose of the matrix and store it in a given matrix
  4084. * @param result defines the target matrix
  4085. * @returns the current matrix
  4086. */
  4087. transposeToRef(result: Matrix): Matrix;
  4088. /**
  4089. * Sets the index-th row of the current matrix with the given 4 x float values
  4090. * @param index defines the row index
  4091. * @param x defines the x component to set
  4092. * @param y defines the y component to set
  4093. * @param z defines the z component to set
  4094. * @param w defines the w component to set
  4095. * @returns the updated current matrix
  4096. */
  4097. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4098. /**
  4099. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4100. * @param scale defines the scale factor
  4101. * @returns a new matrix
  4102. */
  4103. scale(scale: number): Matrix;
  4104. /**
  4105. * Scale the current matrix values by a factor to a given result matrix
  4106. * @param scale defines the scale factor
  4107. * @param result defines the matrix to store the result
  4108. * @returns the current matrix
  4109. */
  4110. scaleToRef(scale: number, result: Matrix): Matrix;
  4111. /**
  4112. * Scale the current matrix values by a factor and add the result to a given matrix
  4113. * @param scale defines the scale factor
  4114. * @param result defines the Matrix to store the result
  4115. * @returns the current matrix
  4116. */
  4117. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4118. /**
  4119. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4120. * @param ref matrix to store the result
  4121. */
  4122. toNormalMatrix(ref: Matrix): void;
  4123. /**
  4124. * Gets only rotation part of the current matrix
  4125. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4126. */
  4127. getRotationMatrix(): Matrix;
  4128. /**
  4129. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4130. * @param result defines the target matrix to store data to
  4131. * @returns the current matrix
  4132. */
  4133. getRotationMatrixToRef(result: Matrix): Matrix;
  4134. /**
  4135. * Toggles model matrix from being right handed to left handed in place and vice versa
  4136. */
  4137. toggleModelMatrixHandInPlace(): void;
  4138. /**
  4139. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4140. */
  4141. toggleProjectionMatrixHandInPlace(): void;
  4142. /**
  4143. * Creates a matrix from an array
  4144. * @param array defines the source array
  4145. * @param offset defines an offset in the source array
  4146. * @returns a new Matrix set from the starting index of the given array
  4147. */
  4148. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4149. /**
  4150. * Copy the content of an array into a given matrix
  4151. * @param array defines the source array
  4152. * @param offset defines an offset in the source array
  4153. * @param result defines the target matrix
  4154. */
  4155. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4156. /**
  4157. * Stores an array into a matrix after having multiplied each component by a given factor
  4158. * @param array defines the source array
  4159. * @param offset defines the offset in the source array
  4160. * @param scale defines the scaling factor
  4161. * @param result defines the target matrix
  4162. */
  4163. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4164. /**
  4165. * Gets an identity matrix that must not be updated
  4166. */
  4167. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4168. /**
  4169. * Stores a list of values (16) inside a given matrix
  4170. * @param initialM11 defines 1st value of 1st row
  4171. * @param initialM12 defines 2nd value of 1st row
  4172. * @param initialM13 defines 3rd value of 1st row
  4173. * @param initialM14 defines 4th value of 1st row
  4174. * @param initialM21 defines 1st value of 2nd row
  4175. * @param initialM22 defines 2nd value of 2nd row
  4176. * @param initialM23 defines 3rd value of 2nd row
  4177. * @param initialM24 defines 4th value of 2nd row
  4178. * @param initialM31 defines 1st value of 3rd row
  4179. * @param initialM32 defines 2nd value of 3rd row
  4180. * @param initialM33 defines 3rd value of 3rd row
  4181. * @param initialM34 defines 4th value of 3rd row
  4182. * @param initialM41 defines 1st value of 4th row
  4183. * @param initialM42 defines 2nd value of 4th row
  4184. * @param initialM43 defines 3rd value of 4th row
  4185. * @param initialM44 defines 4th value of 4th row
  4186. * @param result defines the target matrix
  4187. */
  4188. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4189. /**
  4190. * Creates new matrix from a list of values (16)
  4191. * @param initialM11 defines 1st value of 1st row
  4192. * @param initialM12 defines 2nd value of 1st row
  4193. * @param initialM13 defines 3rd value of 1st row
  4194. * @param initialM14 defines 4th value of 1st row
  4195. * @param initialM21 defines 1st value of 2nd row
  4196. * @param initialM22 defines 2nd value of 2nd row
  4197. * @param initialM23 defines 3rd value of 2nd row
  4198. * @param initialM24 defines 4th value of 2nd row
  4199. * @param initialM31 defines 1st value of 3rd row
  4200. * @param initialM32 defines 2nd value of 3rd row
  4201. * @param initialM33 defines 3rd value of 3rd row
  4202. * @param initialM34 defines 4th value of 3rd row
  4203. * @param initialM41 defines 1st value of 4th row
  4204. * @param initialM42 defines 2nd value of 4th row
  4205. * @param initialM43 defines 3rd value of 4th row
  4206. * @param initialM44 defines 4th value of 4th row
  4207. * @returns the new matrix
  4208. */
  4209. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4210. /**
  4211. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4212. * @param scale defines the scale vector3
  4213. * @param rotation defines the rotation quaternion
  4214. * @param translation defines the translation vector3
  4215. * @returns a new matrix
  4216. */
  4217. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4218. /**
  4219. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4220. * @param scale defines the scale vector3
  4221. * @param rotation defines the rotation quaternion
  4222. * @param translation defines the translation vector3
  4223. * @param result defines the target matrix
  4224. */
  4225. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4226. /**
  4227. * Creates a new identity matrix
  4228. * @returns a new identity matrix
  4229. */
  4230. static Identity(): Matrix;
  4231. /**
  4232. * Creates a new identity matrix and stores the result in a given matrix
  4233. * @param result defines the target matrix
  4234. */
  4235. static IdentityToRef(result: Matrix): void;
  4236. /**
  4237. * Creates a new zero matrix
  4238. * @returns a new zero matrix
  4239. */
  4240. static Zero(): Matrix;
  4241. /**
  4242. * Creates a new rotation matrix for "angle" radians around the X axis
  4243. * @param angle defines the angle (in radians) to use
  4244. * @return the new matrix
  4245. */
  4246. static RotationX(angle: number): Matrix;
  4247. /**
  4248. * Creates a new matrix as the invert of a given matrix
  4249. * @param source defines the source matrix
  4250. * @returns the new matrix
  4251. */
  4252. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4253. /**
  4254. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4255. * @param angle defines the angle (in radians) to use
  4256. * @param result defines the target matrix
  4257. */
  4258. static RotationXToRef(angle: number, result: Matrix): void;
  4259. /**
  4260. * Creates a new rotation matrix for "angle" radians around the Y axis
  4261. * @param angle defines the angle (in radians) to use
  4262. * @return the new matrix
  4263. */
  4264. static RotationY(angle: number): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4267. * @param angle defines the angle (in radians) to use
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationYToRef(angle: number, result: Matrix): void;
  4271. /**
  4272. * Creates a new rotation matrix for "angle" radians around the Z axis
  4273. * @param angle defines the angle (in radians) to use
  4274. * @return the new matrix
  4275. */
  4276. static RotationZ(angle: number): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationZToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the given axis
  4285. * @param axis defines the axis to use
  4286. * @param angle defines the angle (in radians) to use
  4287. * @return the new matrix
  4288. */
  4289. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4290. /**
  4291. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4292. * @param axis defines the axis to use
  4293. * @param angle defines the angle (in radians) to use
  4294. * @param result defines the target matrix
  4295. */
  4296. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4297. /**
  4298. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4299. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4300. * @param from defines the vector to align
  4301. * @param to defines the vector to align to
  4302. * @param result defines the target matrix
  4303. */
  4304. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4305. /**
  4306. * Creates a rotation matrix
  4307. * @param yaw defines the yaw angle in radians (Y axis)
  4308. * @param pitch defines the pitch angle in radians (X axis)
  4309. * @param roll defines the roll angle in radians (X axis)
  4310. * @returns the new rotation matrix
  4311. */
  4312. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4313. /**
  4314. * Creates a rotation matrix and stores it in a given matrix
  4315. * @param yaw defines the yaw angle in radians (Y axis)
  4316. * @param pitch defines the pitch angle in radians (X axis)
  4317. * @param roll defines the roll angle in radians (X axis)
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4321. /**
  4322. * Creates a scaling matrix
  4323. * @param x defines the scale factor on X axis
  4324. * @param y defines the scale factor on Y axis
  4325. * @param z defines the scale factor on Z axis
  4326. * @returns the new matrix
  4327. */
  4328. static Scaling(x: number, y: number, z: number): Matrix;
  4329. /**
  4330. * Creates a scaling matrix and stores it in a given matrix
  4331. * @param x defines the scale factor on X axis
  4332. * @param y defines the scale factor on Y axis
  4333. * @param z defines the scale factor on Z axis
  4334. * @param result defines the target matrix
  4335. */
  4336. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4337. /**
  4338. * Creates a translation matrix
  4339. * @param x defines the translation on X axis
  4340. * @param y defines the translation on Y axis
  4341. * @param z defines the translationon Z axis
  4342. * @returns the new matrix
  4343. */
  4344. static Translation(x: number, y: number, z: number): Matrix;
  4345. /**
  4346. * Creates a translation matrix and stores it in a given matrix
  4347. * @param x defines the translation on X axis
  4348. * @param y defines the translation on Y axis
  4349. * @param z defines the translationon Z axis
  4350. * @param result defines the target matrix
  4351. */
  4352. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4353. /**
  4354. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4355. * @param startValue defines the start value
  4356. * @param endValue defines the end value
  4357. * @param gradient defines the gradient factor
  4358. * @returns the new matrix
  4359. */
  4360. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4361. /**
  4362. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4363. * @param startValue defines the start value
  4364. * @param endValue defines the end value
  4365. * @param gradient defines the gradient factor
  4366. * @param result defines the Matrix object where to store data
  4367. */
  4368. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4369. /**
  4370. * Builds a new matrix whose values are computed by:
  4371. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4372. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4373. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4374. * @param startValue defines the first matrix
  4375. * @param endValue defines the second matrix
  4376. * @param gradient defines the gradient between the two matrices
  4377. * @returns the new matrix
  4378. */
  4379. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4380. /**
  4381. * Update a matrix to values which are computed by:
  4382. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4383. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4384. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4385. * @param startValue defines the first matrix
  4386. * @param endValue defines the second matrix
  4387. * @param gradient defines the gradient between the two matrices
  4388. * @param result defines the target matrix
  4389. */
  4390. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4391. /**
  4392. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @returns the new matrix
  4398. */
  4399. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4400. /**
  4401. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4402. * This function works in left handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @param result defines the target matrix
  4407. */
  4408. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4409. /**
  4410. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @returns the new matrix
  4416. */
  4417. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4418. /**
  4419. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4420. * This function works in right handed mode
  4421. * @param eye defines the final position of the entity
  4422. * @param target defines where the entity should look at
  4423. * @param up defines the up vector for the entity
  4424. * @param result defines the target matrix
  4425. */
  4426. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4427. /**
  4428. * Create a left-handed orthographic projection matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @returns a new matrix as a left-handed orthographic projection matrix
  4434. */
  4435. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4436. /**
  4437. * Store a left-handed orthographic projection to a given matrix
  4438. * @param width defines the viewport width
  4439. * @param height defines the viewport height
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @param result defines the target matrix
  4443. */
  4444. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4445. /**
  4446. * Create a left-handed orthographic projection matrix
  4447. * @param left defines the viewport left coordinate
  4448. * @param right defines the viewport right coordinate
  4449. * @param bottom defines the viewport bottom coordinate
  4450. * @param top defines the viewport top coordinate
  4451. * @param znear defines the near clip plane
  4452. * @param zfar defines the far clip plane
  4453. * @returns a new matrix as a left-handed orthographic projection matrix
  4454. */
  4455. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4456. /**
  4457. * Stores a left-handed orthographic projection into a given matrix
  4458. * @param left defines the viewport left coordinate
  4459. * @param right defines the viewport right coordinate
  4460. * @param bottom defines the viewport bottom coordinate
  4461. * @param top defines the viewport top coordinate
  4462. * @param znear defines the near clip plane
  4463. * @param zfar defines the far clip plane
  4464. * @param result defines the target matrix
  4465. */
  4466. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4467. /**
  4468. * Creates a right-handed orthographic projection matrix
  4469. * @param left defines the viewport left coordinate
  4470. * @param right defines the viewport right coordinate
  4471. * @param bottom defines the viewport bottom coordinate
  4472. * @param top defines the viewport top coordinate
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @returns a new matrix as a right-handed orthographic projection matrix
  4476. */
  4477. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4478. /**
  4479. * Stores a right-handed orthographic projection into a given matrix
  4480. * @param left defines the viewport left coordinate
  4481. * @param right defines the viewport right coordinate
  4482. * @param bottom defines the viewport bottom coordinate
  4483. * @param top defines the viewport top coordinate
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. */
  4488. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param width defines the viewport width
  4492. * @param height defines the viewport height
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Creates a left-handed perspective projection matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @returns a new matrix as a left-handed perspective projection matrix
  4505. */
  4506. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4507. /**
  4508. * Stores a left-handed perspective projection into a given matrix
  4509. * @param fov defines the horizontal field of view
  4510. * @param aspect defines the aspect ratio
  4511. * @param znear defines the near clip plane
  4512. * @param zfar defines the far clip plane
  4513. * @param result defines the target matrix
  4514. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4515. */
  4516. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4517. /**
  4518. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4519. * @param fov defines the horizontal field of view
  4520. * @param aspect defines the aspect ratio
  4521. * @param znear defines the near clip plane
  4522. * @param zfar not used as infinity is used as far clip
  4523. * @param result defines the target matrix
  4524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4525. */
  4526. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4527. /**
  4528. * Creates a right-handed perspective projection matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @returns a new matrix as a right-handed perspective projection matrix
  4534. */
  4535. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4536. /**
  4537. * Stores a right-handed perspective projection into a given matrix
  4538. * @param fov defines the horizontal field of view
  4539. * @param aspect defines the aspect ratio
  4540. * @param znear defines the near clip plane
  4541. * @param zfar defines the far clip plane
  4542. * @param result defines the target matrix
  4543. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4544. */
  4545. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4546. /**
  4547. * Stores a right-handed perspective projection into a given matrix
  4548. * @param fov defines the horizontal field of view
  4549. * @param aspect defines the aspect ratio
  4550. * @param znear defines the near clip plane
  4551. * @param zfar not used as infinity is used as far clip
  4552. * @param result defines the target matrix
  4553. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4554. */
  4555. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4556. /**
  4557. * Stores a perspective projection for WebVR info a given matrix
  4558. * @param fov defines the field of view
  4559. * @param znear defines the near clip plane
  4560. * @param zfar defines the far clip plane
  4561. * @param result defines the target matrix
  4562. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4563. */
  4564. static PerspectiveFovWebVRToRef(fov: {
  4565. upDegrees: number;
  4566. downDegrees: number;
  4567. leftDegrees: number;
  4568. rightDegrees: number;
  4569. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4570. /**
  4571. * Computes a complete transformation matrix
  4572. * @param viewport defines the viewport to use
  4573. * @param world defines the world matrix
  4574. * @param view defines the view matrix
  4575. * @param projection defines the projection matrix
  4576. * @param zmin defines the near clip plane
  4577. * @param zmax defines the far clip plane
  4578. * @returns the transformation matrix
  4579. */
  4580. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4581. /**
  4582. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4583. * @param matrix defines the matrix to use
  4584. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4585. */
  4586. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4587. /**
  4588. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4589. * @param matrix defines the matrix to use
  4590. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4591. */
  4592. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4593. /**
  4594. * Compute the transpose of a given matrix
  4595. * @param matrix defines the matrix to transpose
  4596. * @returns the new matrix
  4597. */
  4598. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4599. /**
  4600. * Compute the transpose of a matrix and store it in a target matrix
  4601. * @param matrix defines the matrix to transpose
  4602. * @param result defines the target matrix
  4603. */
  4604. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4605. /**
  4606. * Computes a reflection matrix from a plane
  4607. * @param plane defines the reflection plane
  4608. * @returns a new matrix
  4609. */
  4610. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4611. /**
  4612. * Computes a reflection matrix from a plane
  4613. * @param plane defines the reflection plane
  4614. * @param result defines the target matrix
  4615. */
  4616. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4617. /**
  4618. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4619. * @param xaxis defines the value of the 1st axis
  4620. * @param yaxis defines the value of the 2nd axis
  4621. * @param zaxis defines the value of the 3rd axis
  4622. * @param result defines the target matrix
  4623. */
  4624. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4625. /**
  4626. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4627. * @param quat defines the quaternion to use
  4628. * @param result defines the target matrix
  4629. */
  4630. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4631. }
  4632. /**
  4633. * @hidden
  4634. */
  4635. export class TmpVectors {
  4636. static Vector2: Vector2[];
  4637. static Vector3: Vector3[];
  4638. static Vector4: Vector4[];
  4639. static Quaternion: Quaternion[];
  4640. static Matrix: Matrix[];
  4641. }
  4642. }
  4643. declare module BABYLON {
  4644. /**
  4645. * Defines potential orientation for back face culling
  4646. */
  4647. export enum Orientation {
  4648. /**
  4649. * Clockwise
  4650. */
  4651. CW = 0,
  4652. /** Counter clockwise */
  4653. CCW = 1
  4654. }
  4655. /** Class used to represent a Bezier curve */
  4656. export class BezierCurve {
  4657. /**
  4658. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4659. * @param t defines the time
  4660. * @param x1 defines the left coordinate on X axis
  4661. * @param y1 defines the left coordinate on Y axis
  4662. * @param x2 defines the right coordinate on X axis
  4663. * @param y2 defines the right coordinate on Y axis
  4664. * @returns the interpolated value
  4665. */
  4666. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4667. }
  4668. /**
  4669. * Defines angle representation
  4670. */
  4671. export class Angle {
  4672. private _radians;
  4673. /**
  4674. * Creates an Angle object of "radians" radians (float).
  4675. * @param radians the angle in radians
  4676. */
  4677. constructor(radians: number);
  4678. /**
  4679. * Get value in degrees
  4680. * @returns the Angle value in degrees (float)
  4681. */
  4682. degrees(): number;
  4683. /**
  4684. * Get value in radians
  4685. * @returns the Angle value in radians (float)
  4686. */
  4687. radians(): number;
  4688. /**
  4689. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4690. * @param a defines first vector
  4691. * @param b defines second vector
  4692. * @returns a new Angle
  4693. */
  4694. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4695. /**
  4696. * Gets a new Angle object from the given float in radians
  4697. * @param radians defines the angle value in radians
  4698. * @returns a new Angle
  4699. */
  4700. static FromRadians(radians: number): Angle;
  4701. /**
  4702. * Gets a new Angle object from the given float in degrees
  4703. * @param degrees defines the angle value in degrees
  4704. * @returns a new Angle
  4705. */
  4706. static FromDegrees(degrees: number): Angle;
  4707. }
  4708. /**
  4709. * This represents an arc in a 2d space.
  4710. */
  4711. export class Arc2 {
  4712. /** Defines the start point of the arc */
  4713. startPoint: Vector2;
  4714. /** Defines the mid point of the arc */
  4715. midPoint: Vector2;
  4716. /** Defines the end point of the arc */
  4717. endPoint: Vector2;
  4718. /**
  4719. * Defines the center point of the arc.
  4720. */
  4721. centerPoint: Vector2;
  4722. /**
  4723. * Defines the radius of the arc.
  4724. */
  4725. radius: number;
  4726. /**
  4727. * Defines the angle of the arc (from mid point to end point).
  4728. */
  4729. angle: Angle;
  4730. /**
  4731. * Defines the start angle of the arc (from start point to middle point).
  4732. */
  4733. startAngle: Angle;
  4734. /**
  4735. * Defines the orientation of the arc (clock wise/counter clock wise).
  4736. */
  4737. orientation: Orientation;
  4738. /**
  4739. * Creates an Arc object from the three given points : start, middle and end.
  4740. * @param startPoint Defines the start point of the arc
  4741. * @param midPoint Defines the midlle point of the arc
  4742. * @param endPoint Defines the end point of the arc
  4743. */
  4744. constructor(
  4745. /** Defines the start point of the arc */
  4746. startPoint: Vector2,
  4747. /** Defines the mid point of the arc */
  4748. midPoint: Vector2,
  4749. /** Defines the end point of the arc */
  4750. endPoint: Vector2);
  4751. }
  4752. /**
  4753. * Represents a 2D path made up of multiple 2D points
  4754. */
  4755. export class Path2 {
  4756. private _points;
  4757. private _length;
  4758. /**
  4759. * If the path start and end point are the same
  4760. */
  4761. closed: boolean;
  4762. /**
  4763. * Creates a Path2 object from the starting 2D coordinates x and y.
  4764. * @param x the starting points x value
  4765. * @param y the starting points y value
  4766. */
  4767. constructor(x: number, y: number);
  4768. /**
  4769. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4770. * @param x the added points x value
  4771. * @param y the added points y value
  4772. * @returns the updated Path2.
  4773. */
  4774. addLineTo(x: number, y: number): Path2;
  4775. /**
  4776. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4777. * @param midX middle point x value
  4778. * @param midY middle point y value
  4779. * @param endX end point x value
  4780. * @param endY end point y value
  4781. * @param numberOfSegments (default: 36)
  4782. * @returns the updated Path2.
  4783. */
  4784. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4785. /**
  4786. * Closes the Path2.
  4787. * @returns the Path2.
  4788. */
  4789. close(): Path2;
  4790. /**
  4791. * Gets the sum of the distance between each sequential point in the path
  4792. * @returns the Path2 total length (float).
  4793. */
  4794. length(): number;
  4795. /**
  4796. * Gets the points which construct the path
  4797. * @returns the Path2 internal array of points.
  4798. */
  4799. getPoints(): Vector2[];
  4800. /**
  4801. * Retreives the point at the distance aways from the starting point
  4802. * @param normalizedLengthPosition the length along the path to retreive the point from
  4803. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4804. */
  4805. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4806. /**
  4807. * Creates a new path starting from an x and y position
  4808. * @param x starting x value
  4809. * @param y starting y value
  4810. * @returns a new Path2 starting at the coordinates (x, y).
  4811. */
  4812. static StartingAt(x: number, y: number): Path2;
  4813. }
  4814. /**
  4815. * Represents a 3D path made up of multiple 3D points
  4816. */
  4817. export class Path3D {
  4818. /**
  4819. * an array of Vector3, the curve axis of the Path3D
  4820. */
  4821. path: Vector3[];
  4822. private _curve;
  4823. private _distances;
  4824. private _tangents;
  4825. private _normals;
  4826. private _binormals;
  4827. private _raw;
  4828. private _alignTangentsWithPath;
  4829. private readonly _pointAtData;
  4830. /**
  4831. * new Path3D(path, normal, raw)
  4832. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4833. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4834. * @param path an array of Vector3, the curve axis of the Path3D
  4835. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4836. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4837. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4838. */
  4839. constructor(
  4840. /**
  4841. * an array of Vector3, the curve axis of the Path3D
  4842. */
  4843. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4844. /**
  4845. * Returns the Path3D array of successive Vector3 designing its curve.
  4846. * @returns the Path3D array of successive Vector3 designing its curve.
  4847. */
  4848. getCurve(): Vector3[];
  4849. /**
  4850. * Returns the Path3D array of successive Vector3 designing its curve.
  4851. * @returns the Path3D array of successive Vector3 designing its curve.
  4852. */
  4853. getPoints(): Vector3[];
  4854. /**
  4855. * @returns the computed length (float) of the path.
  4856. */
  4857. length(): number;
  4858. /**
  4859. * Returns an array populated with tangent vectors on each Path3D curve point.
  4860. * @returns an array populated with tangent vectors on each Path3D curve point.
  4861. */
  4862. getTangents(): Vector3[];
  4863. /**
  4864. * Returns an array populated with normal vectors on each Path3D curve point.
  4865. * @returns an array populated with normal vectors on each Path3D curve point.
  4866. */
  4867. getNormals(): Vector3[];
  4868. /**
  4869. * Returns an array populated with binormal vectors on each Path3D curve point.
  4870. * @returns an array populated with binormal vectors on each Path3D curve point.
  4871. */
  4872. getBinormals(): Vector3[];
  4873. /**
  4874. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4875. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4876. */
  4877. getDistances(): number[];
  4878. /**
  4879. * Returns an interpolated point along this path
  4880. * @param position the position of the point along this path, from 0.0 to 1.0
  4881. * @returns a new Vector3 as the point
  4882. */
  4883. getPointAt(position: number): Vector3;
  4884. /**
  4885. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4886. * @param position the position of the point along this path, from 0.0 to 1.0
  4887. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4888. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4889. */
  4890. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4891. /**
  4892. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4893. * @param position the position of the point along this path, from 0.0 to 1.0
  4894. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4895. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4896. */
  4897. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4898. /**
  4899. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4900. * @param position the position of the point along this path, from 0.0 to 1.0
  4901. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4902. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4903. */
  4904. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4905. /**
  4906. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4907. * @param position the position of the point along this path, from 0.0 to 1.0
  4908. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4909. */
  4910. getDistanceAt(position: number): number;
  4911. /**
  4912. * Returns the array index of the previous point of an interpolated point along this path
  4913. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4914. * @returns the array index
  4915. */
  4916. getPreviousPointIndexAt(position: number): number;
  4917. /**
  4918. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4919. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4920. * @returns the sub position
  4921. */
  4922. getSubPositionAt(position: number): number;
  4923. /**
  4924. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4925. * @param target the vector of which to get the closest position to
  4926. * @returns the position of the closest virtual point on this path to the target vector
  4927. */
  4928. getClosestPositionTo(target: Vector3): number;
  4929. /**
  4930. * Returns a sub path (slice) of this path
  4931. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4932. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4933. * @returns a sub path (slice) of this path
  4934. */
  4935. slice(start?: number, end?: number): Path3D;
  4936. /**
  4937. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4938. * @param path path which all values are copied into the curves points
  4939. * @param firstNormal which should be projected onto the curve
  4940. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4941. * @returns the same object updated.
  4942. */
  4943. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4944. private _compute;
  4945. private _getFirstNonNullVector;
  4946. private _getLastNonNullVector;
  4947. private _normalVector;
  4948. /**
  4949. * Updates the point at data for an interpolated point along this curve
  4950. * @param position the position of the point along this curve, from 0.0 to 1.0
  4951. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4952. * @returns the (updated) point at data
  4953. */
  4954. private _updatePointAtData;
  4955. /**
  4956. * Updates the point at data from the specified parameters
  4957. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4958. * @param point the interpolated point
  4959. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4960. */
  4961. private _setPointAtData;
  4962. /**
  4963. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4964. */
  4965. private _updateInterpolationMatrix;
  4966. }
  4967. /**
  4968. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4969. * A Curve3 is designed from a series of successive Vector3.
  4970. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4971. */
  4972. export class Curve3 {
  4973. private _points;
  4974. private _length;
  4975. /**
  4976. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4978. * @param v1 (Vector3) the control point
  4979. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4980. * @param nbPoints (integer) the wanted number of points in the curve
  4981. * @returns the created Curve3
  4982. */
  4983. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4984. /**
  4985. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4986. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4987. * @param v1 (Vector3) the first control point
  4988. * @param v2 (Vector3) the second control point
  4989. * @param v3 (Vector3) the end point of the Cubic Bezier
  4990. * @param nbPoints (integer) the wanted number of points in the curve
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4994. /**
  4995. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4996. * @param p1 (Vector3) the origin point of the Hermite Spline
  4997. * @param t1 (Vector3) the tangent vector at the origin point
  4998. * @param p2 (Vector3) the end point of the Hermite Spline
  4999. * @param t2 (Vector3) the tangent vector at the end point
  5000. * @param nbPoints (integer) the wanted number of points in the curve
  5001. * @returns the created Curve3
  5002. */
  5003. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5004. /**
  5005. * Returns a Curve3 object along a CatmullRom Spline curve :
  5006. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5007. * @param nbPoints (integer) the wanted number of points between each curve control points
  5008. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5009. * @returns the created Curve3
  5010. */
  5011. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5012. /**
  5013. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5014. * A Curve3 is designed from a series of successive Vector3.
  5015. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5016. * @param points points which make up the curve
  5017. */
  5018. constructor(points: Vector3[]);
  5019. /**
  5020. * @returns the Curve3 stored array of successive Vector3
  5021. */
  5022. getPoints(): Vector3[];
  5023. /**
  5024. * @returns the computed length (float) of the curve.
  5025. */
  5026. length(): number;
  5027. /**
  5028. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5029. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5030. * curveA and curveB keep unchanged.
  5031. * @param curve the curve to continue from this curve
  5032. * @returns the newly constructed curve
  5033. */
  5034. continue(curve: DeepImmutable<Curve3>): Curve3;
  5035. private _computeLength;
  5036. }
  5037. }
  5038. declare module BABYLON {
  5039. /**
  5040. * This represents the main contract an easing function should follow.
  5041. * Easing functions are used throughout the animation system.
  5042. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5043. */
  5044. export interface IEasingFunction {
  5045. /**
  5046. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5047. * of the easing function.
  5048. * The link below provides some of the most common examples of easing functions.
  5049. * @see https://easings.net/
  5050. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5051. * @returns the corresponding value on the curve defined by the easing function
  5052. */
  5053. ease(gradient: number): number;
  5054. }
  5055. /**
  5056. * Base class used for every default easing function.
  5057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5058. */
  5059. export class EasingFunction implements IEasingFunction {
  5060. /**
  5061. * Interpolation follows the mathematical formula associated with the easing function.
  5062. */
  5063. static readonly EASINGMODE_EASEIN: number;
  5064. /**
  5065. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5066. */
  5067. static readonly EASINGMODE_EASEOUT: number;
  5068. /**
  5069. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5070. */
  5071. static readonly EASINGMODE_EASEINOUT: number;
  5072. private _easingMode;
  5073. /**
  5074. * Sets the easing mode of the current function.
  5075. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5076. */
  5077. setEasingMode(easingMode: number): void;
  5078. /**
  5079. * Gets the current easing mode.
  5080. * @returns the easing mode
  5081. */
  5082. getEasingMode(): number;
  5083. /**
  5084. * @hidden
  5085. */
  5086. easeInCore(gradient: number): number;
  5087. /**
  5088. * Given an input gradient between 0 and 1, this returns the corresponding value
  5089. * of the easing function.
  5090. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5091. * @returns the corresponding value on the curve defined by the easing function
  5092. */
  5093. ease(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a circle shape (see link below).
  5097. * @see https://easings.net/#easeInCirc
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class CircleEase extends EasingFunction implements IEasingFunction {
  5101. /** @hidden */
  5102. easeInCore(gradient: number): number;
  5103. }
  5104. /**
  5105. * Easing function with a ease back shape (see link below).
  5106. * @see https://easings.net/#easeInBack
  5107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5108. */
  5109. export class BackEase extends EasingFunction implements IEasingFunction {
  5110. /** Defines the amplitude of the function */
  5111. amplitude: number;
  5112. /**
  5113. * Instantiates a back ease easing
  5114. * @see https://easings.net/#easeInBack
  5115. * @param amplitude Defines the amplitude of the function
  5116. */
  5117. constructor(
  5118. /** Defines the amplitude of the function */
  5119. amplitude?: number);
  5120. /** @hidden */
  5121. easeInCore(gradient: number): number;
  5122. }
  5123. /**
  5124. * Easing function with a bouncing shape (see link below).
  5125. * @see https://easings.net/#easeInBounce
  5126. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5127. */
  5128. export class BounceEase extends EasingFunction implements IEasingFunction {
  5129. /** Defines the number of bounces */
  5130. bounces: number;
  5131. /** Defines the amplitude of the bounce */
  5132. bounciness: number;
  5133. /**
  5134. * Instantiates a bounce easing
  5135. * @see https://easings.net/#easeInBounce
  5136. * @param bounces Defines the number of bounces
  5137. * @param bounciness Defines the amplitude of the bounce
  5138. */
  5139. constructor(
  5140. /** Defines the number of bounces */
  5141. bounces?: number,
  5142. /** Defines the amplitude of the bounce */
  5143. bounciness?: number);
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with a power of 3 shape (see link below).
  5149. * @see https://easings.net/#easeInCubic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class CubicEase extends EasingFunction implements IEasingFunction {
  5153. /** @hidden */
  5154. easeInCore(gradient: number): number;
  5155. }
  5156. /**
  5157. * Easing function with an elastic shape (see link below).
  5158. * @see https://easings.net/#easeInElastic
  5159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5160. */
  5161. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5162. /** Defines the number of oscillations*/
  5163. oscillations: number;
  5164. /** Defines the amplitude of the oscillations*/
  5165. springiness: number;
  5166. /**
  5167. * Instantiates an elastic easing function
  5168. * @see https://easings.net/#easeInElastic
  5169. * @param oscillations Defines the number of oscillations
  5170. * @param springiness Defines the amplitude of the oscillations
  5171. */
  5172. constructor(
  5173. /** Defines the number of oscillations*/
  5174. oscillations?: number,
  5175. /** Defines the amplitude of the oscillations*/
  5176. springiness?: number);
  5177. /** @hidden */
  5178. easeInCore(gradient: number): number;
  5179. }
  5180. /**
  5181. * Easing function with an exponential shape (see link below).
  5182. * @see https://easings.net/#easeInExpo
  5183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5184. */
  5185. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5186. /** Defines the exponent of the function */
  5187. exponent: number;
  5188. /**
  5189. * Instantiates an exponential easing function
  5190. * @see https://easings.net/#easeInExpo
  5191. * @param exponent Defines the exponent of the function
  5192. */
  5193. constructor(
  5194. /** Defines the exponent of the function */
  5195. exponent?: number);
  5196. /** @hidden */
  5197. easeInCore(gradient: number): number;
  5198. }
  5199. /**
  5200. * Easing function with a power shape (see link below).
  5201. * @see https://easings.net/#easeInQuad
  5202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5203. */
  5204. export class PowerEase extends EasingFunction implements IEasingFunction {
  5205. /** Defines the power of the function */
  5206. power: number;
  5207. /**
  5208. * Instantiates an power base easing function
  5209. * @see https://easings.net/#easeInQuad
  5210. * @param power Defines the power of the function
  5211. */
  5212. constructor(
  5213. /** Defines the power of the function */
  5214. power?: number);
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 2 shape (see link below).
  5220. * @see https://easings.net/#easeInQuad
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 4 shape (see link below).
  5229. * @see https://easings.net/#easeInQuart
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a power of 5 shape (see link below).
  5238. * @see https://easings.net/#easeInQuint
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a sin shape (see link below).
  5247. * @see https://easings.net/#easeInSine
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class SineEase extends EasingFunction implements IEasingFunction {
  5251. /** @hidden */
  5252. easeInCore(gradient: number): number;
  5253. }
  5254. /**
  5255. * Easing function with a bezier shape (see link below).
  5256. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5258. */
  5259. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5260. /** Defines the x component of the start tangent in the bezier curve */
  5261. x1: number;
  5262. /** Defines the y component of the start tangent in the bezier curve */
  5263. y1: number;
  5264. /** Defines the x component of the end tangent in the bezier curve */
  5265. x2: number;
  5266. /** Defines the y component of the end tangent in the bezier curve */
  5267. y2: number;
  5268. /**
  5269. * Instantiates a bezier function
  5270. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5271. * @param x1 Defines the x component of the start tangent in the bezier curve
  5272. * @param y1 Defines the y component of the start tangent in the bezier curve
  5273. * @param x2 Defines the x component of the end tangent in the bezier curve
  5274. * @param y2 Defines the y component of the end tangent in the bezier curve
  5275. */
  5276. constructor(
  5277. /** Defines the x component of the start tangent in the bezier curve */
  5278. x1?: number,
  5279. /** Defines the y component of the start tangent in the bezier curve */
  5280. y1?: number,
  5281. /** Defines the x component of the end tangent in the bezier curve */
  5282. x2?: number,
  5283. /** Defines the y component of the end tangent in the bezier curve */
  5284. y2?: number);
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. }
  5289. declare module BABYLON {
  5290. /**
  5291. * Class used to hold a RBG color
  5292. */
  5293. export class Color3 {
  5294. /**
  5295. * Defines the red component (between 0 and 1, default is 0)
  5296. */
  5297. r: number;
  5298. /**
  5299. * Defines the green component (between 0 and 1, default is 0)
  5300. */
  5301. g: number;
  5302. /**
  5303. * Defines the blue component (between 0 and 1, default is 0)
  5304. */
  5305. b: number;
  5306. /**
  5307. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5308. * @param r defines the red component (between 0 and 1, default is 0)
  5309. * @param g defines the green component (between 0 and 1, default is 0)
  5310. * @param b defines the blue component (between 0 and 1, default is 0)
  5311. */
  5312. constructor(
  5313. /**
  5314. * Defines the red component (between 0 and 1, default is 0)
  5315. */
  5316. r?: number,
  5317. /**
  5318. * Defines the green component (between 0 and 1, default is 0)
  5319. */
  5320. g?: number,
  5321. /**
  5322. * Defines the blue component (between 0 and 1, default is 0)
  5323. */
  5324. b?: number);
  5325. /**
  5326. * Creates a string with the Color3 current values
  5327. * @returns the string representation of the Color3 object
  5328. */
  5329. toString(): string;
  5330. /**
  5331. * Returns the string "Color3"
  5332. * @returns "Color3"
  5333. */
  5334. getClassName(): string;
  5335. /**
  5336. * Compute the Color3 hash code
  5337. * @returns an unique number that can be used to hash Color3 objects
  5338. */
  5339. getHashCode(): number;
  5340. /**
  5341. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5342. * @param array defines the array where to store the r,g,b components
  5343. * @param index defines an optional index in the target array to define where to start storing values
  5344. * @returns the current Color3 object
  5345. */
  5346. toArray(array: FloatArray, index?: number): Color3;
  5347. /**
  5348. * Returns a new Color4 object from the current Color3 and the given alpha
  5349. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5350. * @returns a new Color4 object
  5351. */
  5352. toColor4(alpha?: number): Color4;
  5353. /**
  5354. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5355. * @returns the new array
  5356. */
  5357. asArray(): number[];
  5358. /**
  5359. * Returns the luminance value
  5360. * @returns a float value
  5361. */
  5362. toLuminance(): number;
  5363. /**
  5364. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5365. * @param otherColor defines the second operand
  5366. * @returns the new Color3 object
  5367. */
  5368. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5369. /**
  5370. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5371. * @param otherColor defines the second operand
  5372. * @param result defines the Color3 object where to store the result
  5373. * @returns the current Color3
  5374. */
  5375. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5376. /**
  5377. * Determines equality between Color3 objects
  5378. * @param otherColor defines the second operand
  5379. * @returns true if the rgb values are equal to the given ones
  5380. */
  5381. equals(otherColor: DeepImmutable<Color3>): boolean;
  5382. /**
  5383. * Determines equality between the current Color3 object and a set of r,b,g values
  5384. * @param r defines the red component to check
  5385. * @param g defines the green component to check
  5386. * @param b defines the blue component to check
  5387. * @returns true if the rgb values are equal to the given ones
  5388. */
  5389. equalsFloats(r: number, g: number, b: number): boolean;
  5390. /**
  5391. * Multiplies in place each rgb value by scale
  5392. * @param scale defines the scaling factor
  5393. * @returns the updated Color3
  5394. */
  5395. scale(scale: number): Color3;
  5396. /**
  5397. * Multiplies the rgb values by scale and stores the result into "result"
  5398. * @param scale defines the scaling factor
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the unmodified current Color3
  5401. */
  5402. scaleToRef(scale: number, result: Color3): Color3;
  5403. /**
  5404. * Scale the current Color3 values by a factor and add the result to a given Color3
  5405. * @param scale defines the scale factor
  5406. * @param result defines color to store the result into
  5407. * @returns the unmodified current Color3
  5408. */
  5409. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5410. /**
  5411. * Clamps the rgb values by the min and max values and stores the result into "result"
  5412. * @param min defines minimum clamping value (default is 0)
  5413. * @param max defines maximum clamping value (default is 1)
  5414. * @param result defines color to store the result into
  5415. * @returns the original Color3
  5416. */
  5417. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5418. /**
  5419. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5420. * @param otherColor defines the second operand
  5421. * @returns the new Color3
  5422. */
  5423. add(otherColor: DeepImmutable<Color3>): Color3;
  5424. /**
  5425. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5426. * @param otherColor defines the second operand
  5427. * @param result defines Color3 object to store the result into
  5428. * @returns the unmodified current Color3
  5429. */
  5430. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5431. /**
  5432. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5433. * @param otherColor defines the second operand
  5434. * @returns the new Color3
  5435. */
  5436. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5437. /**
  5438. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5439. * @param otherColor defines the second operand
  5440. * @param result defines Color3 object to store the result into
  5441. * @returns the unmodified current Color3
  5442. */
  5443. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5444. /**
  5445. * Copy the current object
  5446. * @returns a new Color3 copied the current one
  5447. */
  5448. clone(): Color3;
  5449. /**
  5450. * Copies the rgb values from the source in the current Color3
  5451. * @param source defines the source Color3 object
  5452. * @returns the updated Color3 object
  5453. */
  5454. copyFrom(source: DeepImmutable<Color3>): Color3;
  5455. /**
  5456. * Updates the Color3 rgb values from the given floats
  5457. * @param r defines the red component to read from
  5458. * @param g defines the green component to read from
  5459. * @param b defines the blue component to read from
  5460. * @returns the current Color3 object
  5461. */
  5462. copyFromFloats(r: number, g: number, b: number): Color3;
  5463. /**
  5464. * Updates the Color3 rgb values from the given floats
  5465. * @param r defines the red component to read from
  5466. * @param g defines the green component to read from
  5467. * @param b defines the blue component to read from
  5468. * @returns the current Color3 object
  5469. */
  5470. set(r: number, g: number, b: number): Color3;
  5471. /**
  5472. * Compute the Color3 hexadecimal code as a string
  5473. * @returns a string containing the hexadecimal representation of the Color3 object
  5474. */
  5475. toHexString(): string;
  5476. /**
  5477. * Computes a new Color3 converted from the current one to linear space
  5478. * @returns a new Color3 object
  5479. */
  5480. toLinearSpace(): Color3;
  5481. /**
  5482. * Converts current color in rgb space to HSV values
  5483. * @returns a new color3 representing the HSV values
  5484. */
  5485. toHSV(): Color3;
  5486. /**
  5487. * Converts current color in rgb space to HSV values
  5488. * @param result defines the Color3 where to store the HSV values
  5489. */
  5490. toHSVToRef(result: Color3): void;
  5491. /**
  5492. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5493. * @param convertedColor defines the Color3 object where to store the linear space version
  5494. * @returns the unmodified Color3
  5495. */
  5496. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5497. /**
  5498. * Computes a new Color3 converted from the current one to gamma space
  5499. * @returns a new Color3 object
  5500. */
  5501. toGammaSpace(): Color3;
  5502. /**
  5503. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5504. * @param convertedColor defines the Color3 object where to store the gamma space version
  5505. * @returns the unmodified Color3
  5506. */
  5507. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5508. private static _BlackReadOnly;
  5509. /**
  5510. * Convert Hue, saturation and value to a Color3 (RGB)
  5511. * @param hue defines the hue
  5512. * @param saturation defines the saturation
  5513. * @param value defines the value
  5514. * @param result defines the Color3 where to store the RGB values
  5515. */
  5516. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5517. /**
  5518. * Creates a new Color3 from the string containing valid hexadecimal values
  5519. * @param hex defines a string containing valid hexadecimal values
  5520. * @returns a new Color3 object
  5521. */
  5522. static FromHexString(hex: string): Color3;
  5523. /**
  5524. * Creates a new Color3 from the starting index of the given array
  5525. * @param array defines the source array
  5526. * @param offset defines an offset in the source array
  5527. * @returns a new Color3 object
  5528. */
  5529. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5530. /**
  5531. * Creates a new Color3 from integer values (< 256)
  5532. * @param r defines the red component to read from (value between 0 and 255)
  5533. * @param g defines the green component to read from (value between 0 and 255)
  5534. * @param b defines the blue component to read from (value between 0 and 255)
  5535. * @returns a new Color3 object
  5536. */
  5537. static FromInts(r: number, g: number, b: number): Color3;
  5538. /**
  5539. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5540. * @param start defines the start Color3 value
  5541. * @param end defines the end Color3 value
  5542. * @param amount defines the gradient value between start and end
  5543. * @returns a new Color3 object
  5544. */
  5545. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5546. /**
  5547. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5548. * @param left defines the start value
  5549. * @param right defines the end value
  5550. * @param amount defines the gradient factor
  5551. * @param result defines the Color3 object where to store the result
  5552. */
  5553. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5554. /**
  5555. * Returns a Color3 value containing a red color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Red(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a green color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Green(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a blue color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Blue(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a black color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Black(): Color3;
  5574. /**
  5575. * Gets a Color3 value containing a black color that must not be updated
  5576. */
  5577. static get BlackReadOnly(): DeepImmutable<Color3>;
  5578. /**
  5579. * Returns a Color3 value containing a white color
  5580. * @returns a new Color3 object
  5581. */
  5582. static White(): Color3;
  5583. /**
  5584. * Returns a Color3 value containing a purple color
  5585. * @returns a new Color3 object
  5586. */
  5587. static Purple(): Color3;
  5588. /**
  5589. * Returns a Color3 value containing a magenta color
  5590. * @returns a new Color3 object
  5591. */
  5592. static Magenta(): Color3;
  5593. /**
  5594. * Returns a Color3 value containing a yellow color
  5595. * @returns a new Color3 object
  5596. */
  5597. static Yellow(): Color3;
  5598. /**
  5599. * Returns a Color3 value containing a gray color
  5600. * @returns a new Color3 object
  5601. */
  5602. static Gray(): Color3;
  5603. /**
  5604. * Returns a Color3 value containing a teal color
  5605. * @returns a new Color3 object
  5606. */
  5607. static Teal(): Color3;
  5608. /**
  5609. * Returns a Color3 value containing a random color
  5610. * @returns a new Color3 object
  5611. */
  5612. static Random(): Color3;
  5613. }
  5614. /**
  5615. * Class used to hold a RBGA color
  5616. */
  5617. export class Color4 {
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r: number;
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g: number;
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b: number;
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a: number;
  5634. /**
  5635. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5636. * @param r defines the red component (between 0 and 1, default is 0)
  5637. * @param g defines the green component (between 0 and 1, default is 0)
  5638. * @param b defines the blue component (between 0 and 1, default is 0)
  5639. * @param a defines the alpha component (between 0 and 1, default is 1)
  5640. */
  5641. constructor(
  5642. /**
  5643. * Defines the red component (between 0 and 1, default is 0)
  5644. */
  5645. r?: number,
  5646. /**
  5647. * Defines the green component (between 0 and 1, default is 0)
  5648. */
  5649. g?: number,
  5650. /**
  5651. * Defines the blue component (between 0 and 1, default is 0)
  5652. */
  5653. b?: number,
  5654. /**
  5655. * Defines the alpha component (between 0 and 1, default is 1)
  5656. */
  5657. a?: number);
  5658. /**
  5659. * Adds in place the given Color4 values to the current Color4 object
  5660. * @param right defines the second operand
  5661. * @returns the current updated Color4 object
  5662. */
  5663. addInPlace(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5666. * @returns the new array
  5667. */
  5668. asArray(): number[];
  5669. /**
  5670. * Stores from the starting index in the given array the Color4 successive values
  5671. * @param array defines the array where to store the r,g,b components
  5672. * @param index defines an optional index in the target array to define where to start storing values
  5673. * @returns the current Color4 object
  5674. */
  5675. toArray(array: number[], index?: number): Color4;
  5676. /**
  5677. * Determines equality between Color4 objects
  5678. * @param otherColor defines the second operand
  5679. * @returns true if the rgba values are equal to the given ones
  5680. */
  5681. equals(otherColor: DeepImmutable<Color4>): boolean;
  5682. /**
  5683. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5684. * @param right defines the second operand
  5685. * @returns a new Color4 object
  5686. */
  5687. add(right: DeepImmutable<Color4>): Color4;
  5688. /**
  5689. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5690. * @param right defines the second operand
  5691. * @returns a new Color4 object
  5692. */
  5693. subtract(right: DeepImmutable<Color4>): Color4;
  5694. /**
  5695. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5696. * @param right defines the second operand
  5697. * @param result defines the Color4 object where to store the result
  5698. * @returns the current Color4 object
  5699. */
  5700. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5701. /**
  5702. * Creates a new Color4 with the current Color4 values multiplied by scale
  5703. * @param scale defines the scaling factor to apply
  5704. * @returns a new Color4 object
  5705. */
  5706. scale(scale: number): Color4;
  5707. /**
  5708. * Multiplies the current Color4 values by scale and stores the result in "result"
  5709. * @param scale defines the scaling factor to apply
  5710. * @param result defines the Color4 object where to store the result
  5711. * @returns the current unmodified Color4
  5712. */
  5713. scaleToRef(scale: number, result: Color4): Color4;
  5714. /**
  5715. * Scale the current Color4 values by a factor and add the result to a given Color4
  5716. * @param scale defines the scale factor
  5717. * @param result defines the Color4 object where to store the result
  5718. * @returns the unmodified current Color4
  5719. */
  5720. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5721. /**
  5722. * Clamps the rgb values by the min and max values and stores the result into "result"
  5723. * @param min defines minimum clamping value (default is 0)
  5724. * @param max defines maximum clamping value (default is 1)
  5725. * @param result defines color to store the result into.
  5726. * @returns the cuurent Color4
  5727. */
  5728. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5729. /**
  5730. * Multipy an Color4 value by another and return a new Color4 object
  5731. * @param color defines the Color4 value to multiply by
  5732. * @returns a new Color4 object
  5733. */
  5734. multiply(color: Color4): Color4;
  5735. /**
  5736. * Multipy a Color4 value by another and push the result in a reference value
  5737. * @param color defines the Color4 value to multiply by
  5738. * @param result defines the Color4 to fill the result in
  5739. * @returns the result Color4
  5740. */
  5741. multiplyToRef(color: Color4, result: Color4): Color4;
  5742. /**
  5743. * Creates a string with the Color4 current values
  5744. * @returns the string representation of the Color4 object
  5745. */
  5746. toString(): string;
  5747. /**
  5748. * Returns the string "Color4"
  5749. * @returns "Color4"
  5750. */
  5751. getClassName(): string;
  5752. /**
  5753. * Compute the Color4 hash code
  5754. * @returns an unique number that can be used to hash Color4 objects
  5755. */
  5756. getHashCode(): number;
  5757. /**
  5758. * Creates a new Color4 copied from the current one
  5759. * @returns a new Color4 object
  5760. */
  5761. clone(): Color4;
  5762. /**
  5763. * Copies the given Color4 values into the current one
  5764. * @param source defines the source Color4 object
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFrom(source: Color4): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Copies the given float values into the current one
  5779. * @param r defines the red component to read from
  5780. * @param g defines the green component to read from
  5781. * @param b defines the blue component to read from
  5782. * @param a defines the alpha component to read from
  5783. * @returns the current updated Color4 object
  5784. */
  5785. set(r: number, g: number, b: number, a: number): Color4;
  5786. /**
  5787. * Compute the Color4 hexadecimal code as a string
  5788. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5789. * @returns a string containing the hexadecimal representation of the Color4 object
  5790. */
  5791. toHexString(returnAsColor3?: boolean): string;
  5792. /**
  5793. * Computes a new Color4 converted from the current one to linear space
  5794. * @returns a new Color4 object
  5795. */
  5796. toLinearSpace(): Color4;
  5797. /**
  5798. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5799. * @param convertedColor defines the Color4 object where to store the linear space version
  5800. * @returns the unmodified Color4
  5801. */
  5802. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5803. /**
  5804. * Computes a new Color4 converted from the current one to gamma space
  5805. * @returns a new Color4 object
  5806. */
  5807. toGammaSpace(): Color4;
  5808. /**
  5809. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5810. * @param convertedColor defines the Color4 object where to store the gamma space version
  5811. * @returns the unmodified Color4
  5812. */
  5813. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5814. /**
  5815. * Creates a new Color4 from the string containing valid hexadecimal values
  5816. * @param hex defines a string containing valid hexadecimal values
  5817. * @returns a new Color4 object
  5818. */
  5819. static FromHexString(hex: string): Color4;
  5820. /**
  5821. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5822. * @param left defines the start value
  5823. * @param right defines the end value
  5824. * @param amount defines the gradient factor
  5825. * @returns a new Color4 object
  5826. */
  5827. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5828. /**
  5829. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5830. * @param left defines the start value
  5831. * @param right defines the end value
  5832. * @param amount defines the gradient factor
  5833. * @param result defines the Color4 object where to store data
  5834. */
  5835. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5836. /**
  5837. * Creates a new Color4 from a Color3 and an alpha value
  5838. * @param color3 defines the source Color3 to read from
  5839. * @param alpha defines the alpha component (1.0 by default)
  5840. * @returns a new Color4 object
  5841. */
  5842. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5843. /**
  5844. * Creates a new Color4 from the starting index element of the given array
  5845. * @param array defines the source array to read from
  5846. * @param offset defines the offset in the source array
  5847. * @returns a new Color4 object
  5848. */
  5849. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5850. /**
  5851. * Creates a new Color3 from integer values (< 256)
  5852. * @param r defines the red component to read from (value between 0 and 255)
  5853. * @param g defines the green component to read from (value between 0 and 255)
  5854. * @param b defines the blue component to read from (value between 0 and 255)
  5855. * @param a defines the alpha component to read from (value between 0 and 255)
  5856. * @returns a new Color3 object
  5857. */
  5858. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5859. /**
  5860. * Check the content of a given array and convert it to an array containing RGBA data
  5861. * If the original array was already containing count * 4 values then it is returned directly
  5862. * @param colors defines the array to check
  5863. * @param count defines the number of RGBA data to expect
  5864. * @returns an array containing count * 4 values (RGBA)
  5865. */
  5866. static CheckColors4(colors: number[], count: number): number[];
  5867. }
  5868. /**
  5869. * @hidden
  5870. */
  5871. export class TmpColors {
  5872. static Color3: Color3[];
  5873. static Color4: Color4[];
  5874. }
  5875. }
  5876. declare module BABYLON {
  5877. /**
  5878. * Defines an interface which represents an animation key frame
  5879. */
  5880. export interface IAnimationKey {
  5881. /**
  5882. * Frame of the key frame
  5883. */
  5884. frame: number;
  5885. /**
  5886. * Value at the specifies key frame
  5887. */
  5888. value: any;
  5889. /**
  5890. * The input tangent for the cubic hermite spline
  5891. */
  5892. inTangent?: any;
  5893. /**
  5894. * The output tangent for the cubic hermite spline
  5895. */
  5896. outTangent?: any;
  5897. /**
  5898. * The animation interpolation type
  5899. */
  5900. interpolation?: AnimationKeyInterpolation;
  5901. }
  5902. /**
  5903. * Enum for the animation key frame interpolation type
  5904. */
  5905. export enum AnimationKeyInterpolation {
  5906. /**
  5907. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5908. */
  5909. STEP = 1
  5910. }
  5911. }
  5912. declare module BABYLON {
  5913. /**
  5914. * Represents the range of an animation
  5915. */
  5916. export class AnimationRange {
  5917. /**The name of the animation range**/
  5918. name: string;
  5919. /**The starting frame of the animation */
  5920. from: number;
  5921. /**The ending frame of the animation*/
  5922. to: number;
  5923. /**
  5924. * Initializes the range of an animation
  5925. * @param name The name of the animation range
  5926. * @param from The starting frame of the animation
  5927. * @param to The ending frame of the animation
  5928. */
  5929. constructor(
  5930. /**The name of the animation range**/
  5931. name: string,
  5932. /**The starting frame of the animation */
  5933. from: number,
  5934. /**The ending frame of the animation*/
  5935. to: number);
  5936. /**
  5937. * Makes a copy of the animation range
  5938. * @returns A copy of the animation range
  5939. */
  5940. clone(): AnimationRange;
  5941. }
  5942. }
  5943. declare module BABYLON {
  5944. /**
  5945. * Composed of a frame, and an action function
  5946. */
  5947. export class AnimationEvent {
  5948. /** The frame for which the event is triggered **/
  5949. frame: number;
  5950. /** The event to perform when triggered **/
  5951. action: (currentFrame: number) => void;
  5952. /** Specifies if the event should be triggered only once**/
  5953. onlyOnce?: boolean | undefined;
  5954. /**
  5955. * Specifies if the animation event is done
  5956. */
  5957. isDone: boolean;
  5958. /**
  5959. * Initializes the animation event
  5960. * @param frame The frame for which the event is triggered
  5961. * @param action The event to perform when triggered
  5962. * @param onlyOnce Specifies if the event should be triggered only once
  5963. */
  5964. constructor(
  5965. /** The frame for which the event is triggered **/
  5966. frame: number,
  5967. /** The event to perform when triggered **/
  5968. action: (currentFrame: number) => void,
  5969. /** Specifies if the event should be triggered only once**/
  5970. onlyOnce?: boolean | undefined);
  5971. /** @hidden */
  5972. _clone(): AnimationEvent;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * Interface used to define a behavior
  5978. */
  5979. export interface Behavior<T> {
  5980. /** gets or sets behavior's name */
  5981. name: string;
  5982. /**
  5983. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5984. */
  5985. init(): void;
  5986. /**
  5987. * Called when the behavior is attached to a target
  5988. * @param target defines the target where the behavior is attached to
  5989. */
  5990. attach(target: T): void;
  5991. /**
  5992. * Called when the behavior is detached from its target
  5993. */
  5994. detach(): void;
  5995. }
  5996. /**
  5997. * Interface implemented by classes supporting behaviors
  5998. */
  5999. export interface IBehaviorAware<T> {
  6000. /**
  6001. * Attach a behavior
  6002. * @param behavior defines the behavior to attach
  6003. * @returns the current host
  6004. */
  6005. addBehavior(behavior: Behavior<T>): T;
  6006. /**
  6007. * Remove a behavior from the current object
  6008. * @param behavior defines the behavior to detach
  6009. * @returns the current host
  6010. */
  6011. removeBehavior(behavior: Behavior<T>): T;
  6012. /**
  6013. * Gets a behavior using its name to search
  6014. * @param name defines the name to search
  6015. * @returns the behavior or null if not found
  6016. */
  6017. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6018. }
  6019. }
  6020. declare module BABYLON {
  6021. /**
  6022. * Defines an array and its length.
  6023. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6024. */
  6025. export interface ISmartArrayLike<T> {
  6026. /**
  6027. * The data of the array.
  6028. */
  6029. data: Array<T>;
  6030. /**
  6031. * The active length of the array.
  6032. */
  6033. length: number;
  6034. }
  6035. /**
  6036. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6037. */
  6038. export class SmartArray<T> implements ISmartArrayLike<T> {
  6039. /**
  6040. * The full set of data from the array.
  6041. */
  6042. data: Array<T>;
  6043. /**
  6044. * The active length of the array.
  6045. */
  6046. length: number;
  6047. protected _id: number;
  6048. /**
  6049. * Instantiates a Smart Array.
  6050. * @param capacity defines the default capacity of the array.
  6051. */
  6052. constructor(capacity: number);
  6053. /**
  6054. * Pushes a value at the end of the active data.
  6055. * @param value defines the object to push in the array.
  6056. */
  6057. push(value: T): void;
  6058. /**
  6059. * Iterates over the active data and apply the lambda to them.
  6060. * @param func defines the action to apply on each value.
  6061. */
  6062. forEach(func: (content: T) => void): void;
  6063. /**
  6064. * Sorts the full sets of data.
  6065. * @param compareFn defines the comparison function to apply.
  6066. */
  6067. sort(compareFn: (a: T, b: T) => number): void;
  6068. /**
  6069. * Resets the active data to an empty array.
  6070. */
  6071. reset(): void;
  6072. /**
  6073. * Releases all the data from the array as well as the array.
  6074. */
  6075. dispose(): void;
  6076. /**
  6077. * Concats the active data with a given array.
  6078. * @param array defines the data to concatenate with.
  6079. */
  6080. concat(array: any): void;
  6081. /**
  6082. * Returns the position of a value in the active data.
  6083. * @param value defines the value to find the index for
  6084. * @returns the index if found in the active data otherwise -1
  6085. */
  6086. indexOf(value: T): number;
  6087. /**
  6088. * Returns whether an element is part of the active data.
  6089. * @param value defines the value to look for
  6090. * @returns true if found in the active data otherwise false
  6091. */
  6092. contains(value: T): boolean;
  6093. private static _GlobalId;
  6094. }
  6095. /**
  6096. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6097. * The data in this array can only be present once
  6098. */
  6099. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6100. private _duplicateId;
  6101. /**
  6102. * Pushes a value at the end of the active data.
  6103. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6104. * @param value defines the object to push in the array.
  6105. */
  6106. push(value: T): void;
  6107. /**
  6108. * Pushes a value at the end of the active data.
  6109. * If the data is already present, it won t be added again
  6110. * @param value defines the object to push in the array.
  6111. * @returns true if added false if it was already present
  6112. */
  6113. pushNoDuplicate(value: T): boolean;
  6114. /**
  6115. * Resets the active data to an empty array.
  6116. */
  6117. reset(): void;
  6118. /**
  6119. * Concats the active data with a given array.
  6120. * This ensures no dupplicate will be present in the result.
  6121. * @param array defines the data to concatenate with.
  6122. */
  6123. concatWithNoDuplicate(array: any): void;
  6124. }
  6125. }
  6126. declare module BABYLON {
  6127. /**
  6128. * @ignore
  6129. * This is a list of all the different input types that are available in the application.
  6130. * Fo instance: ArcRotateCameraGamepadInput...
  6131. */
  6132. export var CameraInputTypes: {};
  6133. /**
  6134. * This is the contract to implement in order to create a new input class.
  6135. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6136. */
  6137. export interface ICameraInput<TCamera extends Camera> {
  6138. /**
  6139. * Defines the camera the input is attached to.
  6140. */
  6141. camera: Nullable<TCamera>;
  6142. /**
  6143. * Gets the class name of the current intput.
  6144. * @returns the class name
  6145. */
  6146. getClassName(): string;
  6147. /**
  6148. * Get the friendly name associated with the input class.
  6149. * @returns the input friendly name
  6150. */
  6151. getSimpleName(): string;
  6152. /**
  6153. * Attach the input controls to a specific dom element to get the input from.
  6154. * @param element Defines the element the controls should be listened from
  6155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6156. */
  6157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6158. /**
  6159. * Detach the current controls from the specified dom element.
  6160. * @param element Defines the element to stop listening the inputs from
  6161. */
  6162. detachControl(element: Nullable<HTMLElement>): void;
  6163. /**
  6164. * Update the current camera state depending on the inputs that have been used this frame.
  6165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6166. */
  6167. checkInputs?: () => void;
  6168. }
  6169. /**
  6170. * Represents a map of input types to input instance or input index to input instance.
  6171. */
  6172. export interface CameraInputsMap<TCamera extends Camera> {
  6173. /**
  6174. * Accessor to the input by input type.
  6175. */
  6176. [name: string]: ICameraInput<TCamera>;
  6177. /**
  6178. * Accessor to the input by input index.
  6179. */
  6180. [idx: number]: ICameraInput<TCamera>;
  6181. }
  6182. /**
  6183. * This represents the input manager used within a camera.
  6184. * It helps dealing with all the different kind of input attached to a camera.
  6185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6186. */
  6187. export class CameraInputsManager<TCamera extends Camera> {
  6188. /**
  6189. * Defines the list of inputs attahed to the camera.
  6190. */
  6191. attached: CameraInputsMap<TCamera>;
  6192. /**
  6193. * Defines the dom element the camera is collecting inputs from.
  6194. * This is null if the controls have not been attached.
  6195. */
  6196. attachedElement: Nullable<HTMLElement>;
  6197. /**
  6198. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6199. */
  6200. noPreventDefault: boolean;
  6201. /**
  6202. * Defined the camera the input manager belongs to.
  6203. */
  6204. camera: TCamera;
  6205. /**
  6206. * Update the current camera state depending on the inputs that have been used this frame.
  6207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6208. */
  6209. checkInputs: () => void;
  6210. /**
  6211. * Instantiate a new Camera Input Manager.
  6212. * @param camera Defines the camera the input manager blongs to
  6213. */
  6214. constructor(camera: TCamera);
  6215. /**
  6216. * Add an input method to a camera
  6217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6218. * @param input camera input method
  6219. */
  6220. add(input: ICameraInput<TCamera>): void;
  6221. /**
  6222. * Remove a specific input method from a camera
  6223. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6224. * @param inputToRemove camera input method
  6225. */
  6226. remove(inputToRemove: ICameraInput<TCamera>): void;
  6227. /**
  6228. * Remove a specific input type from a camera
  6229. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6230. * @param inputType the type of the input to remove
  6231. */
  6232. removeByType(inputType: string): void;
  6233. private _addCheckInputs;
  6234. /**
  6235. * Attach the input controls to the currently attached dom element to listen the events from.
  6236. * @param input Defines the input to attach
  6237. */
  6238. attachInput(input: ICameraInput<TCamera>): void;
  6239. /**
  6240. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6241. * @param element Defines the dom element to collect the events from
  6242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6243. */
  6244. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6245. /**
  6246. * Detach the current manager inputs controls from a specific dom element.
  6247. * @param element Defines the dom element to collect the events from
  6248. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6249. */
  6250. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6251. /**
  6252. * Rebuild the dynamic inputCheck function from the current list of
  6253. * defined inputs in the manager.
  6254. */
  6255. rebuildInputCheck(): void;
  6256. /**
  6257. * Remove all attached input methods from a camera
  6258. */
  6259. clear(): void;
  6260. /**
  6261. * Serialize the current input manager attached to a camera.
  6262. * This ensures than once parsed,
  6263. * the input associated to the camera will be identical to the current ones
  6264. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6265. */
  6266. serialize(serializedCamera: any): void;
  6267. /**
  6268. * Parses an input manager serialized JSON to restore the previous list of inputs
  6269. * and states associated to a camera.
  6270. * @param parsedCamera Defines the JSON to parse
  6271. */
  6272. parse(parsedCamera: any): void;
  6273. }
  6274. }
  6275. declare module BABYLON {
  6276. /**
  6277. * Class used to store data that will be store in GPU memory
  6278. */
  6279. export class Buffer {
  6280. private _engine;
  6281. private _buffer;
  6282. /** @hidden */
  6283. _data: Nullable<DataArray>;
  6284. private _updatable;
  6285. private _instanced;
  6286. private _divisor;
  6287. /**
  6288. * Gets the byte stride.
  6289. */
  6290. readonly byteStride: number;
  6291. /**
  6292. * Constructor
  6293. * @param engine the engine
  6294. * @param data the data to use for this buffer
  6295. * @param updatable whether the data is updatable
  6296. * @param stride the stride (optional)
  6297. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6298. * @param instanced whether the buffer is instanced (optional)
  6299. * @param useBytes set to true if the stride in in bytes (optional)
  6300. * @param divisor sets an optional divisor for instances (1 by default)
  6301. */
  6302. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6303. /**
  6304. * Create a new VertexBuffer based on the current buffer
  6305. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6306. * @param offset defines offset in the buffer (0 by default)
  6307. * @param size defines the size in floats of attributes (position is 3 for instance)
  6308. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6309. * @param instanced defines if the vertex buffer contains indexed data
  6310. * @param useBytes defines if the offset and stride are in bytes *
  6311. * @param divisor sets an optional divisor for instances (1 by default)
  6312. * @returns the new vertex buffer
  6313. */
  6314. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6315. /**
  6316. * Gets a boolean indicating if the Buffer is updatable?
  6317. * @returns true if the buffer is updatable
  6318. */
  6319. isUpdatable(): boolean;
  6320. /**
  6321. * Gets current buffer's data
  6322. * @returns a DataArray or null
  6323. */
  6324. getData(): Nullable<DataArray>;
  6325. /**
  6326. * Gets underlying native buffer
  6327. * @returns underlying native buffer
  6328. */
  6329. getBuffer(): Nullable<DataBuffer>;
  6330. /**
  6331. * Gets the stride in float32 units (i.e. byte stride / 4).
  6332. * May not be an integer if the byte stride is not divisible by 4.
  6333. * @returns the stride in float32 units
  6334. * @deprecated Please use byteStride instead.
  6335. */
  6336. getStrideSize(): number;
  6337. /**
  6338. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6339. * @param data defines the data to store
  6340. */
  6341. create(data?: Nullable<DataArray>): void;
  6342. /** @hidden */
  6343. _rebuild(): void;
  6344. /**
  6345. * Update current buffer data
  6346. * @param data defines the data to store
  6347. */
  6348. update(data: DataArray): void;
  6349. /**
  6350. * Updates the data directly.
  6351. * @param data the new data
  6352. * @param offset the new offset
  6353. * @param vertexCount the vertex count (optional)
  6354. * @param useBytes set to true if the offset is in bytes
  6355. */
  6356. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6357. /**
  6358. * Release all resources
  6359. */
  6360. dispose(): void;
  6361. }
  6362. /**
  6363. * Specialized buffer used to store vertex data
  6364. */
  6365. export class VertexBuffer {
  6366. /** @hidden */
  6367. _buffer: Buffer;
  6368. private _kind;
  6369. private _size;
  6370. private _ownsBuffer;
  6371. private _instanced;
  6372. private _instanceDivisor;
  6373. /**
  6374. * The byte type.
  6375. */
  6376. static readonly BYTE: number;
  6377. /**
  6378. * The unsigned byte type.
  6379. */
  6380. static readonly UNSIGNED_BYTE: number;
  6381. /**
  6382. * The short type.
  6383. */
  6384. static readonly SHORT: number;
  6385. /**
  6386. * The unsigned short type.
  6387. */
  6388. static readonly UNSIGNED_SHORT: number;
  6389. /**
  6390. * The integer type.
  6391. */
  6392. static readonly INT: number;
  6393. /**
  6394. * The unsigned integer type.
  6395. */
  6396. static readonly UNSIGNED_INT: number;
  6397. /**
  6398. * The float type.
  6399. */
  6400. static readonly FLOAT: number;
  6401. /**
  6402. * Gets or sets the instance divisor when in instanced mode
  6403. */
  6404. get instanceDivisor(): number;
  6405. set instanceDivisor(value: number);
  6406. /**
  6407. * Gets the byte stride.
  6408. */
  6409. readonly byteStride: number;
  6410. /**
  6411. * Gets the byte offset.
  6412. */
  6413. readonly byteOffset: number;
  6414. /**
  6415. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6416. */
  6417. readonly normalized: boolean;
  6418. /**
  6419. * Gets the data type of each component in the array.
  6420. */
  6421. readonly type: number;
  6422. /**
  6423. * Constructor
  6424. * @param engine the engine
  6425. * @param data the data to use for this vertex buffer
  6426. * @param kind the vertex buffer kind
  6427. * @param updatable whether the data is updatable
  6428. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6429. * @param stride the stride (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param offset the offset of the data (optional)
  6432. * @param size the number of components (optional)
  6433. * @param type the type of the component (optional)
  6434. * @param normalized whether the data contains normalized data (optional)
  6435. * @param useBytes set to true if stride and offset are in bytes (optional)
  6436. * @param divisor defines the instance divisor to use (1 by default)
  6437. */
  6438. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6439. /** @hidden */
  6440. _rebuild(): void;
  6441. /**
  6442. * Returns the kind of the VertexBuffer (string)
  6443. * @returns a string
  6444. */
  6445. getKind(): string;
  6446. /**
  6447. * Gets a boolean indicating if the VertexBuffer is updatable?
  6448. * @returns true if the buffer is updatable
  6449. */
  6450. isUpdatable(): boolean;
  6451. /**
  6452. * Gets current buffer's data
  6453. * @returns a DataArray or null
  6454. */
  6455. getData(): Nullable<DataArray>;
  6456. /**
  6457. * Gets underlying native buffer
  6458. * @returns underlying native buffer
  6459. */
  6460. getBuffer(): Nullable<DataBuffer>;
  6461. /**
  6462. * Gets the stride in float32 units (i.e. byte stride / 4).
  6463. * May not be an integer if the byte stride is not divisible by 4.
  6464. * @returns the stride in float32 units
  6465. * @deprecated Please use byteStride instead.
  6466. */
  6467. getStrideSize(): number;
  6468. /**
  6469. * Returns the offset as a multiple of the type byte length.
  6470. * @returns the offset in bytes
  6471. * @deprecated Please use byteOffset instead.
  6472. */
  6473. getOffset(): number;
  6474. /**
  6475. * Returns the number of components per vertex attribute (integer)
  6476. * @returns the size in float
  6477. */
  6478. getSize(): number;
  6479. /**
  6480. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6481. * @returns true if this buffer is instanced
  6482. */
  6483. getIsInstanced(): boolean;
  6484. /**
  6485. * Returns the instancing divisor, zero for non-instanced (integer).
  6486. * @returns a number
  6487. */
  6488. getInstanceDivisor(): number;
  6489. /**
  6490. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6491. * @param data defines the data to store
  6492. */
  6493. create(data?: DataArray): void;
  6494. /**
  6495. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6496. * This function will create a new buffer if the current one is not updatable
  6497. * @param data defines the data to store
  6498. */
  6499. update(data: DataArray): void;
  6500. /**
  6501. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6502. * Returns the directly updated WebGLBuffer.
  6503. * @param data the new data
  6504. * @param offset the new offset
  6505. * @param useBytes set to true if the offset is in bytes
  6506. */
  6507. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6508. /**
  6509. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6510. */
  6511. dispose(): void;
  6512. /**
  6513. * Enumerates each value of this vertex buffer as numbers.
  6514. * @param count the number of values to enumerate
  6515. * @param callback the callback function called for each value
  6516. */
  6517. forEach(count: number, callback: (value: number, index: number) => void): void;
  6518. /**
  6519. * Positions
  6520. */
  6521. static readonly PositionKind: string;
  6522. /**
  6523. * Normals
  6524. */
  6525. static readonly NormalKind: string;
  6526. /**
  6527. * Tangents
  6528. */
  6529. static readonly TangentKind: string;
  6530. /**
  6531. * Texture coordinates
  6532. */
  6533. static readonly UVKind: string;
  6534. /**
  6535. * Texture coordinates 2
  6536. */
  6537. static readonly UV2Kind: string;
  6538. /**
  6539. * Texture coordinates 3
  6540. */
  6541. static readonly UV3Kind: string;
  6542. /**
  6543. * Texture coordinates 4
  6544. */
  6545. static readonly UV4Kind: string;
  6546. /**
  6547. * Texture coordinates 5
  6548. */
  6549. static readonly UV5Kind: string;
  6550. /**
  6551. * Texture coordinates 6
  6552. */
  6553. static readonly UV6Kind: string;
  6554. /**
  6555. * Colors
  6556. */
  6557. static readonly ColorKind: string;
  6558. /**
  6559. * Matrix indices (for bones)
  6560. */
  6561. static readonly MatricesIndicesKind: string;
  6562. /**
  6563. * Matrix weights (for bones)
  6564. */
  6565. static readonly MatricesWeightsKind: string;
  6566. /**
  6567. * Additional matrix indices (for bones)
  6568. */
  6569. static readonly MatricesIndicesExtraKind: string;
  6570. /**
  6571. * Additional matrix weights (for bones)
  6572. */
  6573. static readonly MatricesWeightsExtraKind: string;
  6574. /**
  6575. * Deduces the stride given a kind.
  6576. * @param kind The kind string to deduce
  6577. * @returns The deduced stride
  6578. */
  6579. static DeduceStride(kind: string): number;
  6580. /**
  6581. * Gets the byte length of the given type.
  6582. * @param type the type
  6583. * @returns the number of bytes
  6584. */
  6585. static GetTypeByteLength(type: number): number;
  6586. /**
  6587. * Enumerates each value of the given parameters as numbers.
  6588. * @param data the data to enumerate
  6589. * @param byteOffset the byte offset of the data
  6590. * @param byteStride the byte stride of the data
  6591. * @param componentCount the number of components per element
  6592. * @param componentType the type of the component
  6593. * @param count the number of values to enumerate
  6594. * @param normalized whether the data is normalized
  6595. * @param callback the callback function called for each value
  6596. */
  6597. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6598. private static _GetFloatValue;
  6599. }
  6600. }
  6601. declare module BABYLON {
  6602. /**
  6603. * @hidden
  6604. */
  6605. export class IntersectionInfo {
  6606. bu: Nullable<number>;
  6607. bv: Nullable<number>;
  6608. distance: number;
  6609. faceId: number;
  6610. subMeshId: number;
  6611. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6612. }
  6613. }
  6614. declare module BABYLON {
  6615. /**
  6616. * Represens a plane by the equation ax + by + cz + d = 0
  6617. */
  6618. export class Plane {
  6619. private static _TmpMatrix;
  6620. /**
  6621. * Normal of the plane (a,b,c)
  6622. */
  6623. normal: Vector3;
  6624. /**
  6625. * d component of the plane
  6626. */
  6627. d: number;
  6628. /**
  6629. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6630. * @param a a component of the plane
  6631. * @param b b component of the plane
  6632. * @param c c component of the plane
  6633. * @param d d component of the plane
  6634. */
  6635. constructor(a: number, b: number, c: number, d: number);
  6636. /**
  6637. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6638. */
  6639. asArray(): number[];
  6640. /**
  6641. * @returns a new plane copied from the current Plane.
  6642. */
  6643. clone(): Plane;
  6644. /**
  6645. * @returns the string "Plane".
  6646. */
  6647. getClassName(): string;
  6648. /**
  6649. * @returns the Plane hash code.
  6650. */
  6651. getHashCode(): number;
  6652. /**
  6653. * Normalize the current Plane in place.
  6654. * @returns the updated Plane.
  6655. */
  6656. normalize(): Plane;
  6657. /**
  6658. * Applies a transformation the plane and returns the result
  6659. * @param transformation the transformation matrix to be applied to the plane
  6660. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6661. */
  6662. transform(transformation: DeepImmutable<Matrix>): Plane;
  6663. /**
  6664. * Calcualtte the dot product between the point and the plane normal
  6665. * @param point point to calculate the dot product with
  6666. * @returns the dot product (float) of the point coordinates and the plane normal.
  6667. */
  6668. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6669. /**
  6670. * Updates the current Plane from the plane defined by the three given points.
  6671. * @param point1 one of the points used to contruct the plane
  6672. * @param point2 one of the points used to contruct the plane
  6673. * @param point3 one of the points used to contruct the plane
  6674. * @returns the updated Plane.
  6675. */
  6676. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6677. /**
  6678. * Checks if the plane is facing a given direction
  6679. * @param direction the direction to check if the plane is facing
  6680. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6681. * @returns True is the vector "direction" is the same side than the plane normal.
  6682. */
  6683. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6684. /**
  6685. * Calculates the distance to a point
  6686. * @param point point to calculate distance to
  6687. * @returns the signed distance (float) from the given point to the Plane.
  6688. */
  6689. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6690. /**
  6691. * Creates a plane from an array
  6692. * @param array the array to create a plane from
  6693. * @returns a new Plane from the given array.
  6694. */
  6695. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6696. /**
  6697. * Creates a plane from three points
  6698. * @param point1 point used to create the plane
  6699. * @param point2 point used to create the plane
  6700. * @param point3 point used to create the plane
  6701. * @returns a new Plane defined by the three given points.
  6702. */
  6703. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6704. /**
  6705. * Creates a plane from an origin point and a normal
  6706. * @param origin origin of the plane to be constructed
  6707. * @param normal normal of the plane to be constructed
  6708. * @returns a new Plane the normal vector to this plane at the given origin point.
  6709. * Note : the vector "normal" is updated because normalized.
  6710. */
  6711. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6712. /**
  6713. * Calculates the distance from a plane and a point
  6714. * @param origin origin of the plane to be constructed
  6715. * @param normal normal of the plane to be constructed
  6716. * @param point point to calculate distance to
  6717. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6718. */
  6719. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6720. }
  6721. }
  6722. declare module BABYLON {
  6723. /**
  6724. * Class used to store bounding sphere information
  6725. */
  6726. export class BoundingSphere {
  6727. /**
  6728. * Gets the center of the bounding sphere in local space
  6729. */
  6730. readonly center: Vector3;
  6731. /**
  6732. * Radius of the bounding sphere in local space
  6733. */
  6734. radius: number;
  6735. /**
  6736. * Gets the center of the bounding sphere in world space
  6737. */
  6738. readonly centerWorld: Vector3;
  6739. /**
  6740. * Radius of the bounding sphere in world space
  6741. */
  6742. radiusWorld: number;
  6743. /**
  6744. * Gets the minimum vector in local space
  6745. */
  6746. readonly minimum: Vector3;
  6747. /**
  6748. * Gets the maximum vector in local space
  6749. */
  6750. readonly maximum: Vector3;
  6751. private _worldMatrix;
  6752. private static readonly TmpVector3;
  6753. /**
  6754. * Creates a new bounding sphere
  6755. * @param min defines the minimum vector (in local space)
  6756. * @param max defines the maximum vector (in local space)
  6757. * @param worldMatrix defines the new world matrix
  6758. */
  6759. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6760. /**
  6761. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6762. * @param min defines the new minimum vector (in local space)
  6763. * @param max defines the new maximum vector (in local space)
  6764. * @param worldMatrix defines the new world matrix
  6765. */
  6766. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6767. /**
  6768. * Scale the current bounding sphere by applying a scale factor
  6769. * @param factor defines the scale factor to apply
  6770. * @returns the current bounding box
  6771. */
  6772. scale(factor: number): BoundingSphere;
  6773. /**
  6774. * Gets the world matrix of the bounding box
  6775. * @returns a matrix
  6776. */
  6777. getWorldMatrix(): DeepImmutable<Matrix>;
  6778. /** @hidden */
  6779. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6780. /**
  6781. * Tests if the bounding sphere is intersecting the frustum planes
  6782. * @param frustumPlanes defines the frustum planes to test
  6783. * @returns true if there is an intersection
  6784. */
  6785. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6786. /**
  6787. * Tests if the bounding sphere center is in between the frustum planes.
  6788. * Used for optimistic fast inclusion.
  6789. * @param frustumPlanes defines the frustum planes to test
  6790. * @returns true if the sphere center is in between the frustum planes
  6791. */
  6792. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6793. /**
  6794. * Tests if a point is inside the bounding sphere
  6795. * @param point defines the point to test
  6796. * @returns true if the point is inside the bounding sphere
  6797. */
  6798. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6799. /**
  6800. * Checks if two sphere intersct
  6801. * @param sphere0 sphere 0
  6802. * @param sphere1 sphere 1
  6803. * @returns true if the speres intersect
  6804. */
  6805. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6806. }
  6807. }
  6808. declare module BABYLON {
  6809. /**
  6810. * Class used to store bounding box information
  6811. */
  6812. export class BoundingBox implements ICullable {
  6813. /**
  6814. * Gets the 8 vectors representing the bounding box in local space
  6815. */
  6816. readonly vectors: Vector3[];
  6817. /**
  6818. * Gets the center of the bounding box in local space
  6819. */
  6820. readonly center: Vector3;
  6821. /**
  6822. * Gets the center of the bounding box in world space
  6823. */
  6824. readonly centerWorld: Vector3;
  6825. /**
  6826. * Gets the extend size in local space
  6827. */
  6828. readonly extendSize: Vector3;
  6829. /**
  6830. * Gets the extend size in world space
  6831. */
  6832. readonly extendSizeWorld: Vector3;
  6833. /**
  6834. * Gets the OBB (object bounding box) directions
  6835. */
  6836. readonly directions: Vector3[];
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in world space
  6839. */
  6840. readonly vectorsWorld: Vector3[];
  6841. /**
  6842. * Gets the minimum vector in world space
  6843. */
  6844. readonly minimumWorld: Vector3;
  6845. /**
  6846. * Gets the maximum vector in world space
  6847. */
  6848. readonly maximumWorld: Vector3;
  6849. /**
  6850. * Gets the minimum vector in local space
  6851. */
  6852. readonly minimum: Vector3;
  6853. /**
  6854. * Gets the maximum vector in local space
  6855. */
  6856. readonly maximum: Vector3;
  6857. private _worldMatrix;
  6858. private static readonly TmpVector3;
  6859. /**
  6860. * @hidden
  6861. */
  6862. _tag: number;
  6863. /**
  6864. * Creates a new bounding box
  6865. * @param min defines the minimum vector (in local space)
  6866. * @param max defines the maximum vector (in local space)
  6867. * @param worldMatrix defines the new world matrix
  6868. */
  6869. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6870. /**
  6871. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6872. * @param min defines the new minimum vector (in local space)
  6873. * @param max defines the new maximum vector (in local space)
  6874. * @param worldMatrix defines the new world matrix
  6875. */
  6876. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6877. /**
  6878. * Scale the current bounding box by applying a scale factor
  6879. * @param factor defines the scale factor to apply
  6880. * @returns the current bounding box
  6881. */
  6882. scale(factor: number): BoundingBox;
  6883. /**
  6884. * Gets the world matrix of the bounding box
  6885. * @returns a matrix
  6886. */
  6887. getWorldMatrix(): DeepImmutable<Matrix>;
  6888. /** @hidden */
  6889. _update(world: DeepImmutable<Matrix>): void;
  6890. /**
  6891. * Tests if the bounding box is intersecting the frustum planes
  6892. * @param frustumPlanes defines the frustum planes to test
  6893. * @returns true if there is an intersection
  6894. */
  6895. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6896. /**
  6897. * Tests if the bounding box is entirely inside the frustum planes
  6898. * @param frustumPlanes defines the frustum planes to test
  6899. * @returns true if there is an inclusion
  6900. */
  6901. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6902. /**
  6903. * Tests if a point is inside the bounding box
  6904. * @param point defines the point to test
  6905. * @returns true if the point is inside the bounding box
  6906. */
  6907. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6908. /**
  6909. * Tests if the bounding box intersects with a bounding sphere
  6910. * @param sphere defines the sphere to test
  6911. * @returns true if there is an intersection
  6912. */
  6913. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6914. /**
  6915. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6916. * @param min defines the min vector to use
  6917. * @param max defines the max vector to use
  6918. * @returns true if there is an intersection
  6919. */
  6920. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6921. /**
  6922. * Tests if two bounding boxes are intersections
  6923. * @param box0 defines the first box to test
  6924. * @param box1 defines the second box to test
  6925. * @returns true if there is an intersection
  6926. */
  6927. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6928. /**
  6929. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6930. * @param minPoint defines the minimum vector of the bounding box
  6931. * @param maxPoint defines the maximum vector of the bounding box
  6932. * @param sphereCenter defines the sphere center
  6933. * @param sphereRadius defines the sphere radius
  6934. * @returns true if there is an intersection
  6935. */
  6936. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6937. /**
  6938. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6939. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @return true if there is an inclusion
  6942. */
  6943. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6946. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6947. * @param frustumPlanes defines the frustum planes to test
  6948. * @return true if there is an intersection
  6949. */
  6950. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6951. }
  6952. }
  6953. declare module BABYLON {
  6954. /** @hidden */
  6955. export class Collider {
  6956. /** Define if a collision was found */
  6957. collisionFound: boolean;
  6958. /**
  6959. * Define last intersection point in local space
  6960. */
  6961. intersectionPoint: Vector3;
  6962. /**
  6963. * Define last collided mesh
  6964. */
  6965. collidedMesh: Nullable<AbstractMesh>;
  6966. private _collisionPoint;
  6967. private _planeIntersectionPoint;
  6968. private _tempVector;
  6969. private _tempVector2;
  6970. private _tempVector3;
  6971. private _tempVector4;
  6972. private _edge;
  6973. private _baseToVertex;
  6974. private _destinationPoint;
  6975. private _slidePlaneNormal;
  6976. private _displacementVector;
  6977. /** @hidden */
  6978. _radius: Vector3;
  6979. /** @hidden */
  6980. _retry: number;
  6981. private _velocity;
  6982. private _basePoint;
  6983. private _epsilon;
  6984. /** @hidden */
  6985. _velocityWorldLength: number;
  6986. /** @hidden */
  6987. _basePointWorld: Vector3;
  6988. private _velocityWorld;
  6989. private _normalizedVelocity;
  6990. /** @hidden */
  6991. _initialVelocity: Vector3;
  6992. /** @hidden */
  6993. _initialPosition: Vector3;
  6994. private _nearestDistance;
  6995. private _collisionMask;
  6996. get collisionMask(): number;
  6997. set collisionMask(mask: number);
  6998. /**
  6999. * Gets the plane normal used to compute the sliding response (in local space)
  7000. */
  7001. get slidePlaneNormal(): Vector3;
  7002. /** @hidden */
  7003. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7004. /** @hidden */
  7005. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7006. /** @hidden */
  7007. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7008. /** @hidden */
  7009. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7010. /** @hidden */
  7011. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7012. /** @hidden */
  7013. _getResponse(pos: Vector3, vel: Vector3): void;
  7014. }
  7015. }
  7016. declare module BABYLON {
  7017. /**
  7018. * Interface for cullable objects
  7019. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7020. */
  7021. export interface ICullable {
  7022. /**
  7023. * Checks if the object or part of the object is in the frustum
  7024. * @param frustumPlanes Camera near/planes
  7025. * @returns true if the object is in frustum otherwise false
  7026. */
  7027. isInFrustum(frustumPlanes: Plane[]): boolean;
  7028. /**
  7029. * Checks if a cullable object (mesh...) is in the camera frustum
  7030. * Unlike isInFrustum this cheks the full bounding box
  7031. * @param frustumPlanes Camera near/planes
  7032. * @returns true if the object is in frustum otherwise false
  7033. */
  7034. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7035. }
  7036. /**
  7037. * Info for a bounding data of a mesh
  7038. */
  7039. export class BoundingInfo implements ICullable {
  7040. /**
  7041. * Bounding box for the mesh
  7042. */
  7043. readonly boundingBox: BoundingBox;
  7044. /**
  7045. * Bounding sphere for the mesh
  7046. */
  7047. readonly boundingSphere: BoundingSphere;
  7048. private _isLocked;
  7049. private static readonly TmpVector3;
  7050. /**
  7051. * Constructs bounding info
  7052. * @param minimum min vector of the bounding box/sphere
  7053. * @param maximum max vector of the bounding box/sphere
  7054. * @param worldMatrix defines the new world matrix
  7055. */
  7056. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7057. /**
  7058. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7059. * @param min defines the new minimum vector (in local space)
  7060. * @param max defines the new maximum vector (in local space)
  7061. * @param worldMatrix defines the new world matrix
  7062. */
  7063. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7064. /**
  7065. * min vector of the bounding box/sphere
  7066. */
  7067. get minimum(): Vector3;
  7068. /**
  7069. * max vector of the bounding box/sphere
  7070. */
  7071. get maximum(): Vector3;
  7072. /**
  7073. * If the info is locked and won't be updated to avoid perf overhead
  7074. */
  7075. get isLocked(): boolean;
  7076. set isLocked(value: boolean);
  7077. /**
  7078. * Updates the bounding sphere and box
  7079. * @param world world matrix to be used to update
  7080. */
  7081. update(world: DeepImmutable<Matrix>): void;
  7082. /**
  7083. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7084. * @param center New center of the bounding info
  7085. * @param extend New extend of the bounding info
  7086. * @returns the current bounding info
  7087. */
  7088. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7089. /**
  7090. * Scale the current bounding info by applying a scale factor
  7091. * @param factor defines the scale factor to apply
  7092. * @returns the current bounding info
  7093. */
  7094. scale(factor: number): BoundingInfo;
  7095. /**
  7096. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7097. * @param frustumPlanes defines the frustum to test
  7098. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7099. * @returns true if the bounding info is in the frustum planes
  7100. */
  7101. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7102. /**
  7103. * Gets the world distance between the min and max points of the bounding box
  7104. */
  7105. get diagonalLength(): number;
  7106. /**
  7107. * Checks if a cullable object (mesh...) is in the camera frustum
  7108. * Unlike isInFrustum this cheks the full bounding box
  7109. * @param frustumPlanes Camera near/planes
  7110. * @returns true if the object is in frustum otherwise false
  7111. */
  7112. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7113. /** @hidden */
  7114. _checkCollision(collider: Collider): boolean;
  7115. /**
  7116. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7117. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7118. * @param point the point to check intersection with
  7119. * @returns if the point intersects
  7120. */
  7121. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7122. /**
  7123. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7124. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7125. * @param boundingInfo the bounding info to check intersection with
  7126. * @param precise if the intersection should be done using OBB
  7127. * @returns if the bounding info intersects
  7128. */
  7129. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7130. }
  7131. }
  7132. declare module BABYLON {
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module BABYLON {
  7161. /** @hidden */
  7162. export class WebGLDataBuffer extends DataBuffer {
  7163. private _buffer;
  7164. constructor(resource: WebGLBuffer);
  7165. get underlyingResource(): any;
  7166. }
  7167. }
  7168. declare module BABYLON {
  7169. /** @hidden */
  7170. export class WebGLPipelineContext implements IPipelineContext {
  7171. engine: ThinEngine;
  7172. program: Nullable<WebGLProgram>;
  7173. context?: WebGLRenderingContext;
  7174. vertexShader?: WebGLShader;
  7175. fragmentShader?: WebGLShader;
  7176. isParallelCompiled: boolean;
  7177. onCompiled?: () => void;
  7178. transformFeedback?: WebGLTransformFeedback | null;
  7179. vertexCompilationError: Nullable<string>;
  7180. fragmentCompilationError: Nullable<string>;
  7181. programLinkError: Nullable<string>;
  7182. programValidationError: Nullable<string>;
  7183. get isAsync(): boolean;
  7184. get isReady(): boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. _getVertexShaderCode(): string | null;
  7187. _getFragmentShaderCode(): string | null;
  7188. }
  7189. }
  7190. declare module BABYLON {
  7191. interface ThinEngine {
  7192. /**
  7193. * Create an uniform buffer
  7194. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7195. * @param elements defines the content of the uniform buffer
  7196. * @returns the webGL uniform buffer
  7197. */
  7198. createUniformBuffer(elements: FloatArray): DataBuffer;
  7199. /**
  7200. * Create a dynamic uniform buffer
  7201. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7202. * @param elements defines the content of the uniform buffer
  7203. * @returns the webGL uniform buffer
  7204. */
  7205. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7206. /**
  7207. * Update an existing uniform buffer
  7208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7209. * @param uniformBuffer defines the target uniform buffer
  7210. * @param elements defines the content to update
  7211. * @param offset defines the offset in the uniform buffer where update should start
  7212. * @param count defines the size of the data to update
  7213. */
  7214. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7215. /**
  7216. * Bind an uniform buffer to the current webGL context
  7217. * @param buffer defines the buffer to bind
  7218. */
  7219. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7220. /**
  7221. * Bind a buffer to the current webGL context at a given location
  7222. * @param buffer defines the buffer to bind
  7223. * @param location defines the index where to bind the buffer
  7224. */
  7225. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7226. /**
  7227. * Bind a specific block at a given index in a specific shader program
  7228. * @param pipelineContext defines the pipeline context to use
  7229. * @param blockName defines the block name
  7230. * @param index defines the index where to bind the block
  7231. */
  7232. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7233. }
  7234. }
  7235. declare module BABYLON {
  7236. /**
  7237. * Uniform buffer objects.
  7238. *
  7239. * Handles blocks of uniform on the GPU.
  7240. *
  7241. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7242. *
  7243. * For more information, please refer to :
  7244. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7245. */
  7246. export class UniformBuffer {
  7247. private _engine;
  7248. private _buffer;
  7249. private _data;
  7250. private _bufferData;
  7251. private _dynamic?;
  7252. private _uniformLocations;
  7253. private _uniformSizes;
  7254. private _uniformLocationPointer;
  7255. private _needSync;
  7256. private _noUBO;
  7257. private _currentEffect;
  7258. /** @hidden */
  7259. _alreadyBound: boolean;
  7260. private static _MAX_UNIFORM_SIZE;
  7261. private static _tempBuffer;
  7262. /**
  7263. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7264. * This is dynamic to allow compat with webgl 1 and 2.
  7265. * You will need to pass the name of the uniform as well as the value.
  7266. */
  7267. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7268. /**
  7269. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7274. /**
  7275. * Lambda to Update a single float in a uniform buffer.
  7276. * This is dynamic to allow compat with webgl 1 and 2.
  7277. * You will need to pass the name of the uniform as well as the value.
  7278. */
  7279. updateFloat: (name: string, x: number) => void;
  7280. /**
  7281. * Lambda to Update a vec2 of float in a uniform buffer.
  7282. * This is dynamic to allow compat with webgl 1 and 2.
  7283. * You will need to pass the name of the uniform as well as the value.
  7284. */
  7285. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7286. /**
  7287. * Lambda to Update a vec3 of float in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7292. /**
  7293. * Lambda to Update a vec4 of float in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7298. /**
  7299. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateMatrix: (name: string, mat: Matrix) => void;
  7304. /**
  7305. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateVector3: (name: string, vector: Vector3) => void;
  7310. /**
  7311. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateVector4: (name: string, vector: Vector4) => void;
  7316. /**
  7317. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7328. /**
  7329. * Instantiates a new Uniform buffer objects.
  7330. *
  7331. * Handles blocks of uniform on the GPU.
  7332. *
  7333. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7334. *
  7335. * For more information, please refer to :
  7336. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7337. * @param engine Define the engine the buffer is associated with
  7338. * @param data Define the data contained in the buffer
  7339. * @param dynamic Define if the buffer is updatable
  7340. */
  7341. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7342. /**
  7343. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7344. * or just falling back on setUniformXXX calls.
  7345. */
  7346. get useUbo(): boolean;
  7347. /**
  7348. * Indicates if the WebGL underlying uniform buffer is in sync
  7349. * with the javascript cache data.
  7350. */
  7351. get isSync(): boolean;
  7352. /**
  7353. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7354. * Also, a dynamic UniformBuffer will disable cache verification and always
  7355. * update the underlying WebGL uniform buffer to the GPU.
  7356. * @returns if Dynamic, otherwise false
  7357. */
  7358. isDynamic(): boolean;
  7359. /**
  7360. * The data cache on JS side.
  7361. * @returns the underlying data as a float array
  7362. */
  7363. getData(): Float32Array;
  7364. /**
  7365. * The underlying WebGL Uniform buffer.
  7366. * @returns the webgl buffer
  7367. */
  7368. getBuffer(): Nullable<DataBuffer>;
  7369. /**
  7370. * std140 layout specifies how to align data within an UBO structure.
  7371. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7372. * for specs.
  7373. */
  7374. private _fillAlignment;
  7375. /**
  7376. * Adds an uniform in the buffer.
  7377. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7378. * for the layout to be correct !
  7379. * @param name Name of the uniform, as used in the uniform block in the shader.
  7380. * @param size Data size, or data directly.
  7381. */
  7382. addUniform(name: string, size: number | number[]): void;
  7383. /**
  7384. * Adds a Matrix 4x4 to the uniform buffer.
  7385. * @param name Name of the uniform, as used in the uniform block in the shader.
  7386. * @param mat A 4x4 matrix.
  7387. */
  7388. addMatrix(name: string, mat: Matrix): void;
  7389. /**
  7390. * Adds a vec2 to the uniform buffer.
  7391. * @param name Name of the uniform, as used in the uniform block in the shader.
  7392. * @param x Define the x component value of the vec2
  7393. * @param y Define the y component value of the vec2
  7394. */
  7395. addFloat2(name: string, x: number, y: number): void;
  7396. /**
  7397. * Adds a vec3 to the uniform buffer.
  7398. * @param name Name of the uniform, as used in the uniform block in the shader.
  7399. * @param x Define the x component value of the vec3
  7400. * @param y Define the y component value of the vec3
  7401. * @param z Define the z component value of the vec3
  7402. */
  7403. addFloat3(name: string, x: number, y: number, z: number): void;
  7404. /**
  7405. * Adds a vec3 to the uniform buffer.
  7406. * @param name Name of the uniform, as used in the uniform block in the shader.
  7407. * @param color Define the vec3 from a Color
  7408. */
  7409. addColor3(name: string, color: Color3): void;
  7410. /**
  7411. * Adds a vec4 to the uniform buffer.
  7412. * @param name Name of the uniform, as used in the uniform block in the shader.
  7413. * @param color Define the rgb components from a Color
  7414. * @param alpha Define the a component of the vec4
  7415. */
  7416. addColor4(name: string, color: Color3, alpha: number): void;
  7417. /**
  7418. * Adds a vec3 to the uniform buffer.
  7419. * @param name Name of the uniform, as used in the uniform block in the shader.
  7420. * @param vector Define the vec3 components from a Vector
  7421. */
  7422. addVector3(name: string, vector: Vector3): void;
  7423. /**
  7424. * Adds a Matrix 3x3 to the uniform buffer.
  7425. * @param name Name of the uniform, as used in the uniform block in the shader.
  7426. */
  7427. addMatrix3x3(name: string): void;
  7428. /**
  7429. * Adds a Matrix 2x2 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. */
  7432. addMatrix2x2(name: string): void;
  7433. /**
  7434. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7435. */
  7436. create(): void;
  7437. /** @hidden */
  7438. _rebuild(): void;
  7439. /**
  7440. * Updates the WebGL Uniform Buffer on the GPU.
  7441. * If the `dynamic` flag is set to true, no cache comparison is done.
  7442. * Otherwise, the buffer will be updated only if the cache differs.
  7443. */
  7444. update(): void;
  7445. /**
  7446. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7447. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7448. * @param data Define the flattened data
  7449. * @param size Define the size of the data.
  7450. */
  7451. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7452. private _valueCache;
  7453. private _cacheMatrix;
  7454. private _updateMatrix3x3ForUniform;
  7455. private _updateMatrix3x3ForEffect;
  7456. private _updateMatrix2x2ForEffect;
  7457. private _updateMatrix2x2ForUniform;
  7458. private _updateFloatForEffect;
  7459. private _updateFloatForUniform;
  7460. private _updateFloat2ForEffect;
  7461. private _updateFloat2ForUniform;
  7462. private _updateFloat3ForEffect;
  7463. private _updateFloat3ForUniform;
  7464. private _updateFloat4ForEffect;
  7465. private _updateFloat4ForUniform;
  7466. private _updateMatrixForEffect;
  7467. private _updateMatrixForUniform;
  7468. private _updateVector3ForEffect;
  7469. private _updateVector3ForUniform;
  7470. private _updateVector4ForEffect;
  7471. private _updateVector4ForUniform;
  7472. private _updateColor3ForEffect;
  7473. private _updateColor3ForUniform;
  7474. private _updateColor4ForEffect;
  7475. private _updateColor4ForUniform;
  7476. /**
  7477. * Sets a sampler uniform on the effect.
  7478. * @param name Define the name of the sampler.
  7479. * @param texture Define the texture to set in the sampler
  7480. */
  7481. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7482. /**
  7483. * Directly updates the value of the uniform in the cache AND on the GPU.
  7484. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7485. * @param data Define the flattened data
  7486. */
  7487. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7488. /**
  7489. * Binds this uniform buffer to an effect.
  7490. * @param effect Define the effect to bind the buffer to
  7491. * @param name Name of the uniform block in the shader.
  7492. */
  7493. bindToEffect(effect: Effect, name: string): void;
  7494. /**
  7495. * Disposes the uniform buffer.
  7496. */
  7497. dispose(): void;
  7498. }
  7499. }
  7500. declare module BABYLON {
  7501. /**
  7502. * Enum that determines the text-wrapping mode to use.
  7503. */
  7504. export enum InspectableType {
  7505. /**
  7506. * Checkbox for booleans
  7507. */
  7508. Checkbox = 0,
  7509. /**
  7510. * Sliders for numbers
  7511. */
  7512. Slider = 1,
  7513. /**
  7514. * Vector3
  7515. */
  7516. Vector3 = 2,
  7517. /**
  7518. * Quaternions
  7519. */
  7520. Quaternion = 3,
  7521. /**
  7522. * Color3
  7523. */
  7524. Color3 = 4,
  7525. /**
  7526. * String
  7527. */
  7528. String = 5
  7529. }
  7530. /**
  7531. * Interface used to define custom inspectable properties.
  7532. * This interface is used by the inspector to display custom property grids
  7533. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7534. */
  7535. export interface IInspectable {
  7536. /**
  7537. * Gets the label to display
  7538. */
  7539. label: string;
  7540. /**
  7541. * Gets the name of the property to edit
  7542. */
  7543. propertyName: string;
  7544. /**
  7545. * Gets the type of the editor to use
  7546. */
  7547. type: InspectableType;
  7548. /**
  7549. * Gets the minimum value of the property when using in "slider" mode
  7550. */
  7551. min?: number;
  7552. /**
  7553. * Gets the maximum value of the property when using in "slider" mode
  7554. */
  7555. max?: number;
  7556. /**
  7557. * Gets the setp to use when using in "slider" mode
  7558. */
  7559. step?: number;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * Class used to provide helper for timing
  7565. */
  7566. export class TimingTools {
  7567. /**
  7568. * Polyfill for setImmediate
  7569. * @param action defines the action to execute after the current execution block
  7570. */
  7571. static SetImmediate(action: () => void): void;
  7572. }
  7573. }
  7574. declare module BABYLON {
  7575. /**
  7576. * Class used to enable instatition of objects by class name
  7577. */
  7578. export class InstantiationTools {
  7579. /**
  7580. * Use this object to register external classes like custom textures or material
  7581. * to allow the laoders to instantiate them
  7582. */
  7583. static RegisteredExternalClasses: {
  7584. [key: string]: Object;
  7585. };
  7586. /**
  7587. * Tries to instantiate a new object from a given class name
  7588. * @param className defines the class name to instantiate
  7589. * @returns the new object or null if the system was not able to do the instantiation
  7590. */
  7591. static Instantiate(className: string): any;
  7592. }
  7593. }
  7594. declare module BABYLON {
  7595. /**
  7596. * Define options used to create a depth texture
  7597. */
  7598. export class DepthTextureCreationOptions {
  7599. /** Specifies whether or not a stencil should be allocated in the texture */
  7600. generateStencil?: boolean;
  7601. /** Specifies whether or not bilinear filtering is enable on the texture */
  7602. bilinearFiltering?: boolean;
  7603. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7604. comparisonFunction?: number;
  7605. /** Specifies if the created texture is a cube texture */
  7606. isCube?: boolean;
  7607. }
  7608. }
  7609. declare module BABYLON {
  7610. interface ThinEngine {
  7611. /**
  7612. * Creates a depth stencil cube texture.
  7613. * This is only available in WebGL 2.
  7614. * @param size The size of face edge in the cube texture.
  7615. * @param options The options defining the cube texture.
  7616. * @returns The cube texture
  7617. */
  7618. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7619. /**
  7620. * Creates a cube texture
  7621. * @param rootUrl defines the url where the files to load is located
  7622. * @param scene defines the current scene
  7623. * @param files defines the list of files to load (1 per face)
  7624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7625. * @param onLoad defines an optional callback raised when the texture is loaded
  7626. * @param onError defines an optional callback raised if there is an issue to load the texture
  7627. * @param format defines the format of the data
  7628. * @param forcedExtension defines the extension to use to pick the right loader
  7629. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7632. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7633. * @returns the cube texture as an InternalTexture
  7634. */
  7635. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @returns the cube texture as an InternalTexture
  7647. */
  7648. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7649. /**
  7650. * Creates a cube texture
  7651. * @param rootUrl defines the url where the files to load is located
  7652. * @param scene defines the current scene
  7653. * @param files defines the list of files to load (1 per face)
  7654. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7655. * @param onLoad defines an optional callback raised when the texture is loaded
  7656. * @param onError defines an optional callback raised if there is an issue to load the texture
  7657. * @param format defines the format of the data
  7658. * @param forcedExtension defines the extension to use to pick the right loader
  7659. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7660. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7661. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7662. * @returns the cube texture as an InternalTexture
  7663. */
  7664. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7665. /** @hidden */
  7666. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7671. /** @hidden */
  7672. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7673. /**
  7674. * @hidden
  7675. */
  7676. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7677. }
  7678. }
  7679. declare module BABYLON {
  7680. /**
  7681. * Class for creating a cube texture
  7682. */
  7683. export class CubeTexture extends BaseTexture {
  7684. private _delayedOnLoad;
  7685. /**
  7686. * Observable triggered once the texture has been loaded.
  7687. */
  7688. onLoadObservable: Observable<CubeTexture>;
  7689. /**
  7690. * The url of the texture
  7691. */
  7692. url: string;
  7693. /**
  7694. * Gets or sets the center of the bounding box associated with the cube texture.
  7695. * It must define where the camera used to render the texture was set
  7696. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7697. */
  7698. boundingBoxPosition: Vector3;
  7699. private _boundingBoxSize;
  7700. /**
  7701. * Gets or sets the size of the bounding box associated with the cube texture
  7702. * When defined, the cubemap will switch to local mode
  7703. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7704. * @example https://www.babylonjs-playground.com/#RNASML
  7705. */
  7706. set boundingBoxSize(value: Vector3);
  7707. /**
  7708. * Returns the bounding box size
  7709. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7710. */
  7711. get boundingBoxSize(): Vector3;
  7712. protected _rotationY: number;
  7713. /**
  7714. * Sets texture matrix rotation angle around Y axis in radians.
  7715. */
  7716. set rotationY(value: number);
  7717. /**
  7718. * Gets texture matrix rotation angle around Y axis radians.
  7719. */
  7720. get rotationY(): number;
  7721. /**
  7722. * Are mip maps generated for this texture or not.
  7723. */
  7724. get noMipmap(): boolean;
  7725. private _noMipmap;
  7726. private _files;
  7727. protected _forcedExtension: Nullable<string>;
  7728. private _extensions;
  7729. private _textureMatrix;
  7730. private _format;
  7731. private _createPolynomials;
  7732. /** @hidden */
  7733. _prefiltered: boolean;
  7734. /**
  7735. * Creates a cube texture from an array of image urls
  7736. * @param files defines an array of image urls
  7737. * @param scene defines the hosting scene
  7738. * @param noMipmap specifies if mip maps are not used
  7739. * @returns a cube texture
  7740. */
  7741. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7742. /**
  7743. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7744. * @param url defines the url of the prefiltered texture
  7745. * @param scene defines the scene the texture is attached to
  7746. * @param forcedExtension defines the extension of the file if different from the url
  7747. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7748. * @return the prefiltered texture
  7749. */
  7750. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7751. /**
  7752. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7753. * as prefiltered data.
  7754. * @param rootUrl defines the url of the texture or the root name of the six images
  7755. * @param scene defines the scene the texture is attached to
  7756. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7757. * @param noMipmap defines if mipmaps should be created or not
  7758. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7759. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7760. * @param onError defines a callback triggered in case of error during load
  7761. * @param format defines the internal format to use for the texture once loaded
  7762. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7763. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7764. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7765. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7766. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7767. * @return the cube texture
  7768. */
  7769. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7770. /**
  7771. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7772. */
  7773. get isPrefiltered(): boolean;
  7774. /**
  7775. * Get the current class name of the texture useful for serialization or dynamic coding.
  7776. * @returns "CubeTexture"
  7777. */
  7778. getClassName(): string;
  7779. /**
  7780. * Update the url (and optional buffer) of this texture if url was null during construction.
  7781. * @param url the url of the texture
  7782. * @param forcedExtension defines the extension to use
  7783. * @param onLoad callback called when the texture is loaded (defaults to null)
  7784. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7785. */
  7786. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7787. /**
  7788. * Delays loading of the cube texture
  7789. * @param forcedExtension defines the extension to use
  7790. */
  7791. delayLoad(forcedExtension?: string): void;
  7792. /**
  7793. * Returns the reflection texture matrix
  7794. * @returns the reflection texture matrix
  7795. */
  7796. getReflectionTextureMatrix(): Matrix;
  7797. /**
  7798. * Sets the reflection texture matrix
  7799. * @param value Reflection texture matrix
  7800. */
  7801. setReflectionTextureMatrix(value: Matrix): void;
  7802. /**
  7803. * Parses text to create a cube texture
  7804. * @param parsedTexture define the serialized text to read from
  7805. * @param scene defines the hosting scene
  7806. * @param rootUrl defines the root url of the cube texture
  7807. * @returns a cube texture
  7808. */
  7809. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7810. /**
  7811. * Makes a clone, or deep copy, of the cube texture
  7812. * @returns a new cube texture
  7813. */
  7814. clone(): CubeTexture;
  7815. }
  7816. }
  7817. declare module BABYLON {
  7818. /**
  7819. * Manages the defines for the Material
  7820. */
  7821. export class MaterialDefines {
  7822. /** @hidden */
  7823. protected _keys: string[];
  7824. private _isDirty;
  7825. /** @hidden */
  7826. _renderId: number;
  7827. /** @hidden */
  7828. _areLightsDirty: boolean;
  7829. /** @hidden */
  7830. _areLightsDisposed: boolean;
  7831. /** @hidden */
  7832. _areAttributesDirty: boolean;
  7833. /** @hidden */
  7834. _areTexturesDirty: boolean;
  7835. /** @hidden */
  7836. _areFresnelDirty: boolean;
  7837. /** @hidden */
  7838. _areMiscDirty: boolean;
  7839. /** @hidden */
  7840. _areImageProcessingDirty: boolean;
  7841. /** @hidden */
  7842. _normals: boolean;
  7843. /** @hidden */
  7844. _uvs: boolean;
  7845. /** @hidden */
  7846. _needNormals: boolean;
  7847. /** @hidden */
  7848. _needUVs: boolean;
  7849. [id: string]: any;
  7850. /**
  7851. * Specifies if the material needs to be re-calculated
  7852. */
  7853. get isDirty(): boolean;
  7854. /**
  7855. * Marks the material to indicate that it has been re-calculated
  7856. */
  7857. markAsProcessed(): void;
  7858. /**
  7859. * Marks the material to indicate that it needs to be re-calculated
  7860. */
  7861. markAsUnprocessed(): void;
  7862. /**
  7863. * Marks the material to indicate all of its defines need to be re-calculated
  7864. */
  7865. markAllAsDirty(): void;
  7866. /**
  7867. * Marks the material to indicate that image processing needs to be re-calculated
  7868. */
  7869. markAsImageProcessingDirty(): void;
  7870. /**
  7871. * Marks the material to indicate the lights need to be re-calculated
  7872. * @param disposed Defines whether the light is dirty due to dispose or not
  7873. */
  7874. markAsLightDirty(disposed?: boolean): void;
  7875. /**
  7876. * Marks the attribute state as changed
  7877. */
  7878. markAsAttributesDirty(): void;
  7879. /**
  7880. * Marks the texture state as changed
  7881. */
  7882. markAsTexturesDirty(): void;
  7883. /**
  7884. * Marks the fresnel state as changed
  7885. */
  7886. markAsFresnelDirty(): void;
  7887. /**
  7888. * Marks the misc state as changed
  7889. */
  7890. markAsMiscDirty(): void;
  7891. /**
  7892. * Rebuilds the material defines
  7893. */
  7894. rebuild(): void;
  7895. /**
  7896. * Specifies if two material defines are equal
  7897. * @param other - A material define instance to compare to
  7898. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7899. */
  7900. isEqual(other: MaterialDefines): boolean;
  7901. /**
  7902. * Clones this instance's defines to another instance
  7903. * @param other - material defines to clone values to
  7904. */
  7905. cloneTo(other: MaterialDefines): void;
  7906. /**
  7907. * Resets the material define values
  7908. */
  7909. reset(): void;
  7910. /**
  7911. * Converts the material define values to a string
  7912. * @returns - String of material define information
  7913. */
  7914. toString(): string;
  7915. }
  7916. }
  7917. declare module BABYLON {
  7918. /**
  7919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7921. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7923. */
  7924. export class ColorCurves {
  7925. private _dirty;
  7926. private _tempColor;
  7927. private _globalCurve;
  7928. private _highlightsCurve;
  7929. private _midtonesCurve;
  7930. private _shadowsCurve;
  7931. private _positiveCurve;
  7932. private _negativeCurve;
  7933. private _globalHue;
  7934. private _globalDensity;
  7935. private _globalSaturation;
  7936. private _globalExposure;
  7937. /**
  7938. * Gets the global Hue value.
  7939. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7940. */
  7941. get globalHue(): number;
  7942. /**
  7943. * Sets the global Hue value.
  7944. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7945. */
  7946. set globalHue(value: number);
  7947. /**
  7948. * Gets the global Density value.
  7949. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7950. * Values less than zero provide a filter of opposite hue.
  7951. */
  7952. get globalDensity(): number;
  7953. /**
  7954. * Sets the global Density value.
  7955. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7956. * Values less than zero provide a filter of opposite hue.
  7957. */
  7958. set globalDensity(value: number);
  7959. /**
  7960. * Gets the global Saturation value.
  7961. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7962. */
  7963. get globalSaturation(): number;
  7964. /**
  7965. * Sets the global Saturation value.
  7966. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7967. */
  7968. set globalSaturation(value: number);
  7969. /**
  7970. * Gets the global Exposure value.
  7971. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7972. */
  7973. get globalExposure(): number;
  7974. /**
  7975. * Sets the global Exposure value.
  7976. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7977. */
  7978. set globalExposure(value: number);
  7979. private _highlightsHue;
  7980. private _highlightsDensity;
  7981. private _highlightsSaturation;
  7982. private _highlightsExposure;
  7983. /**
  7984. * Gets the highlights Hue value.
  7985. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7986. */
  7987. get highlightsHue(): number;
  7988. /**
  7989. * Sets the highlights Hue value.
  7990. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7991. */
  7992. set highlightsHue(value: number);
  7993. /**
  7994. * Gets the highlights Density value.
  7995. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7996. * Values less than zero provide a filter of opposite hue.
  7997. */
  7998. get highlightsDensity(): number;
  7999. /**
  8000. * Sets the highlights Density value.
  8001. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8002. * Values less than zero provide a filter of opposite hue.
  8003. */
  8004. set highlightsDensity(value: number);
  8005. /**
  8006. * Gets the highlights Saturation value.
  8007. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8008. */
  8009. get highlightsSaturation(): number;
  8010. /**
  8011. * Sets the highlights Saturation value.
  8012. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8013. */
  8014. set highlightsSaturation(value: number);
  8015. /**
  8016. * Gets the highlights Exposure value.
  8017. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8018. */
  8019. get highlightsExposure(): number;
  8020. /**
  8021. * Sets the highlights Exposure value.
  8022. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8023. */
  8024. set highlightsExposure(value: number);
  8025. private _midtonesHue;
  8026. private _midtonesDensity;
  8027. private _midtonesSaturation;
  8028. private _midtonesExposure;
  8029. /**
  8030. * Gets the midtones Hue value.
  8031. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8032. */
  8033. get midtonesHue(): number;
  8034. /**
  8035. * Sets the midtones Hue value.
  8036. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8037. */
  8038. set midtonesHue(value: number);
  8039. /**
  8040. * Gets the midtones Density value.
  8041. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8042. * Values less than zero provide a filter of opposite hue.
  8043. */
  8044. get midtonesDensity(): number;
  8045. /**
  8046. * Sets the midtones Density value.
  8047. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8048. * Values less than zero provide a filter of opposite hue.
  8049. */
  8050. set midtonesDensity(value: number);
  8051. /**
  8052. * Gets the midtones Saturation value.
  8053. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8054. */
  8055. get midtonesSaturation(): number;
  8056. /**
  8057. * Sets the midtones Saturation value.
  8058. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8059. */
  8060. set midtonesSaturation(value: number);
  8061. /**
  8062. * Gets the midtones Exposure value.
  8063. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8064. */
  8065. get midtonesExposure(): number;
  8066. /**
  8067. * Sets the midtones Exposure value.
  8068. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8069. */
  8070. set midtonesExposure(value: number);
  8071. private _shadowsHue;
  8072. private _shadowsDensity;
  8073. private _shadowsSaturation;
  8074. private _shadowsExposure;
  8075. /**
  8076. * Gets the shadows Hue value.
  8077. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8078. */
  8079. get shadowsHue(): number;
  8080. /**
  8081. * Sets the shadows Hue value.
  8082. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8083. */
  8084. set shadowsHue(value: number);
  8085. /**
  8086. * Gets the shadows Density value.
  8087. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8088. * Values less than zero provide a filter of opposite hue.
  8089. */
  8090. get shadowsDensity(): number;
  8091. /**
  8092. * Sets the shadows Density value.
  8093. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8094. * Values less than zero provide a filter of opposite hue.
  8095. */
  8096. set shadowsDensity(value: number);
  8097. /**
  8098. * Gets the shadows Saturation value.
  8099. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8100. */
  8101. get shadowsSaturation(): number;
  8102. /**
  8103. * Sets the shadows Saturation value.
  8104. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8105. */
  8106. set shadowsSaturation(value: number);
  8107. /**
  8108. * Gets the shadows Exposure value.
  8109. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8110. */
  8111. get shadowsExposure(): number;
  8112. /**
  8113. * Sets the shadows Exposure value.
  8114. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8115. */
  8116. set shadowsExposure(value: number);
  8117. /**
  8118. * Returns the class name
  8119. * @returns The class name
  8120. */
  8121. getClassName(): string;
  8122. /**
  8123. * Binds the color curves to the shader.
  8124. * @param colorCurves The color curve to bind
  8125. * @param effect The effect to bind to
  8126. * @param positiveUniform The positive uniform shader parameter
  8127. * @param neutralUniform The neutral uniform shader parameter
  8128. * @param negativeUniform The negative uniform shader parameter
  8129. */
  8130. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8131. /**
  8132. * Prepare the list of uniforms associated with the ColorCurves effects.
  8133. * @param uniformsList The list of uniforms used in the effect
  8134. */
  8135. static PrepareUniforms(uniformsList: string[]): void;
  8136. /**
  8137. * Returns color grading data based on a hue, density, saturation and exposure value.
  8138. * @param filterHue The hue of the color filter.
  8139. * @param filterDensity The density of the color filter.
  8140. * @param saturation The saturation.
  8141. * @param exposure The exposure.
  8142. * @param result The result data container.
  8143. */
  8144. private getColorGradingDataToRef;
  8145. /**
  8146. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8147. * @param value The input slider value in range [-100,100].
  8148. * @returns Adjusted value.
  8149. */
  8150. private static applyColorGradingSliderNonlinear;
  8151. /**
  8152. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8153. * @param hue The hue (H) input.
  8154. * @param saturation The saturation (S) input.
  8155. * @param brightness The brightness (B) input.
  8156. * @result An RGBA color represented as Vector4.
  8157. */
  8158. private static fromHSBToRef;
  8159. /**
  8160. * Returns a value clamped between min and max
  8161. * @param value The value to clamp
  8162. * @param min The minimum of value
  8163. * @param max The maximum of value
  8164. * @returns The clamped value.
  8165. */
  8166. private static clamp;
  8167. /**
  8168. * Clones the current color curve instance.
  8169. * @return The cloned curves
  8170. */
  8171. clone(): ColorCurves;
  8172. /**
  8173. * Serializes the current color curve instance to a json representation.
  8174. * @return a JSON representation
  8175. */
  8176. serialize(): any;
  8177. /**
  8178. * Parses the color curve from a json representation.
  8179. * @param source the JSON source to parse
  8180. * @return The parsed curves
  8181. */
  8182. static Parse(source: any): ColorCurves;
  8183. }
  8184. }
  8185. declare module BABYLON {
  8186. /**
  8187. * Interface to follow in your material defines to integrate easily the
  8188. * Image proccessing functions.
  8189. * @hidden
  8190. */
  8191. export interface IImageProcessingConfigurationDefines {
  8192. IMAGEPROCESSING: boolean;
  8193. VIGNETTE: boolean;
  8194. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8195. VIGNETTEBLENDMODEOPAQUE: boolean;
  8196. TONEMAPPING: boolean;
  8197. TONEMAPPING_ACES: boolean;
  8198. CONTRAST: boolean;
  8199. EXPOSURE: boolean;
  8200. COLORCURVES: boolean;
  8201. COLORGRADING: boolean;
  8202. COLORGRADING3D: boolean;
  8203. SAMPLER3DGREENDEPTH: boolean;
  8204. SAMPLER3DBGRMAP: boolean;
  8205. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8206. }
  8207. /**
  8208. * @hidden
  8209. */
  8210. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8211. IMAGEPROCESSING: boolean;
  8212. VIGNETTE: boolean;
  8213. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8214. VIGNETTEBLENDMODEOPAQUE: boolean;
  8215. TONEMAPPING: boolean;
  8216. TONEMAPPING_ACES: boolean;
  8217. CONTRAST: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. EXPOSURE: boolean;
  8225. constructor();
  8226. }
  8227. /**
  8228. * This groups together the common properties used for image processing either in direct forward pass
  8229. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8230. * or not.
  8231. */
  8232. export class ImageProcessingConfiguration {
  8233. /**
  8234. * Default tone mapping applied in BabylonJS.
  8235. */
  8236. static readonly TONEMAPPING_STANDARD: number;
  8237. /**
  8238. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8239. * to other engines rendering to increase portability.
  8240. */
  8241. static readonly TONEMAPPING_ACES: number;
  8242. /**
  8243. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8244. */
  8245. colorCurves: Nullable<ColorCurves>;
  8246. private _colorCurvesEnabled;
  8247. /**
  8248. * Gets wether the color curves effect is enabled.
  8249. */
  8250. get colorCurvesEnabled(): boolean;
  8251. /**
  8252. * Sets wether the color curves effect is enabled.
  8253. */
  8254. set colorCurvesEnabled(value: boolean);
  8255. private _colorGradingTexture;
  8256. /**
  8257. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8258. */
  8259. get colorGradingTexture(): Nullable<BaseTexture>;
  8260. /**
  8261. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8262. */
  8263. set colorGradingTexture(value: Nullable<BaseTexture>);
  8264. private _colorGradingEnabled;
  8265. /**
  8266. * Gets wether the color grading effect is enabled.
  8267. */
  8268. get colorGradingEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color grading effect is enabled.
  8271. */
  8272. set colorGradingEnabled(value: boolean);
  8273. private _colorGradingWithGreenDepth;
  8274. /**
  8275. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8276. */
  8277. get colorGradingWithGreenDepth(): boolean;
  8278. /**
  8279. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8280. */
  8281. set colorGradingWithGreenDepth(value: boolean);
  8282. private _colorGradingBGR;
  8283. /**
  8284. * Gets wether the color grading texture contains BGR values.
  8285. */
  8286. get colorGradingBGR(): boolean;
  8287. /**
  8288. * Sets wether the color grading texture contains BGR values.
  8289. */
  8290. set colorGradingBGR(value: boolean);
  8291. /** @hidden */
  8292. _exposure: number;
  8293. /**
  8294. * Gets the Exposure used in the effect.
  8295. */
  8296. get exposure(): number;
  8297. /**
  8298. * Sets the Exposure used in the effect.
  8299. */
  8300. set exposure(value: number);
  8301. private _toneMappingEnabled;
  8302. /**
  8303. * Gets wether the tone mapping effect is enabled.
  8304. */
  8305. get toneMappingEnabled(): boolean;
  8306. /**
  8307. * Sets wether the tone mapping effect is enabled.
  8308. */
  8309. set toneMappingEnabled(value: boolean);
  8310. private _toneMappingType;
  8311. /**
  8312. * Gets the type of tone mapping effect.
  8313. */
  8314. get toneMappingType(): number;
  8315. /**
  8316. * Sets the type of tone mapping effect used in BabylonJS.
  8317. */
  8318. set toneMappingType(value: number);
  8319. protected _contrast: number;
  8320. /**
  8321. * Gets the contrast used in the effect.
  8322. */
  8323. get contrast(): number;
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. set contrast(value: number);
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. get vignetteBlendMode(): number;
  8358. /**
  8359. * Sets the vignette blend mode allowing different kind of effect.
  8360. */
  8361. set vignetteBlendMode(value: number);
  8362. private _vignetteEnabled;
  8363. /**
  8364. * Gets wether the vignette effect is enabled.
  8365. */
  8366. get vignetteEnabled(): boolean;
  8367. /**
  8368. * Sets wether the vignette effect is enabled.
  8369. */
  8370. set vignetteEnabled(value: boolean);
  8371. private _applyByPostProcess;
  8372. /**
  8373. * Gets wether the image processing is applied through a post process or not.
  8374. */
  8375. get applyByPostProcess(): boolean;
  8376. /**
  8377. * Sets wether the image processing is applied through a post process or not.
  8378. */
  8379. set applyByPostProcess(value: boolean);
  8380. private _isEnabled;
  8381. /**
  8382. * Gets wether the image processing is enabled or not.
  8383. */
  8384. get isEnabled(): boolean;
  8385. /**
  8386. * Sets wether the image processing is enabled or not.
  8387. */
  8388. set isEnabled(value: boolean);
  8389. /**
  8390. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8391. */
  8392. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8393. /**
  8394. * Method called each time the image processing information changes requires to recompile the effect.
  8395. */
  8396. protected _updateParameters(): void;
  8397. /**
  8398. * Gets the current class name.
  8399. * @return "ImageProcessingConfiguration"
  8400. */
  8401. getClassName(): string;
  8402. /**
  8403. * Prepare the list of uniforms associated with the Image Processing effects.
  8404. * @param uniforms The list of uniforms used in the effect
  8405. * @param defines the list of defines currently in use
  8406. */
  8407. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8408. /**
  8409. * Prepare the list of samplers associated with the Image Processing effects.
  8410. * @param samplersList The list of uniforms used in the effect
  8411. * @param defines the list of defines currently in use
  8412. */
  8413. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8414. /**
  8415. * Prepare the list of defines associated to the shader.
  8416. * @param defines the list of defines to complete
  8417. * @param forPostProcess Define if we are currently in post process mode or not
  8418. */
  8419. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8420. /**
  8421. * Returns true if all the image processing information are ready.
  8422. * @returns True if ready, otherwise, false
  8423. */
  8424. isReady(): boolean;
  8425. /**
  8426. * Binds the image processing to the shader.
  8427. * @param effect The effect to bind to
  8428. * @param overrideAspectRatio Override the aspect ratio of the effect
  8429. */
  8430. bind(effect: Effect, overrideAspectRatio?: number): void;
  8431. /**
  8432. * Clones the current image processing instance.
  8433. * @return The cloned image processing
  8434. */
  8435. clone(): ImageProcessingConfiguration;
  8436. /**
  8437. * Serializes the current image processing instance to a json representation.
  8438. * @return a JSON representation
  8439. */
  8440. serialize(): any;
  8441. /**
  8442. * Parses the image processing from a json representation.
  8443. * @param source the JSON source to parse
  8444. * @return The parsed image processing
  8445. */
  8446. static Parse(source: any): ImageProcessingConfiguration;
  8447. private static _VIGNETTEMODE_MULTIPLY;
  8448. private static _VIGNETTEMODE_OPAQUE;
  8449. /**
  8450. * Used to apply the vignette as a mix with the pixel color.
  8451. */
  8452. static get VIGNETTEMODE_MULTIPLY(): number;
  8453. /**
  8454. * Used to apply the vignette as a replacement of the pixel color.
  8455. */
  8456. static get VIGNETTEMODE_OPAQUE(): number;
  8457. }
  8458. }
  8459. declare module BABYLON {
  8460. /** @hidden */
  8461. export var postprocessVertexShader: {
  8462. name: string;
  8463. shader: string;
  8464. };
  8465. }
  8466. declare module BABYLON {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. layers?: number;
  8478. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8479. /**
  8480. * Creates a depth stencil texture.
  8481. * This is only available in WebGL 2 or with the depth texture extension available.
  8482. * @param size The size of face edge in the texture.
  8483. * @param options The options defining the texture.
  8484. * @returns The texture
  8485. */
  8486. createDepthStencilTexture(size: number | {
  8487. width: number;
  8488. height: number;
  8489. layers?: number;
  8490. }, options: DepthTextureCreationOptions): InternalTexture;
  8491. /** @hidden */
  8492. _createDepthStencilTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: DepthTextureCreationOptions): InternalTexture;
  8497. }
  8498. }
  8499. declare module BABYLON {
  8500. /** Defines supported spaces */
  8501. export enum Space {
  8502. /** Local (object) space */
  8503. LOCAL = 0,
  8504. /** World space */
  8505. WORLD = 1,
  8506. /** Bone space */
  8507. BONE = 2
  8508. }
  8509. /** Defines the 3 main axes */
  8510. export class Axis {
  8511. /** X axis */
  8512. static X: Vector3;
  8513. /** Y axis */
  8514. static Y: Vector3;
  8515. /** Z axis */
  8516. static Z: Vector3;
  8517. }
  8518. }
  8519. declare module BABYLON {
  8520. /**
  8521. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8522. * This is the base of the follow, arc rotate cameras and Free camera
  8523. * @see http://doc.babylonjs.com/features/cameras
  8524. */
  8525. export class TargetCamera extends Camera {
  8526. private static _RigCamTransformMatrix;
  8527. private static _TargetTransformMatrix;
  8528. private static _TargetFocalPoint;
  8529. /**
  8530. * Define the current direction the camera is moving to
  8531. */
  8532. cameraDirection: Vector3;
  8533. /**
  8534. * Define the current rotation the camera is rotating to
  8535. */
  8536. cameraRotation: Vector2;
  8537. /**
  8538. * When set, the up vector of the camera will be updated by the rotation of the camera
  8539. */
  8540. updateUpVectorFromRotation: boolean;
  8541. private _tmpQuaternion;
  8542. /**
  8543. * Define the current rotation of the camera
  8544. */
  8545. rotation: Vector3;
  8546. /**
  8547. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8548. */
  8549. rotationQuaternion: Quaternion;
  8550. /**
  8551. * Define the current speed of the camera
  8552. */
  8553. speed: number;
  8554. /**
  8555. * Add constraint to the camera to prevent it to move freely in all directions and
  8556. * around all axis.
  8557. */
  8558. noRotationConstraint: boolean;
  8559. /**
  8560. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8561. * panning
  8562. */
  8563. invertRotation: boolean;
  8564. /**
  8565. * Speed multiplier for inverse camera panning
  8566. */
  8567. inverseRotationSpeed: number;
  8568. /**
  8569. * Define the current target of the camera as an object or a position.
  8570. */
  8571. lockedTarget: any;
  8572. /** @hidden */
  8573. _currentTarget: Vector3;
  8574. /** @hidden */
  8575. _initialFocalDistance: number;
  8576. /** @hidden */
  8577. _viewMatrix: Matrix;
  8578. /** @hidden */
  8579. _camMatrix: Matrix;
  8580. /** @hidden */
  8581. _cameraTransformMatrix: Matrix;
  8582. /** @hidden */
  8583. _cameraRotationMatrix: Matrix;
  8584. /** @hidden */
  8585. _referencePoint: Vector3;
  8586. /** @hidden */
  8587. _transformedReferencePoint: Vector3;
  8588. protected _globalCurrentTarget: Vector3;
  8589. protected _globalCurrentUpVector: Vector3;
  8590. /** @hidden */
  8591. _reset: () => void;
  8592. private _defaultUp;
  8593. /**
  8594. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8595. * This is the base of the follow, arc rotate cameras and Free camera
  8596. * @see http://doc.babylonjs.com/features/cameras
  8597. * @param name Defines the name of the camera in the scene
  8598. * @param position Defines the start position of the camera in the scene
  8599. * @param scene Defines the scene the camera belongs to
  8600. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8601. */
  8602. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8603. /**
  8604. * Gets the position in front of the camera at a given distance.
  8605. * @param distance The distance from the camera we want the position to be
  8606. * @returns the position
  8607. */
  8608. getFrontPosition(distance: number): Vector3;
  8609. /** @hidden */
  8610. _getLockedTargetPosition(): Nullable<Vector3>;
  8611. private _storedPosition;
  8612. private _storedRotation;
  8613. private _storedRotationQuaternion;
  8614. /**
  8615. * Store current camera state of the camera (fov, position, rotation, etc..)
  8616. * @returns the camera
  8617. */
  8618. storeState(): Camera;
  8619. /**
  8620. * Restored camera state. You must call storeState() first
  8621. * @returns whether it was successful or not
  8622. * @hidden
  8623. */
  8624. _restoreStateValues(): boolean;
  8625. /** @hidden */
  8626. _initCache(): void;
  8627. /** @hidden */
  8628. _updateCache(ignoreParentClass?: boolean): void;
  8629. /** @hidden */
  8630. _isSynchronizedViewMatrix(): boolean;
  8631. /** @hidden */
  8632. _computeLocalCameraSpeed(): number;
  8633. /**
  8634. * Defines the target the camera should look at.
  8635. * @param target Defines the new target as a Vector or a mesh
  8636. */
  8637. setTarget(target: Vector3): void;
  8638. /**
  8639. * Return the current target position of the camera. This value is expressed in local space.
  8640. * @returns the target position
  8641. */
  8642. getTarget(): Vector3;
  8643. /** @hidden */
  8644. _decideIfNeedsToMove(): boolean;
  8645. /** @hidden */
  8646. _updatePosition(): void;
  8647. /** @hidden */
  8648. _checkInputs(): void;
  8649. protected _updateCameraRotationMatrix(): void;
  8650. /**
  8651. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8652. * @returns the current camera
  8653. */
  8654. private _rotateUpVectorWithCameraRotationMatrix;
  8655. private _cachedRotationZ;
  8656. private _cachedQuaternionRotationZ;
  8657. /** @hidden */
  8658. _getViewMatrix(): Matrix;
  8659. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8660. /**
  8661. * @hidden
  8662. */
  8663. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8664. /**
  8665. * @hidden
  8666. */
  8667. _updateRigCameras(): void;
  8668. private _getRigCamPositionAndTarget;
  8669. /**
  8670. * Gets the current object class name.
  8671. * @return the class name
  8672. */
  8673. getClassName(): string;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Gather the list of keyboard event types as constants.
  8679. */
  8680. export class KeyboardEventTypes {
  8681. /**
  8682. * The keydown event is fired when a key becomes active (pressed).
  8683. */
  8684. static readonly KEYDOWN: number;
  8685. /**
  8686. * The keyup event is fired when a key has been released.
  8687. */
  8688. static readonly KEYUP: number;
  8689. }
  8690. /**
  8691. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8692. */
  8693. export class KeyboardInfo {
  8694. /**
  8695. * Defines the type of event (KeyboardEventTypes)
  8696. */
  8697. type: number;
  8698. /**
  8699. * Defines the related dom event
  8700. */
  8701. event: KeyboardEvent;
  8702. /**
  8703. * Instantiates a new keyboard info.
  8704. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8705. * @param type Defines the type of event (KeyboardEventTypes)
  8706. * @param event Defines the related dom event
  8707. */
  8708. constructor(
  8709. /**
  8710. * Defines the type of event (KeyboardEventTypes)
  8711. */
  8712. type: number,
  8713. /**
  8714. * Defines the related dom event
  8715. */
  8716. event: KeyboardEvent);
  8717. }
  8718. /**
  8719. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8720. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8721. */
  8722. export class KeyboardInfoPre extends KeyboardInfo {
  8723. /**
  8724. * Defines the type of event (KeyboardEventTypes)
  8725. */
  8726. type: number;
  8727. /**
  8728. * Defines the related dom event
  8729. */
  8730. event: KeyboardEvent;
  8731. /**
  8732. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8733. */
  8734. skipOnPointerObservable: boolean;
  8735. /**
  8736. * Instantiates a new keyboard pre info.
  8737. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8738. * @param type Defines the type of event (KeyboardEventTypes)
  8739. * @param event Defines the related dom event
  8740. */
  8741. constructor(
  8742. /**
  8743. * Defines the type of event (KeyboardEventTypes)
  8744. */
  8745. type: number,
  8746. /**
  8747. * Defines the related dom event
  8748. */
  8749. event: KeyboardEvent);
  8750. }
  8751. }
  8752. declare module BABYLON {
  8753. /**
  8754. * Manage the keyboard inputs to control the movement of a free camera.
  8755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8756. */
  8757. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8758. /**
  8759. * Defines the camera the input is attached to.
  8760. */
  8761. camera: FreeCamera;
  8762. /**
  8763. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8764. */
  8765. keysUp: number[];
  8766. /**
  8767. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8768. */
  8769. keysUpward: number[];
  8770. /**
  8771. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8772. */
  8773. keysDown: number[];
  8774. /**
  8775. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8776. */
  8777. keysDownward: number[];
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8780. */
  8781. keysLeft: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8784. */
  8785. keysRight: number[];
  8786. private _keys;
  8787. private _onCanvasBlurObserver;
  8788. private _onKeyboardObserver;
  8789. private _engine;
  8790. private _scene;
  8791. /**
  8792. * Attach the input controls to a specific dom element to get the input from.
  8793. * @param element Defines the element the controls should be listened from
  8794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8795. */
  8796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8797. /**
  8798. * Detach the current controls from the specified dom element.
  8799. * @param element Defines the element to stop listening the inputs from
  8800. */
  8801. detachControl(element: Nullable<HTMLElement>): void;
  8802. /**
  8803. * Update the current camera state depending on the inputs that have been used this frame.
  8804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8805. */
  8806. checkInputs(): void;
  8807. /**
  8808. * Gets the class name of the current intput.
  8809. * @returns the class name
  8810. */
  8811. getClassName(): string;
  8812. /** @hidden */
  8813. _onLostFocus(): void;
  8814. /**
  8815. * Get the friendly name associated with the input class.
  8816. * @returns the input friendly name
  8817. */
  8818. getSimpleName(): string;
  8819. }
  8820. }
  8821. declare module BABYLON {
  8822. /**
  8823. * Interface describing all the common properties and methods a shadow light needs to implement.
  8824. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8825. * as well as binding the different shadow properties to the effects.
  8826. */
  8827. export interface IShadowLight extends Light {
  8828. /**
  8829. * The light id in the scene (used in scene.findLighById for instance)
  8830. */
  8831. id: string;
  8832. /**
  8833. * The position the shdow will be casted from.
  8834. */
  8835. position: Vector3;
  8836. /**
  8837. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8838. */
  8839. direction: Vector3;
  8840. /**
  8841. * The transformed position. Position of the light in world space taking parenting in account.
  8842. */
  8843. transformedPosition: Vector3;
  8844. /**
  8845. * The transformed direction. Direction of the light in world space taking parenting in account.
  8846. */
  8847. transformedDirection: Vector3;
  8848. /**
  8849. * The friendly name of the light in the scene.
  8850. */
  8851. name: string;
  8852. /**
  8853. * Defines the shadow projection clipping minimum z value.
  8854. */
  8855. shadowMinZ: number;
  8856. /**
  8857. * Defines the shadow projection clipping maximum z value.
  8858. */
  8859. shadowMaxZ: number;
  8860. /**
  8861. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8862. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8863. */
  8864. computeTransformedInformation(): boolean;
  8865. /**
  8866. * Gets the scene the light belongs to.
  8867. * @returns The scene
  8868. */
  8869. getScene(): Scene;
  8870. /**
  8871. * Callback defining a custom Projection Matrix Builder.
  8872. * This can be used to override the default projection matrix computation.
  8873. */
  8874. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8875. /**
  8876. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8877. * @param matrix The materix to updated with the projection information
  8878. * @param viewMatrix The transform matrix of the light
  8879. * @param renderList The list of mesh to render in the map
  8880. * @returns The current light
  8881. */
  8882. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8883. /**
  8884. * Gets the current depth scale used in ESM.
  8885. * @returns The scale
  8886. */
  8887. getDepthScale(): number;
  8888. /**
  8889. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8890. * @returns true if a cube texture needs to be use
  8891. */
  8892. needCube(): boolean;
  8893. /**
  8894. * Detects if the projection matrix requires to be recomputed this frame.
  8895. * @returns true if it requires to be recomputed otherwise, false.
  8896. */
  8897. needProjectionMatrixCompute(): boolean;
  8898. /**
  8899. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8900. */
  8901. forceProjectionMatrixCompute(): void;
  8902. /**
  8903. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8904. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8905. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8906. */
  8907. getShadowDirection(faceIndex?: number): Vector3;
  8908. /**
  8909. * Gets the minZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the min for
  8911. * @returns the depth min z
  8912. */
  8913. getDepthMinZ(activeCamera: Camera): number;
  8914. /**
  8915. * Gets the maxZ used for shadow according to both the scene and the light.
  8916. * @param activeCamera The camera we are returning the max for
  8917. * @returns the depth max z
  8918. */
  8919. getDepthMaxZ(activeCamera: Camera): number;
  8920. }
  8921. /**
  8922. * Base implementation IShadowLight
  8923. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8924. */
  8925. export abstract class ShadowLight extends Light implements IShadowLight {
  8926. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8927. protected _position: Vector3;
  8928. protected _setPosition(value: Vector3): void;
  8929. /**
  8930. * Sets the position the shadow will be casted from. Also use as the light position for both
  8931. * point and spot lights.
  8932. */
  8933. get position(): Vector3;
  8934. /**
  8935. * Sets the position the shadow will be casted from. Also use as the light position for both
  8936. * point and spot lights.
  8937. */
  8938. set position(value: Vector3);
  8939. protected _direction: Vector3;
  8940. protected _setDirection(value: Vector3): void;
  8941. /**
  8942. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8943. * Also use as the light direction on spot and directional lights.
  8944. */
  8945. get direction(): Vector3;
  8946. /**
  8947. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8948. * Also use as the light direction on spot and directional lights.
  8949. */
  8950. set direction(value: Vector3);
  8951. protected _shadowMinZ: number;
  8952. /**
  8953. * Gets the shadow projection clipping minimum z value.
  8954. */
  8955. get shadowMinZ(): number;
  8956. /**
  8957. * Sets the shadow projection clipping minimum z value.
  8958. */
  8959. set shadowMinZ(value: number);
  8960. protected _shadowMaxZ: number;
  8961. /**
  8962. * Sets the shadow projection clipping maximum z value.
  8963. */
  8964. get shadowMaxZ(): number;
  8965. /**
  8966. * Gets the shadow projection clipping maximum z value.
  8967. */
  8968. set shadowMaxZ(value: number);
  8969. /**
  8970. * Callback defining a custom Projection Matrix Builder.
  8971. * This can be used to override the default projection matrix computation.
  8972. */
  8973. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8974. /**
  8975. * The transformed position. Position of the light in world space taking parenting in account.
  8976. */
  8977. transformedPosition: Vector3;
  8978. /**
  8979. * The transformed direction. Direction of the light in world space taking parenting in account.
  8980. */
  8981. transformedDirection: Vector3;
  8982. private _needProjectionMatrixCompute;
  8983. /**
  8984. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8985. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8986. */
  8987. computeTransformedInformation(): boolean;
  8988. /**
  8989. * Return the depth scale used for the shadow map.
  8990. * @returns the depth scale.
  8991. */
  8992. getDepthScale(): number;
  8993. /**
  8994. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8995. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8996. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8997. */
  8998. getShadowDirection(faceIndex?: number): Vector3;
  8999. /**
  9000. * Returns the ShadowLight absolute position in the World.
  9001. * @returns the position vector in world space
  9002. */
  9003. getAbsolutePosition(): Vector3;
  9004. /**
  9005. * Sets the ShadowLight direction toward the passed target.
  9006. * @param target The point to target in local space
  9007. * @returns the updated ShadowLight direction
  9008. */
  9009. setDirectionToTarget(target: Vector3): Vector3;
  9010. /**
  9011. * Returns the light rotation in euler definition.
  9012. * @returns the x y z rotation in local space.
  9013. */
  9014. getRotation(): Vector3;
  9015. /**
  9016. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9017. * @returns true if a cube texture needs to be use
  9018. */
  9019. needCube(): boolean;
  9020. /**
  9021. * Detects if the projection matrix requires to be recomputed this frame.
  9022. * @returns true if it requires to be recomputed otherwise, false.
  9023. */
  9024. needProjectionMatrixCompute(): boolean;
  9025. /**
  9026. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9027. */
  9028. forceProjectionMatrixCompute(): void;
  9029. /** @hidden */
  9030. _initCache(): void;
  9031. /** @hidden */
  9032. _isSynchronized(): boolean;
  9033. /**
  9034. * Computes the world matrix of the node
  9035. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9036. * @returns the world matrix
  9037. */
  9038. computeWorldMatrix(force?: boolean): Matrix;
  9039. /**
  9040. * Gets the minZ used for shadow according to both the scene and the light.
  9041. * @param activeCamera The camera we are returning the min for
  9042. * @returns the depth min z
  9043. */
  9044. getDepthMinZ(activeCamera: Camera): number;
  9045. /**
  9046. * Gets the maxZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the max for
  9048. * @returns the depth max z
  9049. */
  9050. getDepthMaxZ(activeCamera: Camera): number;
  9051. /**
  9052. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9053. * @param matrix The materix to updated with the projection information
  9054. * @param viewMatrix The transform matrix of the light
  9055. * @param renderList The list of mesh to render in the map
  9056. * @returns The current light
  9057. */
  9058. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9059. }
  9060. }
  9061. declare module BABYLON {
  9062. /**
  9063. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9064. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9065. */
  9066. export class EffectFallbacks implements IEffectFallbacks {
  9067. private _defines;
  9068. private _currentRank;
  9069. private _maxRank;
  9070. private _mesh;
  9071. /**
  9072. * Removes the fallback from the bound mesh.
  9073. */
  9074. unBindMesh(): void;
  9075. /**
  9076. * Adds a fallback on the specified property.
  9077. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9078. * @param define The name of the define in the shader
  9079. */
  9080. addFallback(rank: number, define: string): void;
  9081. /**
  9082. * Sets the mesh to use CPU skinning when needing to fallback.
  9083. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9084. * @param mesh The mesh to use the fallbacks.
  9085. */
  9086. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9087. /**
  9088. * Checks to see if more fallbacks are still availible.
  9089. */
  9090. get hasMoreFallbacks(): boolean;
  9091. /**
  9092. * Removes the defines that should be removed when falling back.
  9093. * @param currentDefines defines the current define statements for the shader.
  9094. * @param effect defines the current effect we try to compile
  9095. * @returns The resulting defines with defines of the current rank removed.
  9096. */
  9097. reduce(currentDefines: string, effect: Effect): string;
  9098. }
  9099. }
  9100. declare module BABYLON {
  9101. /**
  9102. * "Static Class" containing the most commonly used helper while dealing with material for
  9103. * rendering purpose.
  9104. *
  9105. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9106. *
  9107. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9108. */
  9109. export class MaterialHelper {
  9110. /**
  9111. * Bind the current view position to an effect.
  9112. * @param effect The effect to be bound
  9113. * @param scene The scene the eyes position is used from
  9114. */
  9115. static BindEyePosition(effect: Effect, scene: Scene): void;
  9116. /**
  9117. * Helps preparing the defines values about the UVs in used in the effect.
  9118. * UVs are shared as much as we can accross channels in the shaders.
  9119. * @param texture The texture we are preparing the UVs for
  9120. * @param defines The defines to update
  9121. * @param key The channel key "diffuse", "specular"... used in the shader
  9122. */
  9123. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9124. /**
  9125. * Binds a texture matrix value to its corrsponding uniform
  9126. * @param texture The texture to bind the matrix for
  9127. * @param uniformBuffer The uniform buffer receivin the data
  9128. * @param key The channel key "diffuse", "specular"... used in the shader
  9129. */
  9130. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9131. /**
  9132. * Gets the current status of the fog (should it be enabled?)
  9133. * @param mesh defines the mesh to evaluate for fog support
  9134. * @param scene defines the hosting scene
  9135. * @returns true if fog must be enabled
  9136. */
  9137. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9138. /**
  9139. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9140. * @param mesh defines the current mesh
  9141. * @param scene defines the current scene
  9142. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9143. * @param pointsCloud defines if point cloud rendering has to be turned on
  9144. * @param fogEnabled defines if fog has to be turned on
  9145. * @param alphaTest defines if alpha testing has to be turned on
  9146. * @param defines defines the current list of defines
  9147. */
  9148. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9149. /**
  9150. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9151. * @param scene defines the current scene
  9152. * @param engine defines the current engine
  9153. * @param defines specifies the list of active defines
  9154. * @param useInstances defines if instances have to be turned on
  9155. * @param useClipPlane defines if clip plane have to be turned on
  9156. */
  9157. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9158. /**
  9159. * Prepares the defines for bones
  9160. * @param mesh The mesh containing the geometry data we will draw
  9161. * @param defines The defines to update
  9162. */
  9163. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9164. /**
  9165. * Prepares the defines for morph targets
  9166. * @param mesh The mesh containing the geometry data we will draw
  9167. * @param defines The defines to update
  9168. */
  9169. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9170. /**
  9171. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9172. * @param mesh The mesh containing the geometry data we will draw
  9173. * @param defines The defines to update
  9174. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9175. * @param useBones Precise whether bones should be used or not (override mesh info)
  9176. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9177. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9178. * @returns false if defines are considered not dirty and have not been checked
  9179. */
  9180. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9181. /**
  9182. * Prepares the defines related to multiview
  9183. * @param scene The scene we are intending to draw
  9184. * @param defines The defines to update
  9185. */
  9186. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9187. /**
  9188. * Prepares the defines related to the light information passed in parameter
  9189. * @param scene The scene we are intending to draw
  9190. * @param mesh The mesh the effect is compiling for
  9191. * @param light The light the effect is compiling for
  9192. * @param lightIndex The index of the light
  9193. * @param defines The defines to update
  9194. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9195. * @param state Defines the current state regarding what is needed (normals, etc...)
  9196. */
  9197. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9198. needNormals: boolean;
  9199. needRebuild: boolean;
  9200. shadowEnabled: boolean;
  9201. specularEnabled: boolean;
  9202. lightmapMode: boolean;
  9203. }): void;
  9204. /**
  9205. * Prepares the defines related to the light information passed in parameter
  9206. * @param scene The scene we are intending to draw
  9207. * @param mesh The mesh the effect is compiling for
  9208. * @param defines The defines to update
  9209. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9210. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9211. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9212. * @returns true if normals will be required for the rest of the effect
  9213. */
  9214. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9215. /**
  9216. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9217. * @param lightIndex defines the light index
  9218. * @param uniformsList The uniform list
  9219. * @param samplersList The sampler list
  9220. * @param projectedLightTexture defines if projected texture must be used
  9221. * @param uniformBuffersList defines an optional list of uniform buffers
  9222. */
  9223. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9224. /**
  9225. * Prepares the uniforms and samplers list to be used in the effect
  9226. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9227. * @param samplersList The sampler list
  9228. * @param defines The defines helping in the list generation
  9229. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9230. */
  9231. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9232. /**
  9233. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9234. * @param defines The defines to update while falling back
  9235. * @param fallbacks The authorized effect fallbacks
  9236. * @param maxSimultaneousLights The maximum number of lights allowed
  9237. * @param rank the current rank of the Effect
  9238. * @returns The newly affected rank
  9239. */
  9240. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9241. private static _TmpMorphInfluencers;
  9242. /**
  9243. * Prepares the list of attributes required for morph targets according to the effect defines.
  9244. * @param attribs The current list of supported attribs
  9245. * @param mesh The mesh to prepare the morph targets attributes for
  9246. * @param influencers The number of influencers
  9247. */
  9248. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9249. /**
  9250. * Prepares the list of attributes required for morph targets according to the effect defines.
  9251. * @param attribs The current list of supported attribs
  9252. * @param mesh The mesh to prepare the morph targets attributes for
  9253. * @param defines The current Defines of the effect
  9254. */
  9255. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9256. /**
  9257. * Prepares the list of attributes required for bones according to the effect defines.
  9258. * @param attribs The current list of supported attribs
  9259. * @param mesh The mesh to prepare the bones attributes for
  9260. * @param defines The current Defines of the effect
  9261. * @param fallbacks The current efffect fallback strategy
  9262. */
  9263. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9264. /**
  9265. * Check and prepare the list of attributes required for instances according to the effect defines.
  9266. * @param attribs The current list of supported attribs
  9267. * @param defines The current MaterialDefines of the effect
  9268. */
  9269. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9270. /**
  9271. * Add the list of attributes required for instances to the attribs array.
  9272. * @param attribs The current list of supported attribs
  9273. */
  9274. static PushAttributesForInstances(attribs: string[]): void;
  9275. /**
  9276. * Binds the light information to the effect.
  9277. * @param light The light containing the generator
  9278. * @param effect The effect we are binding the data to
  9279. * @param lightIndex The light index in the effect used to render
  9280. */
  9281. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9282. /**
  9283. * Binds the lights information from the scene to the effect for the given mesh.
  9284. * @param light Light to bind
  9285. * @param lightIndex Light index
  9286. * @param scene The scene where the light belongs to
  9287. * @param effect The effect we are binding the data to
  9288. * @param useSpecular Defines if specular is supported
  9289. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9290. */
  9291. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9292. /**
  9293. * Binds the lights information from the scene to the effect for the given mesh.
  9294. * @param scene The scene the lights belongs to
  9295. * @param mesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. * @param defines The generated defines for the effect
  9298. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9299. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9300. */
  9301. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9302. private static _tempFogColor;
  9303. /**
  9304. * Binds the fog information from the scene to the effect for the given mesh.
  9305. * @param scene The scene the lights belongs to
  9306. * @param mesh The mesh we are binding the information to render
  9307. * @param effect The effect we are binding the data to
  9308. * @param linearSpace Defines if the fog effect is applied in linear space
  9309. */
  9310. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9311. /**
  9312. * Binds the bones information from the mesh to the effect.
  9313. * @param mesh The mesh we are binding the information to render
  9314. * @param effect The effect we are binding the data to
  9315. */
  9316. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9317. /**
  9318. * Binds the morph targets information from the mesh to the effect.
  9319. * @param abstractMesh The mesh we are binding the information to render
  9320. * @param effect The effect we are binding the data to
  9321. */
  9322. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9323. /**
  9324. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9325. * @param defines The generated defines used in the effect
  9326. * @param effect The effect we are binding the data to
  9327. * @param scene The scene we are willing to render with logarithmic scale for
  9328. */
  9329. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9330. /**
  9331. * Binds the clip plane information from the scene to the effect.
  9332. * @param scene The scene the clip plane information are extracted from
  9333. * @param effect The effect we are binding the data to
  9334. */
  9335. static BindClipPlane(effect: Effect, scene: Scene): void;
  9336. }
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var packingFunctions: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var clipPlaneFragmentDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var clipPlaneFragment: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var clipPlaneVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var morphTargetsVertex: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var instancesVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /** @hidden */
  9424. export var bonesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module BABYLON {
  9430. /** @hidden */
  9431. export var clipPlaneVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module BABYLON {
  9437. /** @hidden */
  9438. export var shadowMapVertexShader: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module BABYLON {
  9444. /** @hidden */
  9445. export var depthBoxBlurPixelShader: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module BABYLON {
  9451. /**
  9452. * Class representing a ray with position and direction
  9453. */
  9454. export class Ray {
  9455. /** origin point */
  9456. origin: Vector3;
  9457. /** direction */
  9458. direction: Vector3;
  9459. /** length of the ray */
  9460. length: number;
  9461. private static readonly TmpVector3;
  9462. private _tmpRay;
  9463. /**
  9464. * Creates a new ray
  9465. * @param origin origin point
  9466. * @param direction direction
  9467. * @param length length of the ray
  9468. */
  9469. constructor(
  9470. /** origin point */
  9471. origin: Vector3,
  9472. /** direction */
  9473. direction: Vector3,
  9474. /** length of the ray */
  9475. length?: number);
  9476. /**
  9477. * Checks if the ray intersects a box
  9478. * @param minimum bound of the box
  9479. * @param maximum bound of the box
  9480. * @param intersectionTreshold extra extend to be added to the box in all direction
  9481. * @returns if the box was hit
  9482. */
  9483. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9484. /**
  9485. * Checks if the ray intersects a box
  9486. * @param box the bounding box to check
  9487. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9488. * @returns if the box was hit
  9489. */
  9490. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9491. /**
  9492. * If the ray hits a sphere
  9493. * @param sphere the bounding sphere to check
  9494. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9495. * @returns true if it hits the sphere
  9496. */
  9497. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9498. /**
  9499. * If the ray hits a triange
  9500. * @param vertex0 triangle vertex
  9501. * @param vertex1 triangle vertex
  9502. * @param vertex2 triangle vertex
  9503. * @returns intersection information if hit
  9504. */
  9505. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9506. /**
  9507. * Checks if ray intersects a plane
  9508. * @param plane the plane to check
  9509. * @returns the distance away it was hit
  9510. */
  9511. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9512. /**
  9513. * Calculate the intercept of a ray on a given axis
  9514. * @param axis to check 'x' | 'y' | 'z'
  9515. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9516. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9517. */
  9518. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9519. /**
  9520. * Checks if ray intersects a mesh
  9521. * @param mesh the mesh to check
  9522. * @param fastCheck if only the bounding box should checked
  9523. * @returns picking info of the intersecton
  9524. */
  9525. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9526. /**
  9527. * Checks if ray intersects a mesh
  9528. * @param meshes the meshes to check
  9529. * @param fastCheck if only the bounding box should checked
  9530. * @param results array to store result in
  9531. * @returns Array of picking infos
  9532. */
  9533. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9534. private _comparePickingInfo;
  9535. private static smallnum;
  9536. private static rayl;
  9537. /**
  9538. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9539. * @param sega the first point of the segment to test the intersection against
  9540. * @param segb the second point of the segment to test the intersection against
  9541. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9542. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9543. */
  9544. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9545. /**
  9546. * Update the ray from viewport position
  9547. * @param x position
  9548. * @param y y position
  9549. * @param viewportWidth viewport width
  9550. * @param viewportHeight viewport height
  9551. * @param world world matrix
  9552. * @param view view matrix
  9553. * @param projection projection matrix
  9554. * @returns this ray updated
  9555. */
  9556. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9557. /**
  9558. * Creates a ray with origin and direction of 0,0,0
  9559. * @returns the new ray
  9560. */
  9561. static Zero(): Ray;
  9562. /**
  9563. * Creates a new ray from screen space and viewport
  9564. * @param x position
  9565. * @param y y position
  9566. * @param viewportWidth viewport width
  9567. * @param viewportHeight viewport height
  9568. * @param world world matrix
  9569. * @param view view matrix
  9570. * @param projection projection matrix
  9571. * @returns new ray
  9572. */
  9573. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9574. /**
  9575. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9576. * transformed to the given world matrix.
  9577. * @param origin The origin point
  9578. * @param end The end point
  9579. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9580. * @returns the new ray
  9581. */
  9582. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9583. /**
  9584. * Transforms a ray by a matrix
  9585. * @param ray ray to transform
  9586. * @param matrix matrix to apply
  9587. * @returns the resulting new ray
  9588. */
  9589. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9590. /**
  9591. * Transforms a ray by a matrix
  9592. * @param ray ray to transform
  9593. * @param matrix matrix to apply
  9594. * @param result ray to store result in
  9595. */
  9596. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9597. /**
  9598. * Unproject a ray from screen space to object space
  9599. * @param sourceX defines the screen space x coordinate to use
  9600. * @param sourceY defines the screen space y coordinate to use
  9601. * @param viewportWidth defines the current width of the viewport
  9602. * @param viewportHeight defines the current height of the viewport
  9603. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9604. * @param view defines the view matrix to use
  9605. * @param projection defines the projection matrix to use
  9606. */
  9607. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9608. }
  9609. /**
  9610. * Type used to define predicate used to select faces when a mesh intersection is detected
  9611. */
  9612. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9613. interface Scene {
  9614. /** @hidden */
  9615. _tempPickingRay: Nullable<Ray>;
  9616. /** @hidden */
  9617. _cachedRayForTransform: Ray;
  9618. /** @hidden */
  9619. _pickWithRayInverseMatrix: Matrix;
  9620. /** @hidden */
  9621. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9622. /** @hidden */
  9623. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9624. }
  9625. }
  9626. declare module BABYLON {
  9627. /**
  9628. * Groups all the scene component constants in one place to ease maintenance.
  9629. * @hidden
  9630. */
  9631. export class SceneComponentConstants {
  9632. static readonly NAME_EFFECTLAYER: string;
  9633. static readonly NAME_LAYER: string;
  9634. static readonly NAME_LENSFLARESYSTEM: string;
  9635. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9636. static readonly NAME_PARTICLESYSTEM: string;
  9637. static readonly NAME_GAMEPAD: string;
  9638. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9639. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9640. static readonly NAME_DEPTHRENDERER: string;
  9641. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9642. static readonly NAME_SPRITE: string;
  9643. static readonly NAME_OUTLINERENDERER: string;
  9644. static readonly NAME_PROCEDURALTEXTURE: string;
  9645. static readonly NAME_SHADOWGENERATOR: string;
  9646. static readonly NAME_OCTREE: string;
  9647. static readonly NAME_PHYSICSENGINE: string;
  9648. static readonly NAME_AUDIO: string;
  9649. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9650. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9651. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9652. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9653. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9654. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9655. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9656. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9657. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9658. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9659. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9660. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9661. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9662. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9663. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9664. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9665. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9666. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9667. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9668. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9669. static readonly STEP_AFTERRENDER_AUDIO: number;
  9670. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9671. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9672. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9673. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9674. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9675. static readonly STEP_POINTERMOVE_SPRITE: number;
  9676. static readonly STEP_POINTERDOWN_SPRITE: number;
  9677. static readonly STEP_POINTERUP_SPRITE: number;
  9678. }
  9679. /**
  9680. * This represents a scene component.
  9681. *
  9682. * This is used to decouple the dependency the scene is having on the different workloads like
  9683. * layers, post processes...
  9684. */
  9685. export interface ISceneComponent {
  9686. /**
  9687. * The name of the component. Each component must have a unique name.
  9688. */
  9689. name: string;
  9690. /**
  9691. * The scene the component belongs to.
  9692. */
  9693. scene: Scene;
  9694. /**
  9695. * Register the component to one instance of a scene.
  9696. */
  9697. register(): void;
  9698. /**
  9699. * Rebuilds the elements related to this component in case of
  9700. * context lost for instance.
  9701. */
  9702. rebuild(): void;
  9703. /**
  9704. * Disposes the component and the associated ressources.
  9705. */
  9706. dispose(): void;
  9707. }
  9708. /**
  9709. * This represents a SERIALIZABLE scene component.
  9710. *
  9711. * This extends Scene Component to add Serialization methods on top.
  9712. */
  9713. export interface ISceneSerializableComponent extends ISceneComponent {
  9714. /**
  9715. * Adds all the elements from the container to the scene
  9716. * @param container the container holding the elements
  9717. */
  9718. addFromContainer(container: AbstractScene): void;
  9719. /**
  9720. * Removes all the elements in the container from the scene
  9721. * @param container contains the elements to remove
  9722. * @param dispose if the removed element should be disposed (default: false)
  9723. */
  9724. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9725. /**
  9726. * Serializes the component data to the specified json object
  9727. * @param serializationObject The object to serialize to
  9728. */
  9729. serialize(serializationObject: any): void;
  9730. }
  9731. /**
  9732. * Strong typing of a Mesh related stage step action
  9733. */
  9734. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9735. /**
  9736. * Strong typing of a Evaluate Sub Mesh related stage step action
  9737. */
  9738. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9739. /**
  9740. * Strong typing of a Active Mesh related stage step action
  9741. */
  9742. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9743. /**
  9744. * Strong typing of a Camera related stage step action
  9745. */
  9746. export type CameraStageAction = (camera: Camera) => void;
  9747. /**
  9748. * Strong typing of a Camera Frame buffer related stage step action
  9749. */
  9750. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9751. /**
  9752. * Strong typing of a Render Target related stage step action
  9753. */
  9754. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9755. /**
  9756. * Strong typing of a RenderingGroup related stage step action
  9757. */
  9758. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9759. /**
  9760. * Strong typing of a Mesh Render related stage step action
  9761. */
  9762. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9763. /**
  9764. * Strong typing of a simple stage step action
  9765. */
  9766. export type SimpleStageAction = () => void;
  9767. /**
  9768. * Strong typing of a render target action.
  9769. */
  9770. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9771. /**
  9772. * Strong typing of a pointer move action.
  9773. */
  9774. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9775. /**
  9776. * Strong typing of a pointer up/down action.
  9777. */
  9778. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9779. /**
  9780. * Representation of a stage in the scene (Basically a list of ordered steps)
  9781. * @hidden
  9782. */
  9783. export class Stage<T extends Function> extends Array<{
  9784. index: number;
  9785. component: ISceneComponent;
  9786. action: T;
  9787. }> {
  9788. /**
  9789. * Hide ctor from the rest of the world.
  9790. * @param items The items to add.
  9791. */
  9792. private constructor();
  9793. /**
  9794. * Creates a new Stage.
  9795. * @returns A new instance of a Stage
  9796. */
  9797. static Create<T extends Function>(): Stage<T>;
  9798. /**
  9799. * Registers a step in an ordered way in the targeted stage.
  9800. * @param index Defines the position to register the step in
  9801. * @param component Defines the component attached to the step
  9802. * @param action Defines the action to launch during the step
  9803. */
  9804. registerStep(index: number, component: ISceneComponent, action: T): void;
  9805. /**
  9806. * Clears all the steps from the stage.
  9807. */
  9808. clear(): void;
  9809. }
  9810. }
  9811. declare module BABYLON {
  9812. interface Scene {
  9813. /** @hidden */
  9814. _pointerOverSprite: Nullable<Sprite>;
  9815. /** @hidden */
  9816. _pickedDownSprite: Nullable<Sprite>;
  9817. /** @hidden */
  9818. _tempSpritePickingRay: Nullable<Ray>;
  9819. /**
  9820. * All of the sprite managers added to this scene
  9821. * @see http://doc.babylonjs.com/babylon101/sprites
  9822. */
  9823. spriteManagers: Array<ISpriteManager>;
  9824. /**
  9825. * An event triggered when sprites rendering is about to start
  9826. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9827. */
  9828. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9829. /**
  9830. * An event triggered when sprites rendering is done
  9831. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9832. */
  9833. onAfterSpritesRenderingObservable: Observable<Scene>;
  9834. /** @hidden */
  9835. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9836. /** Launch a ray to try to pick a sprite in the scene
  9837. * @param x position on screen
  9838. * @param y position on screen
  9839. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9840. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9841. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9842. * @returns a PickingInfo
  9843. */
  9844. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9845. /** Use the given ray to pick a sprite in the scene
  9846. * @param ray The ray (in world space) to use to pick meshes
  9847. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9848. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9849. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9850. * @returns a PickingInfo
  9851. */
  9852. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9853. /** @hidden */
  9854. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9855. /** Launch a ray to try to pick sprites in the scene
  9856. * @param x position on screen
  9857. * @param y position on screen
  9858. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9859. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9860. * @returns a PickingInfo array
  9861. */
  9862. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9863. /** Use the given ray to pick sprites in the scene
  9864. * @param ray The ray (in world space) to use to pick meshes
  9865. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9866. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9867. * @returns a PickingInfo array
  9868. */
  9869. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9870. /**
  9871. * Force the sprite under the pointer
  9872. * @param sprite defines the sprite to use
  9873. */
  9874. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9875. /**
  9876. * Gets the sprite under the pointer
  9877. * @returns a Sprite or null if no sprite is under the pointer
  9878. */
  9879. getPointerOverSprite(): Nullable<Sprite>;
  9880. }
  9881. /**
  9882. * Defines the sprite scene component responsible to manage sprites
  9883. * in a given scene.
  9884. */
  9885. export class SpriteSceneComponent implements ISceneComponent {
  9886. /**
  9887. * The component name helpfull to identify the component in the list of scene components.
  9888. */
  9889. readonly name: string;
  9890. /**
  9891. * The scene the component belongs to.
  9892. */
  9893. scene: Scene;
  9894. /** @hidden */
  9895. private _spritePredicate;
  9896. /**
  9897. * Creates a new instance of the component for the given scene
  9898. * @param scene Defines the scene to register the component in
  9899. */
  9900. constructor(scene: Scene);
  9901. /**
  9902. * Registers the component in a given scene
  9903. */
  9904. register(): void;
  9905. /**
  9906. * Rebuilds the elements related to this component in case of
  9907. * context lost for instance.
  9908. */
  9909. rebuild(): void;
  9910. /**
  9911. * Disposes the component and the associated ressources.
  9912. */
  9913. dispose(): void;
  9914. private _pickSpriteButKeepRay;
  9915. private _pointerMove;
  9916. private _pointerDown;
  9917. private _pointerUp;
  9918. }
  9919. }
  9920. declare module BABYLON {
  9921. /** @hidden */
  9922. export var fogFragmentDeclaration: {
  9923. name: string;
  9924. shader: string;
  9925. };
  9926. }
  9927. declare module BABYLON {
  9928. /** @hidden */
  9929. export var fogFragment: {
  9930. name: string;
  9931. shader: string;
  9932. };
  9933. }
  9934. declare module BABYLON {
  9935. /** @hidden */
  9936. export var spritesPixelShader: {
  9937. name: string;
  9938. shader: string;
  9939. };
  9940. }
  9941. declare module BABYLON {
  9942. /** @hidden */
  9943. export var fogVertexDeclaration: {
  9944. name: string;
  9945. shader: string;
  9946. };
  9947. }
  9948. declare module BABYLON {
  9949. /** @hidden */
  9950. export var spritesVertexShader: {
  9951. name: string;
  9952. shader: string;
  9953. };
  9954. }
  9955. declare module BABYLON {
  9956. /**
  9957. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9958. */
  9959. export interface ISpriteManager extends IDisposable {
  9960. /**
  9961. * Restricts the camera to viewing objects with the same layerMask.
  9962. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9963. */
  9964. layerMask: number;
  9965. /**
  9966. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9967. */
  9968. isPickable: boolean;
  9969. /**
  9970. * Specifies the rendering group id for this mesh (0 by default)
  9971. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9972. */
  9973. renderingGroupId: number;
  9974. /**
  9975. * Defines the list of sprites managed by the manager.
  9976. */
  9977. sprites: Array<Sprite>;
  9978. /**
  9979. * Tests the intersection of a sprite with a specific ray.
  9980. * @param ray The ray we are sending to test the collision
  9981. * @param camera The camera space we are sending rays in
  9982. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9983. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9984. * @returns picking info or null.
  9985. */
  9986. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9987. /**
  9988. * Intersects the sprites with a ray
  9989. * @param ray defines the ray to intersect with
  9990. * @param camera defines the current active camera
  9991. * @param predicate defines a predicate used to select candidate sprites
  9992. * @returns null if no hit or a PickingInfo array
  9993. */
  9994. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9995. /**
  9996. * Renders the list of sprites on screen.
  9997. */
  9998. render(): void;
  9999. }
  10000. /**
  10001. * Class used to manage multiple sprites on the same spritesheet
  10002. * @see http://doc.babylonjs.com/babylon101/sprites
  10003. */
  10004. export class SpriteManager implements ISpriteManager {
  10005. /** defines the manager's name */
  10006. name: string;
  10007. /** Gets the list of sprites */
  10008. sprites: Sprite[];
  10009. /** Gets or sets the rendering group id (0 by default) */
  10010. renderingGroupId: number;
  10011. /** Gets or sets camera layer mask */
  10012. layerMask: number;
  10013. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10014. fogEnabled: boolean;
  10015. /** Gets or sets a boolean indicating if the sprites are pickable */
  10016. isPickable: boolean;
  10017. /** Defines the default width of a cell in the spritesheet */
  10018. cellWidth: number;
  10019. /** Defines the default height of a cell in the spritesheet */
  10020. cellHeight: number;
  10021. /** Associative array from JSON sprite data file */
  10022. private _cellData;
  10023. /** Array of sprite names from JSON sprite data file */
  10024. private _spriteMap;
  10025. /** True when packed cell data from JSON file is ready*/
  10026. private _packedAndReady;
  10027. /**
  10028. * An event triggered when the manager is disposed.
  10029. */
  10030. onDisposeObservable: Observable<SpriteManager>;
  10031. private _onDisposeObserver;
  10032. /**
  10033. * Callback called when the manager is disposed
  10034. */
  10035. set onDispose(callback: () => void);
  10036. private _capacity;
  10037. private _fromPacked;
  10038. private _spriteTexture;
  10039. private _epsilon;
  10040. private _scene;
  10041. private _vertexData;
  10042. private _buffer;
  10043. private _vertexBuffers;
  10044. private _indexBuffer;
  10045. private _effectBase;
  10046. private _effectFog;
  10047. /**
  10048. * Gets or sets the spritesheet texture
  10049. */
  10050. get texture(): Texture;
  10051. set texture(value: Texture);
  10052. private _blendMode;
  10053. /**
  10054. * Blend mode use to render the particle, it can be any of
  10055. * the static Constants.ALPHA_x properties provided in this class.
  10056. * Default value is Constants.ALPHA_COMBINE
  10057. */
  10058. get blendMode(): number;
  10059. set blendMode(blendMode: number);
  10060. /** Disables writing to the depth buffer when rendering the sprites.
  10061. * It can be handy to disable depth writing when using textures without alpha channel
  10062. * and setting some specific blend modes.
  10063. */
  10064. disableDepthWrite: boolean;
  10065. /**
  10066. * Creates a new sprite manager
  10067. * @param name defines the manager's name
  10068. * @param imgUrl defines the sprite sheet url
  10069. * @param capacity defines the maximum allowed number of sprites
  10070. * @param cellSize defines the size of a sprite cell
  10071. * @param scene defines the hosting scene
  10072. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10073. * @param samplingMode defines the smapling mode to use with spritesheet
  10074. * @param fromPacked set to false; do not alter
  10075. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10076. */
  10077. constructor(
  10078. /** defines the manager's name */
  10079. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10080. private _makePacked;
  10081. private _appendSpriteVertex;
  10082. /**
  10083. * Intersects the sprites with a ray
  10084. * @param ray defines the ray to intersect with
  10085. * @param camera defines the current active camera
  10086. * @param predicate defines a predicate used to select candidate sprites
  10087. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10088. * @returns null if no hit or a PickingInfo
  10089. */
  10090. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10091. /**
  10092. * Intersects the sprites with a ray
  10093. * @param ray defines the ray to intersect with
  10094. * @param camera defines the current active camera
  10095. * @param predicate defines a predicate used to select candidate sprites
  10096. * @returns null if no hit or a PickingInfo array
  10097. */
  10098. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10099. /**
  10100. * Render all child sprites
  10101. */
  10102. render(): void;
  10103. /**
  10104. * Release associated resources
  10105. */
  10106. dispose(): void;
  10107. }
  10108. }
  10109. declare module BABYLON {
  10110. /** Interface used by value gradients (color, factor, ...) */
  10111. export interface IValueGradient {
  10112. /**
  10113. * Gets or sets the gradient value (between 0 and 1)
  10114. */
  10115. gradient: number;
  10116. }
  10117. /** Class used to store color4 gradient */
  10118. export class ColorGradient implements IValueGradient {
  10119. /**
  10120. * Gets or sets the gradient value (between 0 and 1)
  10121. */
  10122. gradient: number;
  10123. /**
  10124. * Gets or sets first associated color
  10125. */
  10126. color1: Color4;
  10127. /**
  10128. * Gets or sets second associated color
  10129. */
  10130. color2?: Color4 | undefined;
  10131. /**
  10132. * Creates a new color4 gradient
  10133. * @param gradient gets or sets the gradient value (between 0 and 1)
  10134. * @param color1 gets or sets first associated color
  10135. * @param color2 gets or sets first second color
  10136. */
  10137. constructor(
  10138. /**
  10139. * Gets or sets the gradient value (between 0 and 1)
  10140. */
  10141. gradient: number,
  10142. /**
  10143. * Gets or sets first associated color
  10144. */
  10145. color1: Color4,
  10146. /**
  10147. * Gets or sets second associated color
  10148. */
  10149. color2?: Color4 | undefined);
  10150. /**
  10151. * Will get a color picked randomly between color1 and color2.
  10152. * If color2 is undefined then color1 will be used
  10153. * @param result defines the target Color4 to store the result in
  10154. */
  10155. getColorToRef(result: Color4): void;
  10156. }
  10157. /** Class used to store color 3 gradient */
  10158. export class Color3Gradient implements IValueGradient {
  10159. /**
  10160. * Gets or sets the gradient value (between 0 and 1)
  10161. */
  10162. gradient: number;
  10163. /**
  10164. * Gets or sets the associated color
  10165. */
  10166. color: Color3;
  10167. /**
  10168. * Creates a new color3 gradient
  10169. * @param gradient gets or sets the gradient value (between 0 and 1)
  10170. * @param color gets or sets associated color
  10171. */
  10172. constructor(
  10173. /**
  10174. * Gets or sets the gradient value (between 0 and 1)
  10175. */
  10176. gradient: number,
  10177. /**
  10178. * Gets or sets the associated color
  10179. */
  10180. color: Color3);
  10181. }
  10182. /** Class used to store factor gradient */
  10183. export class FactorGradient implements IValueGradient {
  10184. /**
  10185. * Gets or sets the gradient value (between 0 and 1)
  10186. */
  10187. gradient: number;
  10188. /**
  10189. * Gets or sets first associated factor
  10190. */
  10191. factor1: number;
  10192. /**
  10193. * Gets or sets second associated factor
  10194. */
  10195. factor2?: number | undefined;
  10196. /**
  10197. * Creates a new factor gradient
  10198. * @param gradient gets or sets the gradient value (between 0 and 1)
  10199. * @param factor1 gets or sets first associated factor
  10200. * @param factor2 gets or sets second associated factor
  10201. */
  10202. constructor(
  10203. /**
  10204. * Gets or sets the gradient value (between 0 and 1)
  10205. */
  10206. gradient: number,
  10207. /**
  10208. * Gets or sets first associated factor
  10209. */
  10210. factor1: number,
  10211. /**
  10212. * Gets or sets second associated factor
  10213. */
  10214. factor2?: number | undefined);
  10215. /**
  10216. * Will get a number picked randomly between factor1 and factor2.
  10217. * If factor2 is undefined then factor1 will be used
  10218. * @returns the picked number
  10219. */
  10220. getFactor(): number;
  10221. }
  10222. /**
  10223. * Helper used to simplify some generic gradient tasks
  10224. */
  10225. export class GradientHelper {
  10226. /**
  10227. * Gets the current gradient from an array of IValueGradient
  10228. * @param ratio defines the current ratio to get
  10229. * @param gradients defines the array of IValueGradient
  10230. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10231. */
  10232. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10233. }
  10234. }
  10235. declare module BABYLON {
  10236. /**
  10237. * Interface for the size containing width and height
  10238. */
  10239. export interface ISize {
  10240. /**
  10241. * Width
  10242. */
  10243. width: number;
  10244. /**
  10245. * Heighht
  10246. */
  10247. height: number;
  10248. }
  10249. /**
  10250. * Size containing widht and height
  10251. */
  10252. export class Size implements ISize {
  10253. /**
  10254. * Width
  10255. */
  10256. width: number;
  10257. /**
  10258. * Height
  10259. */
  10260. height: number;
  10261. /**
  10262. * Creates a Size object from the given width and height (floats).
  10263. * @param width width of the new size
  10264. * @param height height of the new size
  10265. */
  10266. constructor(width: number, height: number);
  10267. /**
  10268. * Returns a string with the Size width and height
  10269. * @returns a string with the Size width and height
  10270. */
  10271. toString(): string;
  10272. /**
  10273. * "Size"
  10274. * @returns the string "Size"
  10275. */
  10276. getClassName(): string;
  10277. /**
  10278. * Returns the Size hash code.
  10279. * @returns a hash code for a unique width and height
  10280. */
  10281. getHashCode(): number;
  10282. /**
  10283. * Updates the current size from the given one.
  10284. * @param src the given size
  10285. */
  10286. copyFrom(src: Size): void;
  10287. /**
  10288. * Updates in place the current Size from the given floats.
  10289. * @param width width of the new size
  10290. * @param height height of the new size
  10291. * @returns the updated Size.
  10292. */
  10293. copyFromFloats(width: number, height: number): Size;
  10294. /**
  10295. * Updates in place the current Size from the given floats.
  10296. * @param width width to set
  10297. * @param height height to set
  10298. * @returns the updated Size.
  10299. */
  10300. set(width: number, height: number): Size;
  10301. /**
  10302. * Multiplies the width and height by numbers
  10303. * @param w factor to multiple the width by
  10304. * @param h factor to multiple the height by
  10305. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10306. */
  10307. multiplyByFloats(w: number, h: number): Size;
  10308. /**
  10309. * Clones the size
  10310. * @returns a new Size copied from the given one.
  10311. */
  10312. clone(): Size;
  10313. /**
  10314. * True if the current Size and the given one width and height are strictly equal.
  10315. * @param other the other size to compare against
  10316. * @returns True if the current Size and the given one width and height are strictly equal.
  10317. */
  10318. equals(other: Size): boolean;
  10319. /**
  10320. * The surface of the Size : width * height (float).
  10321. */
  10322. get surface(): number;
  10323. /**
  10324. * Create a new size of zero
  10325. * @returns a new Size set to (0.0, 0.0)
  10326. */
  10327. static Zero(): Size;
  10328. /**
  10329. * Sums the width and height of two sizes
  10330. * @param otherSize size to add to this size
  10331. * @returns a new Size set as the addition result of the current Size and the given one.
  10332. */
  10333. add(otherSize: Size): Size;
  10334. /**
  10335. * Subtracts the width and height of two
  10336. * @param otherSize size to subtract to this size
  10337. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10338. */
  10339. subtract(otherSize: Size): Size;
  10340. /**
  10341. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10342. * @param start starting size to lerp between
  10343. * @param end end size to lerp between
  10344. * @param amount amount to lerp between the start and end values
  10345. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10346. */
  10347. static Lerp(start: Size, end: Size, amount: number): Size;
  10348. }
  10349. }
  10350. declare module BABYLON {
  10351. interface ThinEngine {
  10352. /**
  10353. * Creates a dynamic texture
  10354. * @param width defines the width of the texture
  10355. * @param height defines the height of the texture
  10356. * @param generateMipMaps defines if the engine should generate the mip levels
  10357. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10358. * @returns the dynamic texture inside an InternalTexture
  10359. */
  10360. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10361. /**
  10362. * Update the content of a dynamic texture
  10363. * @param texture defines the texture to update
  10364. * @param canvas defines the canvas containing the source
  10365. * @param invertY defines if data must be stored with Y axis inverted
  10366. * @param premulAlpha defines if alpha is stored as premultiplied
  10367. * @param format defines the format of the data
  10368. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10369. */
  10370. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10371. }
  10372. }
  10373. declare module BABYLON {
  10374. /**
  10375. * Helper class used to generate a canvas to manipulate images
  10376. */
  10377. export class CanvasGenerator {
  10378. /**
  10379. * Create a new canvas (or offscreen canvas depending on the context)
  10380. * @param width defines the expected width
  10381. * @param height defines the expected height
  10382. * @return a new canvas or offscreen canvas
  10383. */
  10384. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10385. }
  10386. }
  10387. declare module BABYLON {
  10388. /**
  10389. * A class extending Texture allowing drawing on a texture
  10390. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10391. */
  10392. export class DynamicTexture extends Texture {
  10393. private _generateMipMaps;
  10394. private _canvas;
  10395. private _context;
  10396. private _engine;
  10397. /**
  10398. * Creates a DynamicTexture
  10399. * @param name defines the name of the texture
  10400. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10401. * @param scene defines the scene where you want the texture
  10402. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10403. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10404. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10405. */
  10406. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10407. /**
  10408. * Get the current class name of the texture useful for serialization or dynamic coding.
  10409. * @returns "DynamicTexture"
  10410. */
  10411. getClassName(): string;
  10412. /**
  10413. * Gets the current state of canRescale
  10414. */
  10415. get canRescale(): boolean;
  10416. private _recreate;
  10417. /**
  10418. * Scales the texture
  10419. * @param ratio the scale factor to apply to both width and height
  10420. */
  10421. scale(ratio: number): void;
  10422. /**
  10423. * Resizes the texture
  10424. * @param width the new width
  10425. * @param height the new height
  10426. */
  10427. scaleTo(width: number, height: number): void;
  10428. /**
  10429. * Gets the context of the canvas used by the texture
  10430. * @returns the canvas context of the dynamic texture
  10431. */
  10432. getContext(): CanvasRenderingContext2D;
  10433. /**
  10434. * Clears the texture
  10435. */
  10436. clear(): void;
  10437. /**
  10438. * Updates the texture
  10439. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10440. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10441. */
  10442. update(invertY?: boolean, premulAlpha?: boolean): void;
  10443. /**
  10444. * Draws text onto the texture
  10445. * @param text defines the text to be drawn
  10446. * @param x defines the placement of the text from the left
  10447. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10448. * @param font defines the font to be used with font-style, font-size, font-name
  10449. * @param color defines the color used for the text
  10450. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10451. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10452. * @param update defines whether texture is immediately update (default is true)
  10453. */
  10454. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10455. /**
  10456. * Clones the texture
  10457. * @returns the clone of the texture.
  10458. */
  10459. clone(): DynamicTexture;
  10460. /**
  10461. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10462. * @returns a serialized dynamic texture object
  10463. */
  10464. serialize(): any;
  10465. /** @hidden */
  10466. _rebuild(): void;
  10467. }
  10468. }
  10469. declare module BABYLON {
  10470. interface Engine {
  10471. /**
  10472. * Creates a raw texture
  10473. * @param data defines the data to store in the texture
  10474. * @param width defines the width of the texture
  10475. * @param height defines the height of the texture
  10476. * @param format defines the format of the data
  10477. * @param generateMipMaps defines if the engine should generate the mip levels
  10478. * @param invertY defines if data must be stored with Y axis inverted
  10479. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10480. * @param compression defines the compression used (null by default)
  10481. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10482. * @returns the raw texture inside an InternalTexture
  10483. */
  10484. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10485. /**
  10486. * Update a raw texture
  10487. * @param texture defines the texture to update
  10488. * @param data defines the data to store in the texture
  10489. * @param format defines the format of the data
  10490. * @param invertY defines if data must be stored with Y axis inverted
  10491. */
  10492. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10493. /**
  10494. * Update a raw texture
  10495. * @param texture defines the texture to update
  10496. * @param data defines the data to store in the texture
  10497. * @param format defines the format of the data
  10498. * @param invertY defines if data must be stored with Y axis inverted
  10499. * @param compression defines the compression used (null by default)
  10500. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10501. */
  10502. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10503. /**
  10504. * Creates a new raw cube texture
  10505. * @param data defines the array of data to use to create each face
  10506. * @param size defines the size of the textures
  10507. * @param format defines the format of the data
  10508. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10509. * @param generateMipMaps defines if the engine should generate the mip levels
  10510. * @param invertY defines if data must be stored with Y axis inverted
  10511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10512. * @param compression defines the compression used (null by default)
  10513. * @returns the cube texture as an InternalTexture
  10514. */
  10515. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10516. /**
  10517. * Update a raw cube texture
  10518. * @param texture defines the texture to udpdate
  10519. * @param data defines the data to store
  10520. * @param format defines the data format
  10521. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10522. * @param invertY defines if data must be stored with Y axis inverted
  10523. */
  10524. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10525. /**
  10526. * Update a raw cube texture
  10527. * @param texture defines the texture to udpdate
  10528. * @param data defines the data to store
  10529. * @param format defines the data format
  10530. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10531. * @param invertY defines if data must be stored with Y axis inverted
  10532. * @param compression defines the compression used (null by default)
  10533. */
  10534. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10535. /**
  10536. * Update a raw cube texture
  10537. * @param texture defines the texture to udpdate
  10538. * @param data defines the data to store
  10539. * @param format defines the data format
  10540. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10541. * @param invertY defines if data must be stored with Y axis inverted
  10542. * @param compression defines the compression used (null by default)
  10543. * @param level defines which level of the texture to update
  10544. */
  10545. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10546. /**
  10547. * Creates a new raw cube texture from a specified url
  10548. * @param url defines the url where the data is located
  10549. * @param scene defines the current scene
  10550. * @param size defines the size of the textures
  10551. * @param format defines the format of the data
  10552. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10553. * @param noMipmap defines if the engine should avoid generating the mip levels
  10554. * @param callback defines a callback used to extract texture data from loaded data
  10555. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10556. * @param onLoad defines a callback called when texture is loaded
  10557. * @param onError defines a callback called if there is an error
  10558. * @returns the cube texture as an InternalTexture
  10559. */
  10560. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10561. /**
  10562. * Creates a new raw cube texture from a specified url
  10563. * @param url defines the url where the data is located
  10564. * @param scene defines the current scene
  10565. * @param size defines the size of the textures
  10566. * @param format defines the format of the data
  10567. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10568. * @param noMipmap defines if the engine should avoid generating the mip levels
  10569. * @param callback defines a callback used to extract texture data from loaded data
  10570. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10571. * @param onLoad defines a callback called when texture is loaded
  10572. * @param onError defines a callback called if there is an error
  10573. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10574. * @param invertY defines if data must be stored with Y axis inverted
  10575. * @returns the cube texture as an InternalTexture
  10576. */
  10577. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10578. /**
  10579. * Creates a new raw 3D texture
  10580. * @param data defines the data used to create the texture
  10581. * @param width defines the width of the texture
  10582. * @param height defines the height of the texture
  10583. * @param depth defines the depth of the texture
  10584. * @param format defines the format of the texture
  10585. * @param generateMipMaps defines if the engine must generate mip levels
  10586. * @param invertY defines if data must be stored with Y axis inverted
  10587. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10588. * @param compression defines the compressed used (can be null)
  10589. * @param textureType defines the compressed used (can be null)
  10590. * @returns a new raw 3D texture (stored in an InternalTexture)
  10591. */
  10592. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10593. /**
  10594. * Update a raw 3D texture
  10595. * @param texture defines the texture to update
  10596. * @param data defines the data to store
  10597. * @param format defines the data format
  10598. * @param invertY defines if data must be stored with Y axis inverted
  10599. */
  10600. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10601. /**
  10602. * Update a raw 3D texture
  10603. * @param texture defines the texture to update
  10604. * @param data defines the data to store
  10605. * @param format defines the data format
  10606. * @param invertY defines if data must be stored with Y axis inverted
  10607. * @param compression defines the used compression (can be null)
  10608. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10609. */
  10610. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10611. /**
  10612. * Creates a new raw 2D array texture
  10613. * @param data defines the data used to create the texture
  10614. * @param width defines the width of the texture
  10615. * @param height defines the height of the texture
  10616. * @param depth defines the number of layers of the texture
  10617. * @param format defines the format of the texture
  10618. * @param generateMipMaps defines if the engine must generate mip levels
  10619. * @param invertY defines if data must be stored with Y axis inverted
  10620. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10621. * @param compression defines the compressed used (can be null)
  10622. * @param textureType defines the compressed used (can be null)
  10623. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10624. */
  10625. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10626. /**
  10627. * Update a raw 2D array texture
  10628. * @param texture defines the texture to update
  10629. * @param data defines the data to store
  10630. * @param format defines the data format
  10631. * @param invertY defines if data must be stored with Y axis inverted
  10632. */
  10633. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10634. /**
  10635. * Update a raw 2D array texture
  10636. * @param texture defines the texture to update
  10637. * @param data defines the data to store
  10638. * @param format defines the data format
  10639. * @param invertY defines if data must be stored with Y axis inverted
  10640. * @param compression defines the used compression (can be null)
  10641. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10642. */
  10643. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10644. }
  10645. }
  10646. declare module BABYLON {
  10647. /**
  10648. * Raw texture can help creating a texture directly from an array of data.
  10649. * This can be super useful if you either get the data from an uncompressed source or
  10650. * if you wish to create your texture pixel by pixel.
  10651. */
  10652. export class RawTexture extends Texture {
  10653. /**
  10654. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10655. */
  10656. format: number;
  10657. private _engine;
  10658. /**
  10659. * Instantiates a new RawTexture.
  10660. * Raw texture can help creating a texture directly from an array of data.
  10661. * This can be super useful if you either get the data from an uncompressed source or
  10662. * if you wish to create your texture pixel by pixel.
  10663. * @param data define the array of data to use to create the texture
  10664. * @param width define the width of the texture
  10665. * @param height define the height of the texture
  10666. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10667. * @param scene define the scene the texture belongs to
  10668. * @param generateMipMaps define whether mip maps should be generated or not
  10669. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10670. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10671. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10672. */
  10673. constructor(data: ArrayBufferView, width: number, height: number,
  10674. /**
  10675. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10676. */
  10677. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10678. /**
  10679. * Updates the texture underlying data.
  10680. * @param data Define the new data of the texture
  10681. */
  10682. update(data: ArrayBufferView): void;
  10683. /**
  10684. * Creates a luminance texture from some data.
  10685. * @param data Define the texture data
  10686. * @param width Define the width of the texture
  10687. * @param height Define the height of the texture
  10688. * @param scene Define the scene the texture belongs to
  10689. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10690. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10691. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10692. * @returns the luminance texture
  10693. */
  10694. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10695. /**
  10696. * Creates a luminance alpha texture from some data.
  10697. * @param data Define the texture data
  10698. * @param width Define the width of the texture
  10699. * @param height Define the height of the texture
  10700. * @param scene Define the scene the texture belongs to
  10701. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10702. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10703. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10704. * @returns the luminance alpha texture
  10705. */
  10706. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10707. /**
  10708. * Creates an alpha texture from some data.
  10709. * @param data Define the texture data
  10710. * @param width Define the width of the texture
  10711. * @param height Define the height of the texture
  10712. * @param scene Define the scene the texture belongs to
  10713. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10714. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10715. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10716. * @returns the alpha texture
  10717. */
  10718. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10719. /**
  10720. * Creates a RGB texture from some data.
  10721. * @param data Define the texture data
  10722. * @param width Define the width of the texture
  10723. * @param height Define the height of the texture
  10724. * @param scene Define the scene the texture belongs to
  10725. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10726. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10727. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10728. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10729. * @returns the RGB alpha texture
  10730. */
  10731. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10732. /**
  10733. * Creates a RGBA texture from some data.
  10734. * @param data Define the texture data
  10735. * @param width Define the width of the texture
  10736. * @param height Define the height of the texture
  10737. * @param scene Define the scene the texture belongs to
  10738. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10739. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10740. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10741. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10742. * @returns the RGBA texture
  10743. */
  10744. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10745. /**
  10746. * Creates a R texture from some data.
  10747. * @param data Define the texture data
  10748. * @param width Define the width of the texture
  10749. * @param height Define the height of the texture
  10750. * @param scene Define the scene the texture belongs to
  10751. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10752. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10753. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10754. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10755. * @returns the R texture
  10756. */
  10757. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10758. }
  10759. }
  10760. declare module BABYLON {
  10761. interface AbstractScene {
  10762. /**
  10763. * The list of procedural textures added to the scene
  10764. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10765. */
  10766. proceduralTextures: Array<ProceduralTexture>;
  10767. }
  10768. /**
  10769. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10770. * in a given scene.
  10771. */
  10772. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10773. /**
  10774. * The component name helpfull to identify the component in the list of scene components.
  10775. */
  10776. readonly name: string;
  10777. /**
  10778. * The scene the component belongs to.
  10779. */
  10780. scene: Scene;
  10781. /**
  10782. * Creates a new instance of the component for the given scene
  10783. * @param scene Defines the scene to register the component in
  10784. */
  10785. constructor(scene: Scene);
  10786. /**
  10787. * Registers the component in a given scene
  10788. */
  10789. register(): void;
  10790. /**
  10791. * Rebuilds the elements related to this component in case of
  10792. * context lost for instance.
  10793. */
  10794. rebuild(): void;
  10795. /**
  10796. * Disposes the component and the associated ressources.
  10797. */
  10798. dispose(): void;
  10799. private _beforeClear;
  10800. }
  10801. }
  10802. declare module BABYLON {
  10803. interface ThinEngine {
  10804. /**
  10805. * Creates a new render target cube texture
  10806. * @param size defines the size of the texture
  10807. * @param options defines the options used to create the texture
  10808. * @returns a new render target cube texture stored in an InternalTexture
  10809. */
  10810. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10811. }
  10812. }
  10813. declare module BABYLON {
  10814. /** @hidden */
  10815. export var proceduralVertexShader: {
  10816. name: string;
  10817. shader: string;
  10818. };
  10819. }
  10820. declare module BABYLON {
  10821. /**
  10822. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  10823. * This is the base class of any Procedural texture and contains most of the shareable code.
  10824. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10825. */
  10826. export class ProceduralTexture extends Texture {
  10827. isCube: boolean;
  10828. /**
  10829. * Define if the texture is enabled or not (disabled texture will not render)
  10830. */
  10831. isEnabled: boolean;
  10832. /**
  10833. * Define if the texture must be cleared before rendering (default is true)
  10834. */
  10835. autoClear: boolean;
  10836. /**
  10837. * Callback called when the texture is generated
  10838. */
  10839. onGenerated: () => void;
  10840. /**
  10841. * Event raised when the texture is generated
  10842. */
  10843. onGeneratedObservable: Observable<ProceduralTexture>;
  10844. /** @hidden */
  10845. _generateMipMaps: boolean;
  10846. /** @hidden **/
  10847. _effect: Effect;
  10848. /** @hidden */
  10849. _textures: {
  10850. [key: string]: Texture;
  10851. };
  10852. /** @hidden */
  10853. protected _fallbackTexture: Nullable<Texture>;
  10854. private _size;
  10855. private _currentRefreshId;
  10856. private _frameId;
  10857. private _refreshRate;
  10858. private _vertexBuffers;
  10859. private _indexBuffer;
  10860. private _uniforms;
  10861. private _samplers;
  10862. private _fragment;
  10863. private _floats;
  10864. private _ints;
  10865. private _floatsArrays;
  10866. private _colors3;
  10867. private _colors4;
  10868. private _vectors2;
  10869. private _vectors3;
  10870. private _matrices;
  10871. private _fallbackTextureUsed;
  10872. private _engine;
  10873. private _cachedDefines;
  10874. private _contentUpdateId;
  10875. private _contentData;
  10876. /**
  10877. * Instantiates a new procedural texture.
  10878. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  10879. * This is the base class of any Procedural texture and contains most of the shareable code.
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10881. * @param name Define the name of the texture
  10882. * @param size Define the size of the texture to create
  10883. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10884. * @param scene Define the scene the texture belongs to
  10885. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10886. * @param generateMipMaps Define if the texture should creates mip maps or not
  10887. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10888. */
  10889. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10890. /**
  10891. * The effect that is created when initializing the post process.
  10892. * @returns The created effect corresponding the the postprocess.
  10893. */
  10894. getEffect(): Effect;
  10895. /**
  10896. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10897. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10898. */
  10899. getContent(): Nullable<ArrayBufferView>;
  10900. private _createIndexBuffer;
  10901. /** @hidden */
  10902. _rebuild(): void;
  10903. /**
  10904. * Resets the texture in order to recreate its associated resources.
  10905. * This can be called in case of context loss
  10906. */
  10907. reset(): void;
  10908. protected _getDefines(): string;
  10909. /**
  10910. * Is the texture ready to be used ? (rendered at least once)
  10911. * @returns true if ready, otherwise, false.
  10912. */
  10913. isReady(): boolean;
  10914. /**
  10915. * Resets the refresh counter of the texture and start bak from scratch.
  10916. * Could be useful to regenerate the texture if it is setup to render only once.
  10917. */
  10918. resetRefreshCounter(): void;
  10919. /**
  10920. * Set the fragment shader to use in order to render the texture.
  10921. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10922. */
  10923. setFragment(fragment: any): void;
  10924. /**
  10925. * Define the refresh rate of the texture or the rendering frequency.
  10926. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10927. */
  10928. get refreshRate(): number;
  10929. set refreshRate(value: number);
  10930. /** @hidden */
  10931. _shouldRender(): boolean;
  10932. /**
  10933. * Get the size the texture is rendering at.
  10934. * @returns the size (texture is always squared)
  10935. */
  10936. getRenderSize(): number;
  10937. /**
  10938. * Resize the texture to new value.
  10939. * @param size Define the new size the texture should have
  10940. * @param generateMipMaps Define whether the new texture should create mip maps
  10941. */
  10942. resize(size: number, generateMipMaps: boolean): void;
  10943. private _checkUniform;
  10944. /**
  10945. * Set a texture in the shader program used to render.
  10946. * @param name Define the name of the uniform samplers as defined in the shader
  10947. * @param texture Define the texture to bind to this sampler
  10948. * @return the texture itself allowing "fluent" like uniform updates
  10949. */
  10950. setTexture(name: string, texture: Texture): ProceduralTexture;
  10951. /**
  10952. * Set a float in the shader.
  10953. * @param name Define the name of the uniform as defined in the shader
  10954. * @param value Define the value to give to the uniform
  10955. * @return the texture itself allowing "fluent" like uniform updates
  10956. */
  10957. setFloat(name: string, value: number): ProceduralTexture;
  10958. /**
  10959. * Set a int in the shader.
  10960. * @param name Define the name of the uniform as defined in the shader
  10961. * @param value Define the value to give to the uniform
  10962. * @return the texture itself allowing "fluent" like uniform updates
  10963. */
  10964. setInt(name: string, value: number): ProceduralTexture;
  10965. /**
  10966. * Set an array of floats in the shader.
  10967. * @param name Define the name of the uniform as defined in the shader
  10968. * @param value Define the value to give to the uniform
  10969. * @return the texture itself allowing "fluent" like uniform updates
  10970. */
  10971. setFloats(name: string, value: number[]): ProceduralTexture;
  10972. /**
  10973. * Set a vec3 in the shader from a Color3.
  10974. * @param name Define the name of the uniform as defined in the shader
  10975. * @param value Define the value to give to the uniform
  10976. * @return the texture itself allowing "fluent" like uniform updates
  10977. */
  10978. setColor3(name: string, value: Color3): ProceduralTexture;
  10979. /**
  10980. * Set a vec4 in the shader from a Color4.
  10981. * @param name Define the name of the uniform as defined in the shader
  10982. * @param value Define the value to give to the uniform
  10983. * @return the texture itself allowing "fluent" like uniform updates
  10984. */
  10985. setColor4(name: string, value: Color4): ProceduralTexture;
  10986. /**
  10987. * Set a vec2 in the shader from a Vector2.
  10988. * @param name Define the name of the uniform as defined in the shader
  10989. * @param value Define the value to give to the uniform
  10990. * @return the texture itself allowing "fluent" like uniform updates
  10991. */
  10992. setVector2(name: string, value: Vector2): ProceduralTexture;
  10993. /**
  10994. * Set a vec3 in the shader from a Vector3.
  10995. * @param name Define the name of the uniform as defined in the shader
  10996. * @param value Define the value to give to the uniform
  10997. * @return the texture itself allowing "fluent" like uniform updates
  10998. */
  10999. setVector3(name: string, value: Vector3): ProceduralTexture;
  11000. /**
  11001. * Set a mat4 in the shader from a MAtrix.
  11002. * @param name Define the name of the uniform as defined in the shader
  11003. * @param value Define the value to give to the uniform
  11004. * @return the texture itself allowing "fluent" like uniform updates
  11005. */
  11006. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11007. /**
  11008. * Render the texture to its associated render target.
  11009. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11010. */
  11011. render(useCameraPostProcess?: boolean): void;
  11012. /**
  11013. * Clone the texture.
  11014. * @returns the cloned texture
  11015. */
  11016. clone(): ProceduralTexture;
  11017. /**
  11018. * Dispose the texture and release its asoociated resources.
  11019. */
  11020. dispose(): void;
  11021. }
  11022. }
  11023. declare module BABYLON {
  11024. /**
  11025. * This represents the base class for particle system in Babylon.
  11026. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11027. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11028. * @example https://doc.babylonjs.com/babylon101/particles
  11029. */
  11030. export class BaseParticleSystem {
  11031. /**
  11032. * Source color is added to the destination color without alpha affecting the result
  11033. */
  11034. static BLENDMODE_ONEONE: number;
  11035. /**
  11036. * Blend current color and particle color using particle’s alpha
  11037. */
  11038. static BLENDMODE_STANDARD: number;
  11039. /**
  11040. * Add current color and particle color multiplied by particle’s alpha
  11041. */
  11042. static BLENDMODE_ADD: number;
  11043. /**
  11044. * Multiply current color with particle color
  11045. */
  11046. static BLENDMODE_MULTIPLY: number;
  11047. /**
  11048. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11049. */
  11050. static BLENDMODE_MULTIPLYADD: number;
  11051. /**
  11052. * List of animations used by the particle system.
  11053. */
  11054. animations: Animation[];
  11055. /**
  11056. * Gets or sets the unique id of the particle system
  11057. */
  11058. uniqueId: number;
  11059. /**
  11060. * The id of the Particle system.
  11061. */
  11062. id: string;
  11063. /**
  11064. * The friendly name of the Particle system.
  11065. */
  11066. name: string;
  11067. /**
  11068. * Snippet ID if the particle system was created from the snippet server
  11069. */
  11070. snippetId: string;
  11071. /**
  11072. * The rendering group used by the Particle system to chose when to render.
  11073. */
  11074. renderingGroupId: number;
  11075. /**
  11076. * The emitter represents the Mesh or position we are attaching the particle system to.
  11077. */
  11078. emitter: Nullable<AbstractMesh | Vector3>;
  11079. /**
  11080. * The maximum number of particles to emit per frame
  11081. */
  11082. emitRate: number;
  11083. /**
  11084. * If you want to launch only a few particles at once, that can be done, as well.
  11085. */
  11086. manualEmitCount: number;
  11087. /**
  11088. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11089. */
  11090. updateSpeed: number;
  11091. /**
  11092. * The amount of time the particle system is running (depends of the overall update speed).
  11093. */
  11094. targetStopDuration: number;
  11095. /**
  11096. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11097. */
  11098. disposeOnStop: boolean;
  11099. /**
  11100. * Minimum power of emitting particles.
  11101. */
  11102. minEmitPower: number;
  11103. /**
  11104. * Maximum power of emitting particles.
  11105. */
  11106. maxEmitPower: number;
  11107. /**
  11108. * Minimum life time of emitting particles.
  11109. */
  11110. minLifeTime: number;
  11111. /**
  11112. * Maximum life time of emitting particles.
  11113. */
  11114. maxLifeTime: number;
  11115. /**
  11116. * Minimum Size of emitting particles.
  11117. */
  11118. minSize: number;
  11119. /**
  11120. * Maximum Size of emitting particles.
  11121. */
  11122. maxSize: number;
  11123. /**
  11124. * Minimum scale of emitting particles on X axis.
  11125. */
  11126. minScaleX: number;
  11127. /**
  11128. * Maximum scale of emitting particles on X axis.
  11129. */
  11130. maxScaleX: number;
  11131. /**
  11132. * Minimum scale of emitting particles on Y axis.
  11133. */
  11134. minScaleY: number;
  11135. /**
  11136. * Maximum scale of emitting particles on Y axis.
  11137. */
  11138. maxScaleY: number;
  11139. /**
  11140. * Gets or sets the minimal initial rotation in radians.
  11141. */
  11142. minInitialRotation: number;
  11143. /**
  11144. * Gets or sets the maximal initial rotation in radians.
  11145. */
  11146. maxInitialRotation: number;
  11147. /**
  11148. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11149. */
  11150. minAngularSpeed: number;
  11151. /**
  11152. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11153. */
  11154. maxAngularSpeed: number;
  11155. /**
  11156. * The texture used to render each particle. (this can be a spritesheet)
  11157. */
  11158. particleTexture: Nullable<Texture>;
  11159. /**
  11160. * The layer mask we are rendering the particles through.
  11161. */
  11162. layerMask: number;
  11163. /**
  11164. * This can help using your own shader to render the particle system.
  11165. * The according effect will be created
  11166. */
  11167. customShader: any;
  11168. /**
  11169. * By default particle system starts as soon as they are created. This prevents the
  11170. * automatic start to happen and let you decide when to start emitting particles.
  11171. */
  11172. preventAutoStart: boolean;
  11173. private _noiseTexture;
  11174. /**
  11175. * Gets or sets a texture used to add random noise to particle positions
  11176. */
  11177. get noiseTexture(): Nullable<ProceduralTexture>;
  11178. set noiseTexture(value: Nullable<ProceduralTexture>);
  11179. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11180. noiseStrength: Vector3;
  11181. /**
  11182. * Callback triggered when the particle animation is ending.
  11183. */
  11184. onAnimationEnd: Nullable<() => void>;
  11185. /**
  11186. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11187. */
  11188. blendMode: number;
  11189. /**
  11190. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11191. * to override the particles.
  11192. */
  11193. forceDepthWrite: boolean;
  11194. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11195. preWarmCycles: number;
  11196. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11197. preWarmStepOffset: number;
  11198. /**
  11199. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11200. */
  11201. spriteCellChangeSpeed: number;
  11202. /**
  11203. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11204. */
  11205. startSpriteCellID: number;
  11206. /**
  11207. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11208. */
  11209. endSpriteCellID: number;
  11210. /**
  11211. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11212. */
  11213. spriteCellWidth: number;
  11214. /**
  11215. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11216. */
  11217. spriteCellHeight: number;
  11218. /**
  11219. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11220. */
  11221. spriteRandomStartCell: boolean;
  11222. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11223. translationPivot: Vector2;
  11224. /** @hidden */
  11225. protected _isAnimationSheetEnabled: boolean;
  11226. /**
  11227. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11228. */
  11229. beginAnimationOnStart: boolean;
  11230. /**
  11231. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11232. */
  11233. beginAnimationFrom: number;
  11234. /**
  11235. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11236. */
  11237. beginAnimationTo: number;
  11238. /**
  11239. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11240. */
  11241. beginAnimationLoop: boolean;
  11242. /**
  11243. * Gets or sets a world offset applied to all particles
  11244. */
  11245. worldOffset: Vector3;
  11246. /**
  11247. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11248. */
  11249. get isAnimationSheetEnabled(): boolean;
  11250. set isAnimationSheetEnabled(value: boolean);
  11251. /**
  11252. * Get hosting scene
  11253. * @returns the scene
  11254. */
  11255. getScene(): Scene;
  11256. /**
  11257. * You can use gravity if you want to give an orientation to your particles.
  11258. */
  11259. gravity: Vector3;
  11260. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11261. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11262. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11263. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11264. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11265. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11266. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11267. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11268. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11269. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11270. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11271. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11272. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11273. /**
  11274. * Defines the delay in milliseconds before starting the system (0 by default)
  11275. */
  11276. startDelay: number;
  11277. /**
  11278. * Gets the current list of drag gradients.
  11279. * You must use addDragGradient and removeDragGradient to udpate this list
  11280. * @returns the list of drag gradients
  11281. */
  11282. getDragGradients(): Nullable<Array<FactorGradient>>;
  11283. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11284. limitVelocityDamping: number;
  11285. /**
  11286. * Gets the current list of limit velocity gradients.
  11287. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11288. * @returns the list of limit velocity gradients
  11289. */
  11290. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11291. /**
  11292. * Gets the current list of color gradients.
  11293. * You must use addColorGradient and removeColorGradient to udpate this list
  11294. * @returns the list of color gradients
  11295. */
  11296. getColorGradients(): Nullable<Array<ColorGradient>>;
  11297. /**
  11298. * Gets the current list of size gradients.
  11299. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11300. * @returns the list of size gradients
  11301. */
  11302. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11303. /**
  11304. * Gets the current list of color remap gradients.
  11305. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11306. * @returns the list of color remap gradients
  11307. */
  11308. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11309. /**
  11310. * Gets the current list of alpha remap gradients.
  11311. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11312. * @returns the list of alpha remap gradients
  11313. */
  11314. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11315. /**
  11316. * Gets the current list of life time gradients.
  11317. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11318. * @returns the list of life time gradients
  11319. */
  11320. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11321. /**
  11322. * Gets the current list of angular speed gradients.
  11323. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11324. * @returns the list of angular speed gradients
  11325. */
  11326. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11327. /**
  11328. * Gets the current list of velocity gradients.
  11329. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11330. * @returns the list of velocity gradients
  11331. */
  11332. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11333. /**
  11334. * Gets the current list of start size gradients.
  11335. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11336. * @returns the list of start size gradients
  11337. */
  11338. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11339. /**
  11340. * Gets the current list of emit rate gradients.
  11341. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11342. * @returns the list of emit rate gradients
  11343. */
  11344. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11345. /**
  11346. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11347. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11348. */
  11349. get direction1(): Vector3;
  11350. set direction1(value: Vector3);
  11351. /**
  11352. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11353. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11354. */
  11355. get direction2(): Vector3;
  11356. set direction2(value: Vector3);
  11357. /**
  11358. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11359. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11360. */
  11361. get minEmitBox(): Vector3;
  11362. set minEmitBox(value: Vector3);
  11363. /**
  11364. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11365. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11366. */
  11367. get maxEmitBox(): Vector3;
  11368. set maxEmitBox(value: Vector3);
  11369. /**
  11370. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11371. */
  11372. color1: Color4;
  11373. /**
  11374. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11375. */
  11376. color2: Color4;
  11377. /**
  11378. * Color the particle will have at the end of its lifetime
  11379. */
  11380. colorDead: Color4;
  11381. /**
  11382. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11383. */
  11384. textureMask: Color4;
  11385. /**
  11386. * The particle emitter type defines the emitter used by the particle system.
  11387. * It can be for example box, sphere, or cone...
  11388. */
  11389. particleEmitterType: IParticleEmitterType;
  11390. /** @hidden */
  11391. _isSubEmitter: boolean;
  11392. /**
  11393. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11394. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11395. */
  11396. billboardMode: number;
  11397. protected _isBillboardBased: boolean;
  11398. /**
  11399. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11400. */
  11401. get isBillboardBased(): boolean;
  11402. set isBillboardBased(value: boolean);
  11403. /**
  11404. * The scene the particle system belongs to.
  11405. */
  11406. protected _scene: Scene;
  11407. /**
  11408. * Local cache of defines for image processing.
  11409. */
  11410. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11411. /**
  11412. * Default configuration related to image processing available in the standard Material.
  11413. */
  11414. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11415. /**
  11416. * Gets the image processing configuration used either in this material.
  11417. */
  11418. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11419. /**
  11420. * Sets the Default image processing configuration used either in the this material.
  11421. *
  11422. * If sets to null, the scene one is in use.
  11423. */
  11424. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11425. /**
  11426. * Attaches a new image processing configuration to the Standard Material.
  11427. * @param configuration
  11428. */
  11429. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11430. /** @hidden */
  11431. protected _reset(): void;
  11432. /** @hidden */
  11433. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11434. /**
  11435. * Instantiates a particle system.
  11436. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11437. * @param name The name of the particle system
  11438. */
  11439. constructor(name: string);
  11440. /**
  11441. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11442. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11443. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11444. * @returns the emitter
  11445. */
  11446. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11447. /**
  11448. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11449. * @param radius The radius of the hemisphere to emit from
  11450. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11451. * @returns the emitter
  11452. */
  11453. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11454. /**
  11455. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11456. * @param radius The radius of the sphere to emit from
  11457. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11458. * @returns the emitter
  11459. */
  11460. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11461. /**
  11462. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11463. * @param radius The radius of the sphere to emit from
  11464. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11465. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11466. * @returns the emitter
  11467. */
  11468. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11469. /**
  11470. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11471. * @param radius The radius of the emission cylinder
  11472. * @param height The height of the emission cylinder
  11473. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11474. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11475. * @returns the emitter
  11476. */
  11477. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11478. /**
  11479. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11480. * @param radius The radius of the cylinder to emit from
  11481. * @param height The height of the emission cylinder
  11482. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11483. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11484. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11485. * @returns the emitter
  11486. */
  11487. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11488. /**
  11489. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11490. * @param radius The radius of the cone to emit from
  11491. * @param angle The base angle of the cone
  11492. * @returns the emitter
  11493. */
  11494. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11495. /**
  11496. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11497. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11498. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11499. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11500. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11501. * @returns the emitter
  11502. */
  11503. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11504. }
  11505. }
  11506. declare module BABYLON {
  11507. /**
  11508. * Type of sub emitter
  11509. */
  11510. export enum SubEmitterType {
  11511. /**
  11512. * Attached to the particle over it's lifetime
  11513. */
  11514. ATTACHED = 0,
  11515. /**
  11516. * Created when the particle dies
  11517. */
  11518. END = 1
  11519. }
  11520. /**
  11521. * Sub emitter class used to emit particles from an existing particle
  11522. */
  11523. export class SubEmitter {
  11524. /**
  11525. * the particle system to be used by the sub emitter
  11526. */
  11527. particleSystem: ParticleSystem;
  11528. /**
  11529. * Type of the submitter (Default: END)
  11530. */
  11531. type: SubEmitterType;
  11532. /**
  11533. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11534. * Note: This only is supported when using an emitter of type Mesh
  11535. */
  11536. inheritDirection: boolean;
  11537. /**
  11538. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11539. */
  11540. inheritedVelocityAmount: number;
  11541. /**
  11542. * Creates a sub emitter
  11543. * @param particleSystem the particle system to be used by the sub emitter
  11544. */
  11545. constructor(
  11546. /**
  11547. * the particle system to be used by the sub emitter
  11548. */
  11549. particleSystem: ParticleSystem);
  11550. /**
  11551. * Clones the sub emitter
  11552. * @returns the cloned sub emitter
  11553. */
  11554. clone(): SubEmitter;
  11555. /**
  11556. * Serialize current object to a JSON object
  11557. * @returns the serialized object
  11558. */
  11559. serialize(): any;
  11560. /** @hidden */
  11561. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11562. /**
  11563. * Creates a new SubEmitter from a serialized JSON version
  11564. * @param serializationObject defines the JSON object to read from
  11565. * @param scene defines the hosting scene
  11566. * @param rootUrl defines the rootUrl for data loading
  11567. * @returns a new SubEmitter
  11568. */
  11569. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11570. /** Release associated resources */
  11571. dispose(): void;
  11572. }
  11573. }
  11574. declare module BABYLON {
  11575. /** @hidden */
  11576. export var imageProcessingDeclaration: {
  11577. name: string;
  11578. shader: string;
  11579. };
  11580. }
  11581. declare module BABYLON {
  11582. /** @hidden */
  11583. export var imageProcessingFunctions: {
  11584. name: string;
  11585. shader: string;
  11586. };
  11587. }
  11588. declare module BABYLON {
  11589. /** @hidden */
  11590. export var particlesPixelShader: {
  11591. name: string;
  11592. shader: string;
  11593. };
  11594. }
  11595. declare module BABYLON {
  11596. /** @hidden */
  11597. export var particlesVertexShader: {
  11598. name: string;
  11599. shader: string;
  11600. };
  11601. }
  11602. declare module BABYLON {
  11603. /**
  11604. * This represents a particle system in Babylon.
  11605. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11606. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11607. * @example https://doc.babylonjs.com/babylon101/particles
  11608. */
  11609. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11610. /**
  11611. * Billboard mode will only apply to Y axis
  11612. */
  11613. static readonly BILLBOARDMODE_Y: number;
  11614. /**
  11615. * Billboard mode will apply to all axes
  11616. */
  11617. static readonly BILLBOARDMODE_ALL: number;
  11618. /**
  11619. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11620. */
  11621. static readonly BILLBOARDMODE_STRETCHED: number;
  11622. /**
  11623. * This function can be defined to provide custom update for active particles.
  11624. * This function will be called instead of regular update (age, position, color, etc.).
  11625. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11626. */
  11627. updateFunction: (particles: Particle[]) => void;
  11628. private _emitterWorldMatrix;
  11629. /**
  11630. * This function can be defined to specify initial direction for every new particle.
  11631. * It by default use the emitterType defined function
  11632. */
  11633. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11634. /**
  11635. * This function can be defined to specify initial position for every new particle.
  11636. * It by default use the emitterType defined function
  11637. */
  11638. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11639. /**
  11640. * @hidden
  11641. */
  11642. _inheritedVelocityOffset: Vector3;
  11643. /**
  11644. * An event triggered when the system is disposed
  11645. */
  11646. onDisposeObservable: Observable<ParticleSystem>;
  11647. private _onDisposeObserver;
  11648. /**
  11649. * Sets a callback that will be triggered when the system is disposed
  11650. */
  11651. set onDispose(callback: () => void);
  11652. private _particles;
  11653. private _epsilon;
  11654. private _capacity;
  11655. private _stockParticles;
  11656. private _newPartsExcess;
  11657. private _vertexData;
  11658. private _vertexBuffer;
  11659. private _vertexBuffers;
  11660. private _spriteBuffer;
  11661. private _indexBuffer;
  11662. private _effect;
  11663. private _customEffect;
  11664. private _cachedDefines;
  11665. private _scaledColorStep;
  11666. private _colorDiff;
  11667. private _scaledDirection;
  11668. private _scaledGravity;
  11669. private _currentRenderId;
  11670. private _alive;
  11671. private _useInstancing;
  11672. private _started;
  11673. private _stopped;
  11674. private _actualFrame;
  11675. private _scaledUpdateSpeed;
  11676. private _vertexBufferSize;
  11677. /** @hidden */
  11678. _currentEmitRateGradient: Nullable<FactorGradient>;
  11679. /** @hidden */
  11680. _currentEmitRate1: number;
  11681. /** @hidden */
  11682. _currentEmitRate2: number;
  11683. /** @hidden */
  11684. _currentStartSizeGradient: Nullable<FactorGradient>;
  11685. /** @hidden */
  11686. _currentStartSize1: number;
  11687. /** @hidden */
  11688. _currentStartSize2: number;
  11689. private readonly _rawTextureWidth;
  11690. private _rampGradientsTexture;
  11691. private _useRampGradients;
  11692. /** Gets or sets a boolean indicating that ramp gradients must be used
  11693. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11694. */
  11695. get useRampGradients(): boolean;
  11696. set useRampGradients(value: boolean);
  11697. /**
  11698. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  11699. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  11700. */
  11701. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11702. private _subEmitters;
  11703. /**
  11704. * @hidden
  11705. * If the particle systems emitter should be disposed when the particle system is disposed
  11706. */
  11707. _disposeEmitterOnDispose: boolean;
  11708. /**
  11709. * The current active Sub-systems, this property is used by the root particle system only.
  11710. */
  11711. activeSubSystems: Array<ParticleSystem>;
  11712. /**
  11713. * Specifies if the particles are updated in emitter local space or world space
  11714. */
  11715. isLocal: boolean;
  11716. private _rootParticleSystem;
  11717. /**
  11718. * Gets the current list of active particles
  11719. */
  11720. get particles(): Particle[];
  11721. /**
  11722. * Gets the number of particles active at the same time.
  11723. * @returns The number of active particles.
  11724. */
  11725. getActiveCount(): number;
  11726. /**
  11727. * Returns the string "ParticleSystem"
  11728. * @returns a string containing the class name
  11729. */
  11730. getClassName(): string;
  11731. /**
  11732. * Gets a boolean indicating that the system is stopping
  11733. * @returns true if the system is currently stopping
  11734. */
  11735. isStopping(): boolean;
  11736. /**
  11737. * Instantiates a particle system.
  11738. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11739. * @param name The name of the particle system
  11740. * @param capacity The max number of particles alive at the same time
  11741. * @param scene The scene the particle system belongs to
  11742. * @param customEffect a custom effect used to change the way particles are rendered by default
  11743. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11744. * @param epsilon Offset used to render the particles
  11745. */
  11746. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11747. private _addFactorGradient;
  11748. private _removeFactorGradient;
  11749. /**
  11750. * Adds a new life time gradient
  11751. * @param gradient defines the gradient to use (between 0 and 1)
  11752. * @param factor defines the life time factor to affect to the specified gradient
  11753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11754. * @returns the current particle system
  11755. */
  11756. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11757. /**
  11758. * Remove a specific life time gradient
  11759. * @param gradient defines the gradient to remove
  11760. * @returns the current particle system
  11761. */
  11762. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11763. /**
  11764. * Adds a new size gradient
  11765. * @param gradient defines the gradient to use (between 0 and 1)
  11766. * @param factor defines the size factor to affect to the specified gradient
  11767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11768. * @returns the current particle system
  11769. */
  11770. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11771. /**
  11772. * Remove a specific size gradient
  11773. * @param gradient defines the gradient to remove
  11774. * @returns the current particle system
  11775. */
  11776. removeSizeGradient(gradient: number): IParticleSystem;
  11777. /**
  11778. * Adds a new color remap gradient
  11779. * @param gradient defines the gradient to use (between 0 and 1)
  11780. * @param min defines the color remap minimal range
  11781. * @param max defines the color remap maximal range
  11782. * @returns the current particle system
  11783. */
  11784. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11785. /**
  11786. * Remove a specific color remap gradient
  11787. * @param gradient defines the gradient to remove
  11788. * @returns the current particle system
  11789. */
  11790. removeColorRemapGradient(gradient: number): IParticleSystem;
  11791. /**
  11792. * Adds a new alpha remap gradient
  11793. * @param gradient defines the gradient to use (between 0 and 1)
  11794. * @param min defines the alpha remap minimal range
  11795. * @param max defines the alpha remap maximal range
  11796. * @returns the current particle system
  11797. */
  11798. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11799. /**
  11800. * Remove a specific alpha remap gradient
  11801. * @param gradient defines the gradient to remove
  11802. * @returns the current particle system
  11803. */
  11804. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11805. /**
  11806. * Adds a new angular speed gradient
  11807. * @param gradient defines the gradient to use (between 0 and 1)
  11808. * @param factor defines the angular speed to affect to the specified gradient
  11809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11810. * @returns the current particle system
  11811. */
  11812. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11813. /**
  11814. * Remove a specific angular speed gradient
  11815. * @param gradient defines the gradient to remove
  11816. * @returns the current particle system
  11817. */
  11818. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11819. /**
  11820. * Adds a new velocity gradient
  11821. * @param gradient defines the gradient to use (between 0 and 1)
  11822. * @param factor defines the velocity to affect to the specified gradient
  11823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11824. * @returns the current particle system
  11825. */
  11826. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11827. /**
  11828. * Remove a specific velocity gradient
  11829. * @param gradient defines the gradient to remove
  11830. * @returns the current particle system
  11831. */
  11832. removeVelocityGradient(gradient: number): IParticleSystem;
  11833. /**
  11834. * Adds a new limit velocity gradient
  11835. * @param gradient defines the gradient to use (between 0 and 1)
  11836. * @param factor defines the limit velocity value to affect to the specified gradient
  11837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11838. * @returns the current particle system
  11839. */
  11840. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11841. /**
  11842. * Remove a specific limit velocity gradient
  11843. * @param gradient defines the gradient to remove
  11844. * @returns the current particle system
  11845. */
  11846. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11847. /**
  11848. * Adds a new drag gradient
  11849. * @param gradient defines the gradient to use (between 0 and 1)
  11850. * @param factor defines the drag value to affect to the specified gradient
  11851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11852. * @returns the current particle system
  11853. */
  11854. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11855. /**
  11856. * Remove a specific drag gradient
  11857. * @param gradient defines the gradient to remove
  11858. * @returns the current particle system
  11859. */
  11860. removeDragGradient(gradient: number): IParticleSystem;
  11861. /**
  11862. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11863. * @param gradient defines the gradient to use (between 0 and 1)
  11864. * @param factor defines the emit rate value to affect to the specified gradient
  11865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11866. * @returns the current particle system
  11867. */
  11868. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11869. /**
  11870. * Remove a specific emit rate gradient
  11871. * @param gradient defines the gradient to remove
  11872. * @returns the current particle system
  11873. */
  11874. removeEmitRateGradient(gradient: number): IParticleSystem;
  11875. /**
  11876. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11877. * @param gradient defines the gradient to use (between 0 and 1)
  11878. * @param factor defines the start size value to affect to the specified gradient
  11879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11880. * @returns the current particle system
  11881. */
  11882. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11883. /**
  11884. * Remove a specific start size gradient
  11885. * @param gradient defines the gradient to remove
  11886. * @returns the current particle system
  11887. */
  11888. removeStartSizeGradient(gradient: number): IParticleSystem;
  11889. private _createRampGradientTexture;
  11890. /**
  11891. * Gets the current list of ramp gradients.
  11892. * You must use addRampGradient and removeRampGradient to udpate this list
  11893. * @returns the list of ramp gradients
  11894. */
  11895. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11896. /** Force the system to rebuild all gradients that need to be resync */
  11897. forceRefreshGradients(): void;
  11898. private _syncRampGradientTexture;
  11899. /**
  11900. * Adds a new ramp gradient used to remap particle colors
  11901. * @param gradient defines the gradient to use (between 0 and 1)
  11902. * @param color defines the color to affect to the specified gradient
  11903. * @returns the current particle system
  11904. */
  11905. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11906. /**
  11907. * Remove a specific ramp gradient
  11908. * @param gradient defines the gradient to remove
  11909. * @returns the current particle system
  11910. */
  11911. removeRampGradient(gradient: number): ParticleSystem;
  11912. /**
  11913. * Adds a new color gradient
  11914. * @param gradient defines the gradient to use (between 0 and 1)
  11915. * @param color1 defines the color to affect to the specified gradient
  11916. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11917. * @returns this particle system
  11918. */
  11919. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11920. /**
  11921. * Remove a specific color gradient
  11922. * @param gradient defines the gradient to remove
  11923. * @returns this particle system
  11924. */
  11925. removeColorGradient(gradient: number): IParticleSystem;
  11926. private _fetchR;
  11927. protected _reset(): void;
  11928. private _resetEffect;
  11929. private _createVertexBuffers;
  11930. private _createIndexBuffer;
  11931. /**
  11932. * Gets the maximum number of particles active at the same time.
  11933. * @returns The max number of active particles.
  11934. */
  11935. getCapacity(): number;
  11936. /**
  11937. * Gets whether there are still active particles in the system.
  11938. * @returns True if it is alive, otherwise false.
  11939. */
  11940. isAlive(): boolean;
  11941. /**
  11942. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11943. * @returns True if it has been started, otherwise false.
  11944. */
  11945. isStarted(): boolean;
  11946. private _prepareSubEmitterInternalArray;
  11947. /**
  11948. * Starts the particle system and begins to emit
  11949. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11950. */
  11951. start(delay?: number): void;
  11952. /**
  11953. * Stops the particle system.
  11954. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  11955. */
  11956. stop(stopSubEmitters?: boolean): void;
  11957. /**
  11958. * Remove all active particles
  11959. */
  11960. reset(): void;
  11961. /**
  11962. * @hidden (for internal use only)
  11963. */
  11964. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11965. /**
  11966. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11967. * Its lifetime will start back at 0.
  11968. */
  11969. recycleParticle: (particle: Particle) => void;
  11970. private _stopSubEmitters;
  11971. private _createParticle;
  11972. private _removeFromRoot;
  11973. private _emitFromParticle;
  11974. private _update;
  11975. /** @hidden */
  11976. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11977. /** @hidden */
  11978. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11979. /** @hidden */
  11980. private _getEffect;
  11981. /**
  11982. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11983. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11984. */
  11985. animate(preWarmOnly?: boolean): void;
  11986. private _appendParticleVertices;
  11987. /**
  11988. * Rebuilds the particle system.
  11989. */
  11990. rebuild(): void;
  11991. /**
  11992. * Is this system ready to be used/rendered
  11993. * @return true if the system is ready
  11994. */
  11995. isReady(): boolean;
  11996. private _render;
  11997. /**
  11998. * Renders the particle system in its current state.
  11999. * @returns the current number of particles
  12000. */
  12001. render(): number;
  12002. /**
  12003. * Disposes the particle system and free the associated resources
  12004. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12005. */
  12006. dispose(disposeTexture?: boolean): void;
  12007. /**
  12008. * Clones the particle system.
  12009. * @param name The name of the cloned object
  12010. * @param newEmitter The new emitter to use
  12011. * @returns the cloned particle system
  12012. */
  12013. clone(name: string, newEmitter: any): ParticleSystem;
  12014. /**
  12015. * Serializes the particle system to a JSON object
  12016. * @param serializeTexture defines if the texture must be serialized as well
  12017. * @returns the JSON object
  12018. */
  12019. serialize(serializeTexture?: boolean): any;
  12020. /** @hidden */
  12021. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12022. /** @hidden */
  12023. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12024. /**
  12025. * Parses a JSON object to create a particle system.
  12026. * @param parsedParticleSystem The JSON object to parse
  12027. * @param scene The scene to create the particle system in
  12028. * @param rootUrl The root url to use to load external dependencies like texture
  12029. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12030. * @returns the Parsed particle system
  12031. */
  12032. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12033. }
  12034. }
  12035. declare module BABYLON {
  12036. /**
  12037. * A particle represents one of the element emitted by a particle system.
  12038. * This is mainly define by its coordinates, direction, velocity and age.
  12039. */
  12040. export class Particle {
  12041. /**
  12042. * The particle system the particle belongs to.
  12043. */
  12044. particleSystem: ParticleSystem;
  12045. private static _Count;
  12046. /**
  12047. * Unique ID of the particle
  12048. */
  12049. id: number;
  12050. /**
  12051. * The world position of the particle in the scene.
  12052. */
  12053. position: Vector3;
  12054. /**
  12055. * The world direction of the particle in the scene.
  12056. */
  12057. direction: Vector3;
  12058. /**
  12059. * The color of the particle.
  12060. */
  12061. color: Color4;
  12062. /**
  12063. * The color change of the particle per step.
  12064. */
  12065. colorStep: Color4;
  12066. /**
  12067. * Defines how long will the life of the particle be.
  12068. */
  12069. lifeTime: number;
  12070. /**
  12071. * The current age of the particle.
  12072. */
  12073. age: number;
  12074. /**
  12075. * The current size of the particle.
  12076. */
  12077. size: number;
  12078. /**
  12079. * The current scale of the particle.
  12080. */
  12081. scale: Vector2;
  12082. /**
  12083. * The current angle of the particle.
  12084. */
  12085. angle: number;
  12086. /**
  12087. * Defines how fast is the angle changing.
  12088. */
  12089. angularSpeed: number;
  12090. /**
  12091. * Defines the cell index used by the particle to be rendered from a sprite.
  12092. */
  12093. cellIndex: number;
  12094. /**
  12095. * The information required to support color remapping
  12096. */
  12097. remapData: Vector4;
  12098. /** @hidden */
  12099. _randomCellOffset?: number;
  12100. /** @hidden */
  12101. _initialDirection: Nullable<Vector3>;
  12102. /** @hidden */
  12103. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12104. /** @hidden */
  12105. _initialStartSpriteCellID: number;
  12106. /** @hidden */
  12107. _initialEndSpriteCellID: number;
  12108. /** @hidden */
  12109. _currentColorGradient: Nullable<ColorGradient>;
  12110. /** @hidden */
  12111. _currentColor1: Color4;
  12112. /** @hidden */
  12113. _currentColor2: Color4;
  12114. /** @hidden */
  12115. _currentSizeGradient: Nullable<FactorGradient>;
  12116. /** @hidden */
  12117. _currentSize1: number;
  12118. /** @hidden */
  12119. _currentSize2: number;
  12120. /** @hidden */
  12121. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12122. /** @hidden */
  12123. _currentAngularSpeed1: number;
  12124. /** @hidden */
  12125. _currentAngularSpeed2: number;
  12126. /** @hidden */
  12127. _currentVelocityGradient: Nullable<FactorGradient>;
  12128. /** @hidden */
  12129. _currentVelocity1: number;
  12130. /** @hidden */
  12131. _currentVelocity2: number;
  12132. /** @hidden */
  12133. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12134. /** @hidden */
  12135. _currentLimitVelocity1: number;
  12136. /** @hidden */
  12137. _currentLimitVelocity2: number;
  12138. /** @hidden */
  12139. _currentDragGradient: Nullable<FactorGradient>;
  12140. /** @hidden */
  12141. _currentDrag1: number;
  12142. /** @hidden */
  12143. _currentDrag2: number;
  12144. /** @hidden */
  12145. _randomNoiseCoordinates1: Vector3;
  12146. /** @hidden */
  12147. _randomNoiseCoordinates2: Vector3;
  12148. /** @hidden */
  12149. _localPosition?: Vector3;
  12150. /**
  12151. * Creates a new instance Particle
  12152. * @param particleSystem the particle system the particle belongs to
  12153. */
  12154. constructor(
  12155. /**
  12156. * The particle system the particle belongs to.
  12157. */
  12158. particleSystem: ParticleSystem);
  12159. private updateCellInfoFromSystem;
  12160. /**
  12161. * Defines how the sprite cell index is updated for the particle
  12162. */
  12163. updateCellIndex(): void;
  12164. /** @hidden */
  12165. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12166. /** @hidden */
  12167. _inheritParticleInfoToSubEmitters(): void;
  12168. /** @hidden */
  12169. _reset(): void;
  12170. /**
  12171. * Copy the properties of particle to another one.
  12172. * @param other the particle to copy the information to.
  12173. */
  12174. copyTo(other: Particle): void;
  12175. }
  12176. }
  12177. declare module BABYLON {
  12178. /**
  12179. * Particle emitter represents a volume emitting particles.
  12180. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12181. */
  12182. export interface IParticleEmitterType {
  12183. /**
  12184. * Called by the particle System when the direction is computed for the created particle.
  12185. * @param worldMatrix is the world matrix of the particle system
  12186. * @param directionToUpdate is the direction vector to update with the result
  12187. * @param particle is the particle we are computed the direction for
  12188. * @param isLocal defines if the direction should be set in local space
  12189. */
  12190. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12191. /**
  12192. * Called by the particle System when the position is computed for the created particle.
  12193. * @param worldMatrix is the world matrix of the particle system
  12194. * @param positionToUpdate is the position vector to update with the result
  12195. * @param particle is the particle we are computed the position for
  12196. * @param isLocal defines if the position should be set in local space
  12197. */
  12198. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12199. /**
  12200. * Clones the current emitter and returns a copy of it
  12201. * @returns the new emitter
  12202. */
  12203. clone(): IParticleEmitterType;
  12204. /**
  12205. * Called by the GPUParticleSystem to setup the update shader
  12206. * @param effect defines the update shader
  12207. */
  12208. applyToShader(effect: Effect): void;
  12209. /**
  12210. * Returns a string to use to update the GPU particles update shader
  12211. * @returns the effect defines string
  12212. */
  12213. getEffectDefines(): string;
  12214. /**
  12215. * Returns a string representing the class name
  12216. * @returns a string containing the class name
  12217. */
  12218. getClassName(): string;
  12219. /**
  12220. * Serializes the particle system to a JSON object.
  12221. * @returns the JSON object
  12222. */
  12223. serialize(): any;
  12224. /**
  12225. * Parse properties from a JSON object
  12226. * @param serializationObject defines the JSON object
  12227. * @param scene defines the hosting scene
  12228. */
  12229. parse(serializationObject: any, scene: Scene): void;
  12230. }
  12231. }
  12232. declare module BABYLON {
  12233. /**
  12234. * Particle emitter emitting particles from the inside of a box.
  12235. * It emits the particles randomly between 2 given directions.
  12236. */
  12237. export class BoxParticleEmitter implements IParticleEmitterType {
  12238. /**
  12239. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12240. */
  12241. direction1: Vector3;
  12242. /**
  12243. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12244. */
  12245. direction2: Vector3;
  12246. /**
  12247. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12248. */
  12249. minEmitBox: Vector3;
  12250. /**
  12251. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12252. */
  12253. maxEmitBox: Vector3;
  12254. /**
  12255. * Creates a new instance BoxParticleEmitter
  12256. */
  12257. constructor();
  12258. /**
  12259. * Called by the particle System when the direction is computed for the created particle.
  12260. * @param worldMatrix is the world matrix of the particle system
  12261. * @param directionToUpdate is the direction vector to update with the result
  12262. * @param particle is the particle we are computed the direction for
  12263. * @param isLocal defines if the direction should be set in local space
  12264. */
  12265. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12266. /**
  12267. * Called by the particle System when the position is computed for the created particle.
  12268. * @param worldMatrix is the world matrix of the particle system
  12269. * @param positionToUpdate is the position vector to update with the result
  12270. * @param particle is the particle we are computed the position for
  12271. * @param isLocal defines if the position should be set in local space
  12272. */
  12273. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12274. /**
  12275. * Clones the current emitter and returns a copy of it
  12276. * @returns the new emitter
  12277. */
  12278. clone(): BoxParticleEmitter;
  12279. /**
  12280. * Called by the GPUParticleSystem to setup the update shader
  12281. * @param effect defines the update shader
  12282. */
  12283. applyToShader(effect: Effect): void;
  12284. /**
  12285. * Returns a string to use to update the GPU particles update shader
  12286. * @returns a string containng the defines string
  12287. */
  12288. getEffectDefines(): string;
  12289. /**
  12290. * Returns the string "BoxParticleEmitter"
  12291. * @returns a string containing the class name
  12292. */
  12293. getClassName(): string;
  12294. /**
  12295. * Serializes the particle system to a JSON object.
  12296. * @returns the JSON object
  12297. */
  12298. serialize(): any;
  12299. /**
  12300. * Parse properties from a JSON object
  12301. * @param serializationObject defines the JSON object
  12302. */
  12303. parse(serializationObject: any): void;
  12304. }
  12305. }
  12306. declare module BABYLON {
  12307. /**
  12308. * Particle emitter emitting particles from the inside of a cone.
  12309. * It emits the particles alongside the cone volume from the base to the particle.
  12310. * The emission direction might be randomized.
  12311. */
  12312. export class ConeParticleEmitter implements IParticleEmitterType {
  12313. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12314. directionRandomizer: number;
  12315. private _radius;
  12316. private _angle;
  12317. private _height;
  12318. /**
  12319. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12320. */
  12321. radiusRange: number;
  12322. /**
  12323. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12324. */
  12325. heightRange: number;
  12326. /**
  12327. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12328. */
  12329. emitFromSpawnPointOnly: boolean;
  12330. /**
  12331. * Gets or sets the radius of the emission cone
  12332. */
  12333. get radius(): number;
  12334. set radius(value: number);
  12335. /**
  12336. * Gets or sets the angle of the emission cone
  12337. */
  12338. get angle(): number;
  12339. set angle(value: number);
  12340. private _buildHeight;
  12341. /**
  12342. * Creates a new instance ConeParticleEmitter
  12343. * @param radius the radius of the emission cone (1 by default)
  12344. * @param angle the cone base angle (PI by default)
  12345. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12346. */
  12347. constructor(radius?: number, angle?: number,
  12348. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12349. directionRandomizer?: number);
  12350. /**
  12351. * Called by the particle System when the direction is computed for the created particle.
  12352. * @param worldMatrix is the world matrix of the particle system
  12353. * @param directionToUpdate is the direction vector to update with the result
  12354. * @param particle is the particle we are computed the direction for
  12355. * @param isLocal defines if the direction should be set in local space
  12356. */
  12357. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12358. /**
  12359. * Called by the particle System when the position is computed for the created particle.
  12360. * @param worldMatrix is the world matrix of the particle system
  12361. * @param positionToUpdate is the position vector to update with the result
  12362. * @param particle is the particle we are computed the position for
  12363. * @param isLocal defines if the position should be set in local space
  12364. */
  12365. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12366. /**
  12367. * Clones the current emitter and returns a copy of it
  12368. * @returns the new emitter
  12369. */
  12370. clone(): ConeParticleEmitter;
  12371. /**
  12372. * Called by the GPUParticleSystem to setup the update shader
  12373. * @param effect defines the update shader
  12374. */
  12375. applyToShader(effect: Effect): void;
  12376. /**
  12377. * Returns a string to use to update the GPU particles update shader
  12378. * @returns a string containng the defines string
  12379. */
  12380. getEffectDefines(): string;
  12381. /**
  12382. * Returns the string "ConeParticleEmitter"
  12383. * @returns a string containing the class name
  12384. */
  12385. getClassName(): string;
  12386. /**
  12387. * Serializes the particle system to a JSON object.
  12388. * @returns the JSON object
  12389. */
  12390. serialize(): any;
  12391. /**
  12392. * Parse properties from a JSON object
  12393. * @param serializationObject defines the JSON object
  12394. */
  12395. parse(serializationObject: any): void;
  12396. }
  12397. }
  12398. declare module BABYLON {
  12399. /**
  12400. * Particle emitter emitting particles from the inside of a cylinder.
  12401. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12402. */
  12403. export class CylinderParticleEmitter implements IParticleEmitterType {
  12404. /**
  12405. * The radius of the emission cylinder.
  12406. */
  12407. radius: number;
  12408. /**
  12409. * The height of the emission cylinder.
  12410. */
  12411. height: number;
  12412. /**
  12413. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12414. */
  12415. radiusRange: number;
  12416. /**
  12417. * How much to randomize the particle direction [0-1].
  12418. */
  12419. directionRandomizer: number;
  12420. /**
  12421. * Creates a new instance CylinderParticleEmitter
  12422. * @param radius the radius of the emission cylinder (1 by default)
  12423. * @param height the height of the emission cylinder (1 by default)
  12424. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12425. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12426. */
  12427. constructor(
  12428. /**
  12429. * The radius of the emission cylinder.
  12430. */
  12431. radius?: number,
  12432. /**
  12433. * The height of the emission cylinder.
  12434. */
  12435. height?: number,
  12436. /**
  12437. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12438. */
  12439. radiusRange?: number,
  12440. /**
  12441. * How much to randomize the particle direction [0-1].
  12442. */
  12443. directionRandomizer?: number);
  12444. /**
  12445. * Called by the particle System when the direction is computed for the created particle.
  12446. * @param worldMatrix is the world matrix of the particle system
  12447. * @param directionToUpdate is the direction vector to update with the result
  12448. * @param particle is the particle we are computed the direction for
  12449. * @param isLocal defines if the direction should be set in local space
  12450. */
  12451. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12452. /**
  12453. * Called by the particle System when the position is computed for the created particle.
  12454. * @param worldMatrix is the world matrix of the particle system
  12455. * @param positionToUpdate is the position vector to update with the result
  12456. * @param particle is the particle we are computed the position for
  12457. * @param isLocal defines if the position should be set in local space
  12458. */
  12459. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12460. /**
  12461. * Clones the current emitter and returns a copy of it
  12462. * @returns the new emitter
  12463. */
  12464. clone(): CylinderParticleEmitter;
  12465. /**
  12466. * Called by the GPUParticleSystem to setup the update shader
  12467. * @param effect defines the update shader
  12468. */
  12469. applyToShader(effect: Effect): void;
  12470. /**
  12471. * Returns a string to use to update the GPU particles update shader
  12472. * @returns a string containng the defines string
  12473. */
  12474. getEffectDefines(): string;
  12475. /**
  12476. * Returns the string "CylinderParticleEmitter"
  12477. * @returns a string containing the class name
  12478. */
  12479. getClassName(): string;
  12480. /**
  12481. * Serializes the particle system to a JSON object.
  12482. * @returns the JSON object
  12483. */
  12484. serialize(): any;
  12485. /**
  12486. * Parse properties from a JSON object
  12487. * @param serializationObject defines the JSON object
  12488. */
  12489. parse(serializationObject: any): void;
  12490. }
  12491. /**
  12492. * Particle emitter emitting particles from the inside of a cylinder.
  12493. * It emits the particles randomly between two vectors.
  12494. */
  12495. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12496. /**
  12497. * The min limit of the emission direction.
  12498. */
  12499. direction1: Vector3;
  12500. /**
  12501. * The max limit of the emission direction.
  12502. */
  12503. direction2: Vector3;
  12504. /**
  12505. * Creates a new instance CylinderDirectedParticleEmitter
  12506. * @param radius the radius of the emission cylinder (1 by default)
  12507. * @param height the height of the emission cylinder (1 by default)
  12508. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12509. * @param direction1 the min limit of the emission direction (up vector by default)
  12510. * @param direction2 the max limit of the emission direction (up vector by default)
  12511. */
  12512. constructor(radius?: number, height?: number, radiusRange?: number,
  12513. /**
  12514. * The min limit of the emission direction.
  12515. */
  12516. direction1?: Vector3,
  12517. /**
  12518. * The max limit of the emission direction.
  12519. */
  12520. direction2?: Vector3);
  12521. /**
  12522. * Called by the particle System when the direction is computed for the created particle.
  12523. * @param worldMatrix is the world matrix of the particle system
  12524. * @param directionToUpdate is the direction vector to update with the result
  12525. * @param particle is the particle we are computed the direction for
  12526. */
  12527. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12528. /**
  12529. * Clones the current emitter and returns a copy of it
  12530. * @returns the new emitter
  12531. */
  12532. clone(): CylinderDirectedParticleEmitter;
  12533. /**
  12534. * Called by the GPUParticleSystem to setup the update shader
  12535. * @param effect defines the update shader
  12536. */
  12537. applyToShader(effect: Effect): void;
  12538. /**
  12539. * Returns a string to use to update the GPU particles update shader
  12540. * @returns a string containng the defines string
  12541. */
  12542. getEffectDefines(): string;
  12543. /**
  12544. * Returns the string "CylinderDirectedParticleEmitter"
  12545. * @returns a string containing the class name
  12546. */
  12547. getClassName(): string;
  12548. /**
  12549. * Serializes the particle system to a JSON object.
  12550. * @returns the JSON object
  12551. */
  12552. serialize(): any;
  12553. /**
  12554. * Parse properties from a JSON object
  12555. * @param serializationObject defines the JSON object
  12556. */
  12557. parse(serializationObject: any): void;
  12558. }
  12559. }
  12560. declare module BABYLON {
  12561. /**
  12562. * Particle emitter emitting particles from the inside of a hemisphere.
  12563. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12564. */
  12565. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12566. /**
  12567. * The radius of the emission hemisphere.
  12568. */
  12569. radius: number;
  12570. /**
  12571. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12572. */
  12573. radiusRange: number;
  12574. /**
  12575. * How much to randomize the particle direction [0-1].
  12576. */
  12577. directionRandomizer: number;
  12578. /**
  12579. * Creates a new instance HemisphericParticleEmitter
  12580. * @param radius the radius of the emission hemisphere (1 by default)
  12581. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12582. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12583. */
  12584. constructor(
  12585. /**
  12586. * The radius of the emission hemisphere.
  12587. */
  12588. radius?: number,
  12589. /**
  12590. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12591. */
  12592. radiusRange?: number,
  12593. /**
  12594. * How much to randomize the particle direction [0-1].
  12595. */
  12596. directionRandomizer?: number);
  12597. /**
  12598. * Called by the particle System when the direction is computed for the created particle.
  12599. * @param worldMatrix is the world matrix of the particle system
  12600. * @param directionToUpdate is the direction vector to update with the result
  12601. * @param particle is the particle we are computed the direction for
  12602. * @param isLocal defines if the direction should be set in local space
  12603. */
  12604. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12605. /**
  12606. * Called by the particle System when the position is computed for the created particle.
  12607. * @param worldMatrix is the world matrix of the particle system
  12608. * @param positionToUpdate is the position vector to update with the result
  12609. * @param particle is the particle we are computed the position for
  12610. * @param isLocal defines if the position should be set in local space
  12611. */
  12612. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12613. /**
  12614. * Clones the current emitter and returns a copy of it
  12615. * @returns the new emitter
  12616. */
  12617. clone(): HemisphericParticleEmitter;
  12618. /**
  12619. * Called by the GPUParticleSystem to setup the update shader
  12620. * @param effect defines the update shader
  12621. */
  12622. applyToShader(effect: Effect): void;
  12623. /**
  12624. * Returns a string to use to update the GPU particles update shader
  12625. * @returns a string containng the defines string
  12626. */
  12627. getEffectDefines(): string;
  12628. /**
  12629. * Returns the string "HemisphericParticleEmitter"
  12630. * @returns a string containing the class name
  12631. */
  12632. getClassName(): string;
  12633. /**
  12634. * Serializes the particle system to a JSON object.
  12635. * @returns the JSON object
  12636. */
  12637. serialize(): any;
  12638. /**
  12639. * Parse properties from a JSON object
  12640. * @param serializationObject defines the JSON object
  12641. */
  12642. parse(serializationObject: any): void;
  12643. }
  12644. }
  12645. declare module BABYLON {
  12646. /**
  12647. * Particle emitter emitting particles from a point.
  12648. * It emits the particles randomly between 2 given directions.
  12649. */
  12650. export class PointParticleEmitter implements IParticleEmitterType {
  12651. /**
  12652. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12653. */
  12654. direction1: Vector3;
  12655. /**
  12656. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12657. */
  12658. direction2: Vector3;
  12659. /**
  12660. * Creates a new instance PointParticleEmitter
  12661. */
  12662. constructor();
  12663. /**
  12664. * Called by the particle System when the direction is computed for the created particle.
  12665. * @param worldMatrix is the world matrix of the particle system
  12666. * @param directionToUpdate is the direction vector to update with the result
  12667. * @param particle is the particle we are computed the direction for
  12668. * @param isLocal defines if the direction should be set in local space
  12669. */
  12670. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12671. /**
  12672. * Called by the particle System when the position is computed for the created particle.
  12673. * @param worldMatrix is the world matrix of the particle system
  12674. * @param positionToUpdate is the position vector to update with the result
  12675. * @param particle is the particle we are computed the position for
  12676. * @param isLocal defines if the position should be set in local space
  12677. */
  12678. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12679. /**
  12680. * Clones the current emitter and returns a copy of it
  12681. * @returns the new emitter
  12682. */
  12683. clone(): PointParticleEmitter;
  12684. /**
  12685. * Called by the GPUParticleSystem to setup the update shader
  12686. * @param effect defines the update shader
  12687. */
  12688. applyToShader(effect: Effect): void;
  12689. /**
  12690. * Returns a string to use to update the GPU particles update shader
  12691. * @returns a string containng the defines string
  12692. */
  12693. getEffectDefines(): string;
  12694. /**
  12695. * Returns the string "PointParticleEmitter"
  12696. * @returns a string containing the class name
  12697. */
  12698. getClassName(): string;
  12699. /**
  12700. * Serializes the particle system to a JSON object.
  12701. * @returns the JSON object
  12702. */
  12703. serialize(): any;
  12704. /**
  12705. * Parse properties from a JSON object
  12706. * @param serializationObject defines the JSON object
  12707. */
  12708. parse(serializationObject: any): void;
  12709. }
  12710. }
  12711. declare module BABYLON {
  12712. /**
  12713. * Particle emitter emitting particles from the inside of a sphere.
  12714. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12715. */
  12716. export class SphereParticleEmitter implements IParticleEmitterType {
  12717. /**
  12718. * The radius of the emission sphere.
  12719. */
  12720. radius: number;
  12721. /**
  12722. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12723. */
  12724. radiusRange: number;
  12725. /**
  12726. * How much to randomize the particle direction [0-1].
  12727. */
  12728. directionRandomizer: number;
  12729. /**
  12730. * Creates a new instance SphereParticleEmitter
  12731. * @param radius the radius of the emission sphere (1 by default)
  12732. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12733. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12734. */
  12735. constructor(
  12736. /**
  12737. * The radius of the emission sphere.
  12738. */
  12739. radius?: number,
  12740. /**
  12741. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12742. */
  12743. radiusRange?: number,
  12744. /**
  12745. * How much to randomize the particle direction [0-1].
  12746. */
  12747. directionRandomizer?: number);
  12748. /**
  12749. * Called by the particle System when the direction is computed for the created particle.
  12750. * @param worldMatrix is the world matrix of the particle system
  12751. * @param directionToUpdate is the direction vector to update with the result
  12752. * @param particle is the particle we are computed the direction for
  12753. * @param isLocal defines if the direction should be set in local space
  12754. */
  12755. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12756. /**
  12757. * Called by the particle System when the position is computed for the created particle.
  12758. * @param worldMatrix is the world matrix of the particle system
  12759. * @param positionToUpdate is the position vector to update with the result
  12760. * @param particle is the particle we are computed the position for
  12761. * @param isLocal defines if the position should be set in local space
  12762. */
  12763. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12764. /**
  12765. * Clones the current emitter and returns a copy of it
  12766. * @returns the new emitter
  12767. */
  12768. clone(): SphereParticleEmitter;
  12769. /**
  12770. * Called by the GPUParticleSystem to setup the update shader
  12771. * @param effect defines the update shader
  12772. */
  12773. applyToShader(effect: Effect): void;
  12774. /**
  12775. * Returns a string to use to update the GPU particles update shader
  12776. * @returns a string containng the defines string
  12777. */
  12778. getEffectDefines(): string;
  12779. /**
  12780. * Returns the string "SphereParticleEmitter"
  12781. * @returns a string containing the class name
  12782. */
  12783. getClassName(): string;
  12784. /**
  12785. * Serializes the particle system to a JSON object.
  12786. * @returns the JSON object
  12787. */
  12788. serialize(): any;
  12789. /**
  12790. * Parse properties from a JSON object
  12791. * @param serializationObject defines the JSON object
  12792. */
  12793. parse(serializationObject: any): void;
  12794. }
  12795. /**
  12796. * Particle emitter emitting particles from the inside of a sphere.
  12797. * It emits the particles randomly between two vectors.
  12798. */
  12799. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12800. /**
  12801. * The min limit of the emission direction.
  12802. */
  12803. direction1: Vector3;
  12804. /**
  12805. * The max limit of the emission direction.
  12806. */
  12807. direction2: Vector3;
  12808. /**
  12809. * Creates a new instance SphereDirectedParticleEmitter
  12810. * @param radius the radius of the emission sphere (1 by default)
  12811. * @param direction1 the min limit of the emission direction (up vector by default)
  12812. * @param direction2 the max limit of the emission direction (up vector by default)
  12813. */
  12814. constructor(radius?: number,
  12815. /**
  12816. * The min limit of the emission direction.
  12817. */
  12818. direction1?: Vector3,
  12819. /**
  12820. * The max limit of the emission direction.
  12821. */
  12822. direction2?: Vector3);
  12823. /**
  12824. * Called by the particle System when the direction is computed for the created particle.
  12825. * @param worldMatrix is the world matrix of the particle system
  12826. * @param directionToUpdate is the direction vector to update with the result
  12827. * @param particle is the particle we are computed the direction for
  12828. */
  12829. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12830. /**
  12831. * Clones the current emitter and returns a copy of it
  12832. * @returns the new emitter
  12833. */
  12834. clone(): SphereDirectedParticleEmitter;
  12835. /**
  12836. * Called by the GPUParticleSystem to setup the update shader
  12837. * @param effect defines the update shader
  12838. */
  12839. applyToShader(effect: Effect): void;
  12840. /**
  12841. * Returns a string to use to update the GPU particles update shader
  12842. * @returns a string containng the defines string
  12843. */
  12844. getEffectDefines(): string;
  12845. /**
  12846. * Returns the string "SphereDirectedParticleEmitter"
  12847. * @returns a string containing the class name
  12848. */
  12849. getClassName(): string;
  12850. /**
  12851. * Serializes the particle system to a JSON object.
  12852. * @returns the JSON object
  12853. */
  12854. serialize(): any;
  12855. /**
  12856. * Parse properties from a JSON object
  12857. * @param serializationObject defines the JSON object
  12858. */
  12859. parse(serializationObject: any): void;
  12860. }
  12861. }
  12862. declare module BABYLON {
  12863. /**
  12864. * Particle emitter emitting particles from a custom list of positions.
  12865. */
  12866. export class CustomParticleEmitter implements IParticleEmitterType {
  12867. /**
  12868. * Gets or sets the position generator that will create the inital position of each particle.
  12869. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12870. */
  12871. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12872. /**
  12873. * Gets or sets the destination generator that will create the final destination of each particle.
  12874. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12875. */
  12876. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12877. /**
  12878. * Creates a new instance CustomParticleEmitter
  12879. */
  12880. constructor();
  12881. /**
  12882. * Called by the particle System when the direction is computed for the created particle.
  12883. * @param worldMatrix is the world matrix of the particle system
  12884. * @param directionToUpdate is the direction vector to update with the result
  12885. * @param particle is the particle we are computed the direction for
  12886. * @param isLocal defines if the direction should be set in local space
  12887. */
  12888. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12889. /**
  12890. * Called by the particle System when the position is computed for the created particle.
  12891. * @param worldMatrix is the world matrix of the particle system
  12892. * @param positionToUpdate is the position vector to update with the result
  12893. * @param particle is the particle we are computed the position for
  12894. * @param isLocal defines if the position should be set in local space
  12895. */
  12896. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12897. /**
  12898. * Clones the current emitter and returns a copy of it
  12899. * @returns the new emitter
  12900. */
  12901. clone(): CustomParticleEmitter;
  12902. /**
  12903. * Called by the GPUParticleSystem to setup the update shader
  12904. * @param effect defines the update shader
  12905. */
  12906. applyToShader(effect: Effect): void;
  12907. /**
  12908. * Returns a string to use to update the GPU particles update shader
  12909. * @returns a string containng the defines string
  12910. */
  12911. getEffectDefines(): string;
  12912. /**
  12913. * Returns the string "PointParticleEmitter"
  12914. * @returns a string containing the class name
  12915. */
  12916. getClassName(): string;
  12917. /**
  12918. * Serializes the particle system to a JSON object.
  12919. * @returns the JSON object
  12920. */
  12921. serialize(): any;
  12922. /**
  12923. * Parse properties from a JSON object
  12924. * @param serializationObject defines the JSON object
  12925. */
  12926. parse(serializationObject: any): void;
  12927. }
  12928. }
  12929. declare module BABYLON {
  12930. /**
  12931. * Particle emitter emitting particles from the inside of a box.
  12932. * It emits the particles randomly between 2 given directions.
  12933. */
  12934. export class MeshParticleEmitter implements IParticleEmitterType {
  12935. private _indices;
  12936. private _positions;
  12937. private _normals;
  12938. private _storedNormal;
  12939. private _mesh;
  12940. /**
  12941. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12942. */
  12943. direction1: Vector3;
  12944. /**
  12945. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12946. */
  12947. direction2: Vector3;
  12948. /**
  12949. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12950. */
  12951. useMeshNormalsForDirection: boolean;
  12952. /** Defines the mesh to use as source */
  12953. get mesh(): Nullable<AbstractMesh>;
  12954. set mesh(value: Nullable<AbstractMesh>);
  12955. /**
  12956. * Creates a new instance MeshParticleEmitter
  12957. * @param mesh defines the mesh to use as source
  12958. */
  12959. constructor(mesh?: Nullable<AbstractMesh>);
  12960. /**
  12961. * Called by the particle System when the direction is computed for the created particle.
  12962. * @param worldMatrix is the world matrix of the particle system
  12963. * @param directionToUpdate is the direction vector to update with the result
  12964. * @param particle is the particle we are computed the direction for
  12965. * @param isLocal defines if the direction should be set in local space
  12966. */
  12967. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12968. /**
  12969. * Called by the particle System when the position is computed for the created particle.
  12970. * @param worldMatrix is the world matrix of the particle system
  12971. * @param positionToUpdate is the position vector to update with the result
  12972. * @param particle is the particle we are computed the position for
  12973. * @param isLocal defines if the position should be set in local space
  12974. */
  12975. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12976. /**
  12977. * Clones the current emitter and returns a copy of it
  12978. * @returns the new emitter
  12979. */
  12980. clone(): MeshParticleEmitter;
  12981. /**
  12982. * Called by the GPUParticleSystem to setup the update shader
  12983. * @param effect defines the update shader
  12984. */
  12985. applyToShader(effect: Effect): void;
  12986. /**
  12987. * Returns a string to use to update the GPU particles update shader
  12988. * @returns a string containng the defines string
  12989. */
  12990. getEffectDefines(): string;
  12991. /**
  12992. * Returns the string "BoxParticleEmitter"
  12993. * @returns a string containing the class name
  12994. */
  12995. getClassName(): string;
  12996. /**
  12997. * Serializes the particle system to a JSON object.
  12998. * @returns the JSON object
  12999. */
  13000. serialize(): any;
  13001. /**
  13002. * Parse properties from a JSON object
  13003. * @param serializationObject defines the JSON object
  13004. * @param scene defines the hosting scene
  13005. */
  13006. parse(serializationObject: any, scene: Scene): void;
  13007. }
  13008. }
  13009. declare module BABYLON {
  13010. /**
  13011. * Interface representing a particle system in Babylon.js.
  13012. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13013. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13014. */
  13015. export interface IParticleSystem {
  13016. /**
  13017. * List of animations used by the particle system.
  13018. */
  13019. animations: Animation[];
  13020. /**
  13021. * The id of the Particle system.
  13022. */
  13023. id: string;
  13024. /**
  13025. * The name of the Particle system.
  13026. */
  13027. name: string;
  13028. /**
  13029. * The emitter represents the Mesh or position we are attaching the particle system to.
  13030. */
  13031. emitter: Nullable<AbstractMesh | Vector3>;
  13032. /**
  13033. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13034. */
  13035. isBillboardBased: boolean;
  13036. /**
  13037. * The rendering group used by the Particle system to chose when to render.
  13038. */
  13039. renderingGroupId: number;
  13040. /**
  13041. * The layer mask we are rendering the particles through.
  13042. */
  13043. layerMask: number;
  13044. /**
  13045. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13046. */
  13047. updateSpeed: number;
  13048. /**
  13049. * The amount of time the particle system is running (depends of the overall update speed).
  13050. */
  13051. targetStopDuration: number;
  13052. /**
  13053. * The texture used to render each particle. (this can be a spritesheet)
  13054. */
  13055. particleTexture: Nullable<Texture>;
  13056. /**
  13057. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13058. */
  13059. blendMode: number;
  13060. /**
  13061. * Minimum life time of emitting particles.
  13062. */
  13063. minLifeTime: number;
  13064. /**
  13065. * Maximum life time of emitting particles.
  13066. */
  13067. maxLifeTime: number;
  13068. /**
  13069. * Minimum Size of emitting particles.
  13070. */
  13071. minSize: number;
  13072. /**
  13073. * Maximum Size of emitting particles.
  13074. */
  13075. maxSize: number;
  13076. /**
  13077. * Minimum scale of emitting particles on X axis.
  13078. */
  13079. minScaleX: number;
  13080. /**
  13081. * Maximum scale of emitting particles on X axis.
  13082. */
  13083. maxScaleX: number;
  13084. /**
  13085. * Minimum scale of emitting particles on Y axis.
  13086. */
  13087. minScaleY: number;
  13088. /**
  13089. * Maximum scale of emitting particles on Y axis.
  13090. */
  13091. maxScaleY: number;
  13092. /**
  13093. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13094. */
  13095. color1: Color4;
  13096. /**
  13097. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13098. */
  13099. color2: Color4;
  13100. /**
  13101. * Color the particle will have at the end of its lifetime.
  13102. */
  13103. colorDead: Color4;
  13104. /**
  13105. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13106. */
  13107. emitRate: number;
  13108. /**
  13109. * You can use gravity if you want to give an orientation to your particles.
  13110. */
  13111. gravity: Vector3;
  13112. /**
  13113. * Minimum power of emitting particles.
  13114. */
  13115. minEmitPower: number;
  13116. /**
  13117. * Maximum power of emitting particles.
  13118. */
  13119. maxEmitPower: number;
  13120. /**
  13121. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13122. */
  13123. minAngularSpeed: number;
  13124. /**
  13125. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13126. */
  13127. maxAngularSpeed: number;
  13128. /**
  13129. * Gets or sets the minimal initial rotation in radians.
  13130. */
  13131. minInitialRotation: number;
  13132. /**
  13133. * Gets or sets the maximal initial rotation in radians.
  13134. */
  13135. maxInitialRotation: number;
  13136. /**
  13137. * The particle emitter type defines the emitter used by the particle system.
  13138. * It can be for example box, sphere, or cone...
  13139. */
  13140. particleEmitterType: Nullable<IParticleEmitterType>;
  13141. /**
  13142. * Defines the delay in milliseconds before starting the system (0 by default)
  13143. */
  13144. startDelay: number;
  13145. /**
  13146. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  13147. */
  13148. preWarmCycles: number;
  13149. /**
  13150. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13151. */
  13152. preWarmStepOffset: number;
  13153. /**
  13154. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  13155. */
  13156. spriteCellChangeSpeed: number;
  13157. /**
  13158. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13159. */
  13160. startSpriteCellID: number;
  13161. /**
  13162. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13163. */
  13164. endSpriteCellID: number;
  13165. /**
  13166. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13167. */
  13168. spriteCellWidth: number;
  13169. /**
  13170. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13171. */
  13172. spriteCellHeight: number;
  13173. /**
  13174. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13175. */
  13176. spriteRandomStartCell: boolean;
  13177. /**
  13178. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13179. */
  13180. isAnimationSheetEnabled: boolean;
  13181. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13182. translationPivot: Vector2;
  13183. /**
  13184. * Gets or sets a texture used to add random noise to particle positions
  13185. */
  13186. noiseTexture: Nullable<BaseTexture>;
  13187. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13188. noiseStrength: Vector3;
  13189. /**
  13190. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13191. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13192. */
  13193. billboardMode: number;
  13194. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13195. limitVelocityDamping: number;
  13196. /**
  13197. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13198. */
  13199. beginAnimationOnStart: boolean;
  13200. /**
  13201. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13202. */
  13203. beginAnimationFrom: number;
  13204. /**
  13205. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13206. */
  13207. beginAnimationTo: number;
  13208. /**
  13209. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13210. */
  13211. beginAnimationLoop: boolean;
  13212. /**
  13213. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13214. */
  13215. disposeOnStop: boolean;
  13216. /**
  13217. * Specifies if the particles are updated in emitter local space or world space
  13218. */
  13219. isLocal: boolean;
  13220. /** Snippet ID if the particle system was created from the snippet server */
  13221. snippetId: string;
  13222. /**
  13223. * Gets the maximum number of particles active at the same time.
  13224. * @returns The max number of active particles.
  13225. */
  13226. getCapacity(): number;
  13227. /**
  13228. * Gets the number of particles active at the same time.
  13229. * @returns The number of active particles.
  13230. */
  13231. getActiveCount(): number;
  13232. /**
  13233. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13234. * @returns True if it has been started, otherwise false.
  13235. */
  13236. isStarted(): boolean;
  13237. /**
  13238. * Animates the particle system for this frame.
  13239. */
  13240. animate(): void;
  13241. /**
  13242. * Renders the particle system in its current state.
  13243. * @returns the current number of particles
  13244. */
  13245. render(): number;
  13246. /**
  13247. * Dispose the particle system and frees its associated resources.
  13248. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13249. */
  13250. dispose(disposeTexture?: boolean): void;
  13251. /**
  13252. * Clones the particle system.
  13253. * @param name The name of the cloned object
  13254. * @param newEmitter The new emitter to use
  13255. * @returns the cloned particle system
  13256. */
  13257. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13258. /**
  13259. * Serializes the particle system to a JSON object
  13260. * @param serializeTexture defines if the texture must be serialized as well
  13261. * @returns the JSON object
  13262. */
  13263. serialize(serializeTexture: boolean): any;
  13264. /**
  13265. * Rebuild the particle system
  13266. */
  13267. rebuild(): void;
  13268. /** Force the system to rebuild all gradients that need to be resync */
  13269. forceRefreshGradients(): void;
  13270. /**
  13271. * Starts the particle system and begins to emit
  13272. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13273. */
  13274. start(delay?: number): void;
  13275. /**
  13276. * Stops the particle system.
  13277. */
  13278. stop(): void;
  13279. /**
  13280. * Remove all active particles
  13281. */
  13282. reset(): void;
  13283. /**
  13284. * Gets a boolean indicating that the system is stopping
  13285. * @returns true if the system is currently stopping
  13286. */
  13287. isStopping(): boolean;
  13288. /**
  13289. * Is this system ready to be used/rendered
  13290. * @return true if the system is ready
  13291. */
  13292. isReady(): boolean;
  13293. /**
  13294. * Returns the string "ParticleSystem"
  13295. * @returns a string containing the class name
  13296. */
  13297. getClassName(): string;
  13298. /**
  13299. * Adds a new color gradient
  13300. * @param gradient defines the gradient to use (between 0 and 1)
  13301. * @param color1 defines the color to affect to the specified gradient
  13302. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13303. * @returns the current particle system
  13304. */
  13305. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13306. /**
  13307. * Remove a specific color gradient
  13308. * @param gradient defines the gradient to remove
  13309. * @returns the current particle system
  13310. */
  13311. removeColorGradient(gradient: number): IParticleSystem;
  13312. /**
  13313. * Adds a new size gradient
  13314. * @param gradient defines the gradient to use (between 0 and 1)
  13315. * @param factor defines the size factor to affect to the specified gradient
  13316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13317. * @returns the current particle system
  13318. */
  13319. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13320. /**
  13321. * Remove a specific size gradient
  13322. * @param gradient defines the gradient to remove
  13323. * @returns the current particle system
  13324. */
  13325. removeSizeGradient(gradient: number): IParticleSystem;
  13326. /**
  13327. * Gets the current list of color gradients.
  13328. * You must use addColorGradient and removeColorGradient to udpate this list
  13329. * @returns the list of color gradients
  13330. */
  13331. getColorGradients(): Nullable<Array<ColorGradient>>;
  13332. /**
  13333. * Gets the current list of size gradients.
  13334. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13335. * @returns the list of size gradients
  13336. */
  13337. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13338. /**
  13339. * Gets the current list of angular speed gradients.
  13340. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13341. * @returns the list of angular speed gradients
  13342. */
  13343. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13344. /**
  13345. * Adds a new angular speed gradient
  13346. * @param gradient defines the gradient to use (between 0 and 1)
  13347. * @param factor defines the angular speed to affect to the specified gradient
  13348. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13349. * @returns the current particle system
  13350. */
  13351. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13352. /**
  13353. * Remove a specific angular speed gradient
  13354. * @param gradient defines the gradient to remove
  13355. * @returns the current particle system
  13356. */
  13357. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13358. /**
  13359. * Gets the current list of velocity gradients.
  13360. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13361. * @returns the list of velocity gradients
  13362. */
  13363. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13364. /**
  13365. * Adds a new velocity gradient
  13366. * @param gradient defines the gradient to use (between 0 and 1)
  13367. * @param factor defines the velocity to affect to the specified gradient
  13368. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13369. * @returns the current particle system
  13370. */
  13371. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13372. /**
  13373. * Remove a specific velocity gradient
  13374. * @param gradient defines the gradient to remove
  13375. * @returns the current particle system
  13376. */
  13377. removeVelocityGradient(gradient: number): IParticleSystem;
  13378. /**
  13379. * Gets the current list of limit velocity gradients.
  13380. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13381. * @returns the list of limit velocity gradients
  13382. */
  13383. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13384. /**
  13385. * Adds a new limit velocity gradient
  13386. * @param gradient defines the gradient to use (between 0 and 1)
  13387. * @param factor defines the limit velocity to affect to the specified gradient
  13388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13389. * @returns the current particle system
  13390. */
  13391. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13392. /**
  13393. * Remove a specific limit velocity gradient
  13394. * @param gradient defines the gradient to remove
  13395. * @returns the current particle system
  13396. */
  13397. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13398. /**
  13399. * Adds a new drag gradient
  13400. * @param gradient defines the gradient to use (between 0 and 1)
  13401. * @param factor defines the drag to affect to the specified gradient
  13402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13403. * @returns the current particle system
  13404. */
  13405. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13406. /**
  13407. * Remove a specific drag gradient
  13408. * @param gradient defines the gradient to remove
  13409. * @returns the current particle system
  13410. */
  13411. removeDragGradient(gradient: number): IParticleSystem;
  13412. /**
  13413. * Gets the current list of drag gradients.
  13414. * You must use addDragGradient and removeDragGradient to udpate this list
  13415. * @returns the list of drag gradients
  13416. */
  13417. getDragGradients(): Nullable<Array<FactorGradient>>;
  13418. /**
  13419. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13420. * @param gradient defines the gradient to use (between 0 and 1)
  13421. * @param factor defines the emit rate to affect to the specified gradient
  13422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13423. * @returns the current particle system
  13424. */
  13425. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13426. /**
  13427. * Remove a specific emit rate gradient
  13428. * @param gradient defines the gradient to remove
  13429. * @returns the current particle system
  13430. */
  13431. removeEmitRateGradient(gradient: number): IParticleSystem;
  13432. /**
  13433. * Gets the current list of emit rate gradients.
  13434. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13435. * @returns the list of emit rate gradients
  13436. */
  13437. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13438. /**
  13439. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13440. * @param gradient defines the gradient to use (between 0 and 1)
  13441. * @param factor defines the start size to affect to the specified gradient
  13442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13443. * @returns the current particle system
  13444. */
  13445. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13446. /**
  13447. * Remove a specific start size gradient
  13448. * @param gradient defines the gradient to remove
  13449. * @returns the current particle system
  13450. */
  13451. removeStartSizeGradient(gradient: number): IParticleSystem;
  13452. /**
  13453. * Gets the current list of start size gradients.
  13454. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13455. * @returns the list of start size gradients
  13456. */
  13457. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13458. /**
  13459. * Adds a new life time gradient
  13460. * @param gradient defines the gradient to use (between 0 and 1)
  13461. * @param factor defines the life time factor to affect to the specified gradient
  13462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13463. * @returns the current particle system
  13464. */
  13465. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13466. /**
  13467. * Remove a specific life time gradient
  13468. * @param gradient defines the gradient to remove
  13469. * @returns the current particle system
  13470. */
  13471. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13472. /**
  13473. * Gets the current list of life time gradients.
  13474. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13475. * @returns the list of life time gradients
  13476. */
  13477. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13478. /**
  13479. * Gets the current list of color gradients.
  13480. * You must use addColorGradient and removeColorGradient to udpate this list
  13481. * @returns the list of color gradients
  13482. */
  13483. getColorGradients(): Nullable<Array<ColorGradient>>;
  13484. /**
  13485. * Adds a new ramp gradient used to remap particle colors
  13486. * @param gradient defines the gradient to use (between 0 and 1)
  13487. * @param color defines the color to affect to the specified gradient
  13488. * @returns the current particle system
  13489. */
  13490. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13491. /**
  13492. * Gets the current list of ramp gradients.
  13493. * You must use addRampGradient and removeRampGradient to udpate this list
  13494. * @returns the list of ramp gradients
  13495. */
  13496. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13497. /** Gets or sets a boolean indicating that ramp gradients must be used
  13498. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13499. */
  13500. useRampGradients: boolean;
  13501. /**
  13502. * Adds a new color remap gradient
  13503. * @param gradient defines the gradient to use (between 0 and 1)
  13504. * @param min defines the color remap minimal range
  13505. * @param max defines the color remap maximal range
  13506. * @returns the current particle system
  13507. */
  13508. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13509. /**
  13510. * Gets the current list of color remap gradients.
  13511. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13512. * @returns the list of color remap gradients
  13513. */
  13514. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13515. /**
  13516. * Adds a new alpha remap gradient
  13517. * @param gradient defines the gradient to use (between 0 and 1)
  13518. * @param min defines the alpha remap minimal range
  13519. * @param max defines the alpha remap maximal range
  13520. * @returns the current particle system
  13521. */
  13522. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13523. /**
  13524. * Gets the current list of alpha remap gradients.
  13525. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13526. * @returns the list of alpha remap gradients
  13527. */
  13528. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13529. /**
  13530. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13531. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13532. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13533. * @returns the emitter
  13534. */
  13535. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13536. /**
  13537. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13538. * @param radius The radius of the hemisphere to emit from
  13539. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13540. * @returns the emitter
  13541. */
  13542. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13543. /**
  13544. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13545. * @param radius The radius of the sphere to emit from
  13546. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13547. * @returns the emitter
  13548. */
  13549. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13550. /**
  13551. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13552. * @param radius The radius of the sphere to emit from
  13553. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13554. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13555. * @returns the emitter
  13556. */
  13557. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13558. /**
  13559. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13560. * @param radius The radius of the emission cylinder
  13561. * @param height The height of the emission cylinder
  13562. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13563. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13564. * @returns the emitter
  13565. */
  13566. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13567. /**
  13568. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13569. * @param radius The radius of the cylinder to emit from
  13570. * @param height The height of the emission cylinder
  13571. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13572. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13573. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13574. * @returns the emitter
  13575. */
  13576. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13577. /**
  13578. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13579. * @param radius The radius of the cone to emit from
  13580. * @param angle The base angle of the cone
  13581. * @returns the emitter
  13582. */
  13583. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13584. /**
  13585. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13586. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13587. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13588. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13589. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13590. * @returns the emitter
  13591. */
  13592. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13593. /**
  13594. * Get hosting scene
  13595. * @returns the scene
  13596. */
  13597. getScene(): Scene;
  13598. }
  13599. }
  13600. declare module BABYLON {
  13601. /**
  13602. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13603. * @see https://doc.babylonjs.com/how_to/transformnode
  13604. */
  13605. export class TransformNode extends Node {
  13606. /**
  13607. * Object will not rotate to face the camera
  13608. */
  13609. static BILLBOARDMODE_NONE: number;
  13610. /**
  13611. * Object will rotate to face the camera but only on the x axis
  13612. */
  13613. static BILLBOARDMODE_X: number;
  13614. /**
  13615. * Object will rotate to face the camera but only on the y axis
  13616. */
  13617. static BILLBOARDMODE_Y: number;
  13618. /**
  13619. * Object will rotate to face the camera but only on the z axis
  13620. */
  13621. static BILLBOARDMODE_Z: number;
  13622. /**
  13623. * Object will rotate to face the camera
  13624. */
  13625. static BILLBOARDMODE_ALL: number;
  13626. /**
  13627. * Object will rotate to face the camera's position instead of orientation
  13628. */
  13629. static BILLBOARDMODE_USE_POSITION: number;
  13630. private _forward;
  13631. private _forwardInverted;
  13632. private _up;
  13633. private _right;
  13634. private _rightInverted;
  13635. private _position;
  13636. private _rotation;
  13637. private _rotationQuaternion;
  13638. protected _scaling: Vector3;
  13639. protected _isDirty: boolean;
  13640. private _transformToBoneReferal;
  13641. private _isAbsoluteSynced;
  13642. private _billboardMode;
  13643. /**
  13644. * Gets or sets the billboard mode. Default is 0.
  13645. *
  13646. * | Value | Type | Description |
  13647. * | --- | --- | --- |
  13648. * | 0 | BILLBOARDMODE_NONE | |
  13649. * | 1 | BILLBOARDMODE_X | |
  13650. * | 2 | BILLBOARDMODE_Y | |
  13651. * | 4 | BILLBOARDMODE_Z | |
  13652. * | 7 | BILLBOARDMODE_ALL | |
  13653. *
  13654. */
  13655. get billboardMode(): number;
  13656. set billboardMode(value: number);
  13657. private _preserveParentRotationForBillboard;
  13658. /**
  13659. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13660. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13661. */
  13662. get preserveParentRotationForBillboard(): boolean;
  13663. set preserveParentRotationForBillboard(value: boolean);
  13664. /**
  13665. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  13666. */
  13667. scalingDeterminant: number;
  13668. private _infiniteDistance;
  13669. /**
  13670. * Gets or sets the distance of the object to max, often used by skybox
  13671. */
  13672. get infiniteDistance(): boolean;
  13673. set infiniteDistance(value: boolean);
  13674. /**
  13675. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13676. * By default the system will update normals to compensate
  13677. */
  13678. ignoreNonUniformScaling: boolean;
  13679. /**
  13680. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13681. */
  13682. reIntegrateRotationIntoRotationQuaternion: boolean;
  13683. /** @hidden */
  13684. _poseMatrix: Nullable<Matrix>;
  13685. /** @hidden */
  13686. _localMatrix: Matrix;
  13687. private _usePivotMatrix;
  13688. private _absolutePosition;
  13689. private _absoluteScaling;
  13690. private _absoluteRotationQuaternion;
  13691. private _pivotMatrix;
  13692. private _pivotMatrixInverse;
  13693. protected _postMultiplyPivotMatrix: boolean;
  13694. protected _isWorldMatrixFrozen: boolean;
  13695. /** @hidden */
  13696. _indexInSceneTransformNodesArray: number;
  13697. /**
  13698. * An event triggered after the world matrix is updated
  13699. */
  13700. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13701. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13702. /**
  13703. * Gets a string identifying the name of the class
  13704. * @returns "TransformNode" string
  13705. */
  13706. getClassName(): string;
  13707. /**
  13708. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13709. */
  13710. get position(): Vector3;
  13711. set position(newPosition: Vector3);
  13712. /**
  13713. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13714. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13715. */
  13716. get rotation(): Vector3;
  13717. set rotation(newRotation: Vector3);
  13718. /**
  13719. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13720. */
  13721. get scaling(): Vector3;
  13722. set scaling(newScaling: Vector3);
  13723. /**
  13724. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  13725. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13726. */
  13727. get rotationQuaternion(): Nullable<Quaternion>;
  13728. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13729. /**
  13730. * The forward direction of that transform in world space.
  13731. */
  13732. get forward(): Vector3;
  13733. /**
  13734. * The up direction of that transform in world space.
  13735. */
  13736. get up(): Vector3;
  13737. /**
  13738. * The right direction of that transform in world space.
  13739. */
  13740. get right(): Vector3;
  13741. /**
  13742. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13743. * @param matrix the matrix to copy the pose from
  13744. * @returns this TransformNode.
  13745. */
  13746. updatePoseMatrix(matrix: Matrix): TransformNode;
  13747. /**
  13748. * Returns the mesh Pose matrix.
  13749. * @returns the pose matrix
  13750. */
  13751. getPoseMatrix(): Matrix;
  13752. /** @hidden */
  13753. _isSynchronized(): boolean;
  13754. /** @hidden */
  13755. _initCache(): void;
  13756. /**
  13757. * Flag the transform node as dirty (Forcing it to update everything)
  13758. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13759. * @returns this transform node
  13760. */
  13761. markAsDirty(property: string): TransformNode;
  13762. /**
  13763. * Returns the current mesh absolute position.
  13764. * Returns a Vector3.
  13765. */
  13766. get absolutePosition(): Vector3;
  13767. /**
  13768. * Returns the current mesh absolute scaling.
  13769. * Returns a Vector3.
  13770. */
  13771. get absoluteScaling(): Vector3;
  13772. /**
  13773. * Returns the current mesh absolute rotation.
  13774. * Returns a Quaternion.
  13775. */
  13776. get absoluteRotationQuaternion(): Quaternion;
  13777. /**
  13778. * Sets a new matrix to apply before all other transformation
  13779. * @param matrix defines the transform matrix
  13780. * @returns the current TransformNode
  13781. */
  13782. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13783. /**
  13784. * Sets a new pivot matrix to the current node
  13785. * @param matrix defines the new pivot matrix to use
  13786. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  13787. * @returns the current TransformNode
  13788. */
  13789. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13790. /**
  13791. * Returns the mesh pivot matrix.
  13792. * Default : Identity.
  13793. * @returns the matrix
  13794. */
  13795. getPivotMatrix(): Matrix;
  13796. /**
  13797. * Instantiate (when possible) or clone that node with its hierarchy
  13798. * @param newParent defines the new parent to use for the instance (or clone)
  13799. * @param options defines options to configure how copy is done
  13800. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13801. * @returns an instance (or a clone) of the current node with its hiearchy
  13802. */
  13803. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13804. doNotInstantiate: boolean;
  13805. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13806. /**
  13807. * Prevents the World matrix to be computed any longer
  13808. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13809. * @returns the TransformNode.
  13810. */
  13811. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13812. /**
  13813. * Allows back the World matrix computation.
  13814. * @returns the TransformNode.
  13815. */
  13816. unfreezeWorldMatrix(): this;
  13817. /**
  13818. * True if the World matrix has been frozen.
  13819. */
  13820. get isWorldMatrixFrozen(): boolean;
  13821. /**
  13822. * Retuns the mesh absolute position in the World.
  13823. * @returns a Vector3.
  13824. */
  13825. getAbsolutePosition(): Vector3;
  13826. /**
  13827. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13828. * @param absolutePosition the absolute position to set
  13829. * @returns the TransformNode.
  13830. */
  13831. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13832. /**
  13833. * Sets the mesh position in its local space.
  13834. * @param vector3 the position to set in localspace
  13835. * @returns the TransformNode.
  13836. */
  13837. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13838. /**
  13839. * Returns the mesh position in the local space from the current World matrix values.
  13840. * @returns a new Vector3.
  13841. */
  13842. getPositionExpressedInLocalSpace(): Vector3;
  13843. /**
  13844. * Translates the mesh along the passed Vector3 in its local space.
  13845. * @param vector3 the distance to translate in localspace
  13846. * @returns the TransformNode.
  13847. */
  13848. locallyTranslate(vector3: Vector3): TransformNode;
  13849. private static _lookAtVectorCache;
  13850. /**
  13851. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13852. * @param targetPoint the position (must be in same space as current mesh) to look at
  13853. * @param yawCor optional yaw (y-axis) correction in radians
  13854. * @param pitchCor optional pitch (x-axis) correction in radians
  13855. * @param rollCor optional roll (z-axis) correction in radians
  13856. * @param space the choosen space of the target
  13857. * @returns the TransformNode.
  13858. */
  13859. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13860. /**
  13861. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13862. * This Vector3 is expressed in the World space.
  13863. * @param localAxis axis to rotate
  13864. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13865. */
  13866. getDirection(localAxis: Vector3): Vector3;
  13867. /**
  13868. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13869. * localAxis is expressed in the mesh local space.
  13870. * result is computed in the Wordl space from the mesh World matrix.
  13871. * @param localAxis axis to rotate
  13872. * @param result the resulting transformnode
  13873. * @returns this TransformNode.
  13874. */
  13875. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13876. /**
  13877. * Sets this transform node rotation to the given local axis.
  13878. * @param localAxis the axis in local space
  13879. * @param yawCor optional yaw (y-axis) correction in radians
  13880. * @param pitchCor optional pitch (x-axis) correction in radians
  13881. * @param rollCor optional roll (z-axis) correction in radians
  13882. * @returns this TransformNode
  13883. */
  13884. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13885. /**
  13886. * Sets a new pivot point to the current node
  13887. * @param point defines the new pivot point to use
  13888. * @param space defines if the point is in world or local space (local by default)
  13889. * @returns the current TransformNode
  13890. */
  13891. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13892. /**
  13893. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13894. * @returns the pivot point
  13895. */
  13896. getPivotPoint(): Vector3;
  13897. /**
  13898. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13899. * @param result the vector3 to store the result
  13900. * @returns this TransformNode.
  13901. */
  13902. getPivotPointToRef(result: Vector3): TransformNode;
  13903. /**
  13904. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13905. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13906. */
  13907. getAbsolutePivotPoint(): Vector3;
  13908. /**
  13909. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13910. * @param result vector3 to store the result
  13911. * @returns this TransformNode.
  13912. */
  13913. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13914. /**
  13915. * Defines the passed node as the parent of the current node.
  13916. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13917. * @see https://doc.babylonjs.com/how_to/parenting
  13918. * @param node the node ot set as the parent
  13919. * @returns this TransformNode.
  13920. */
  13921. setParent(node: Nullable<Node>): TransformNode;
  13922. private _nonUniformScaling;
  13923. /**
  13924. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13925. */
  13926. get nonUniformScaling(): boolean;
  13927. /** @hidden */
  13928. _updateNonUniformScalingState(value: boolean): boolean;
  13929. /**
  13930. * Attach the current TransformNode to another TransformNode associated with a bone
  13931. * @param bone Bone affecting the TransformNode
  13932. * @param affectedTransformNode TransformNode associated with the bone
  13933. * @returns this object
  13934. */
  13935. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13936. /**
  13937. * Detach the transform node if its associated with a bone
  13938. * @returns this object
  13939. */
  13940. detachFromBone(): TransformNode;
  13941. private static _rotationAxisCache;
  13942. /**
  13943. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13944. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13945. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13946. * The passed axis is also normalized.
  13947. * @param axis the axis to rotate around
  13948. * @param amount the amount to rotate in radians
  13949. * @param space Space to rotate in (Default: local)
  13950. * @returns the TransformNode.
  13951. */
  13952. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13953. /**
  13954. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13955. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13956. * The passed axis is also normalized. .
  13957. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13958. * @param point the point to rotate around
  13959. * @param axis the axis to rotate around
  13960. * @param amount the amount to rotate in radians
  13961. * @returns the TransformNode
  13962. */
  13963. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13964. /**
  13965. * Translates the mesh along the axis vector for the passed distance in the given space.
  13966. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13967. * @param axis the axis to translate in
  13968. * @param distance the distance to translate
  13969. * @param space Space to rotate in (Default: local)
  13970. * @returns the TransformNode.
  13971. */
  13972. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13973. /**
  13974. * Adds a rotation step to the mesh current rotation.
  13975. * x, y, z are Euler angles expressed in radians.
  13976. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13977. * This means this rotation is made in the mesh local space only.
  13978. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13979. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13980. * ```javascript
  13981. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13982. * ```
  13983. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13984. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  13985. * @param x Rotation to add
  13986. * @param y Rotation to add
  13987. * @param z Rotation to add
  13988. * @returns the TransformNode.
  13989. */
  13990. addRotation(x: number, y: number, z: number): TransformNode;
  13991. /**
  13992. * @hidden
  13993. */
  13994. protected _getEffectiveParent(): Nullable<Node>;
  13995. /**
  13996. * Computes the world matrix of the node
  13997. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13998. * @returns the world matrix
  13999. */
  14000. computeWorldMatrix(force?: boolean): Matrix;
  14001. /**
  14002. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14003. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14004. */
  14005. resetLocalMatrix(independentOfChildren?: boolean): void;
  14006. protected _afterComputeWorldMatrix(): void;
  14007. /**
  14008. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14009. * @param func callback function to add
  14010. *
  14011. * @returns the TransformNode.
  14012. */
  14013. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14014. /**
  14015. * Removes a registered callback function.
  14016. * @param func callback function to remove
  14017. * @returns the TransformNode.
  14018. */
  14019. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14020. /**
  14021. * Gets the position of the current mesh in camera space
  14022. * @param camera defines the camera to use
  14023. * @returns a position
  14024. */
  14025. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14026. /**
  14027. * Returns the distance from the mesh to the active camera
  14028. * @param camera defines the camera to use
  14029. * @returns the distance
  14030. */
  14031. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14032. /**
  14033. * Clone the current transform node
  14034. * @param name Name of the new clone
  14035. * @param newParent New parent for the clone
  14036. * @param doNotCloneChildren Do not clone children hierarchy
  14037. * @returns the new transform node
  14038. */
  14039. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14040. /**
  14041. * Serializes the objects information.
  14042. * @param currentSerializationObject defines the object to serialize in
  14043. * @returns the serialized object
  14044. */
  14045. serialize(currentSerializationObject?: any): any;
  14046. /**
  14047. * Returns a new TransformNode object parsed from the source provided.
  14048. * @param parsedTransformNode is the source.
  14049. * @param scene the scne the object belongs to
  14050. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14051. * @returns a new TransformNode object parsed from the source provided.
  14052. */
  14053. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14054. /**
  14055. * Get all child-transformNodes of this node
  14056. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14057. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14058. * @returns an array of TransformNode
  14059. */
  14060. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14061. /**
  14062. * Releases resources associated with this transform node.
  14063. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14064. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14065. */
  14066. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14067. /**
  14068. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14069. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14070. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14071. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14072. * @returns the current mesh
  14073. */
  14074. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14075. private _syncAbsoluteScalingAndRotation;
  14076. }
  14077. }
  14078. declare module BABYLON {
  14079. /**
  14080. * Class used to override all child animations of a given target
  14081. */
  14082. export class AnimationPropertiesOverride {
  14083. /**
  14084. * Gets or sets a value indicating if animation blending must be used
  14085. */
  14086. enableBlending: boolean;
  14087. /**
  14088. * Gets or sets the blending speed to use when enableBlending is true
  14089. */
  14090. blendingSpeed: number;
  14091. /**
  14092. * Gets or sets the default loop mode to use
  14093. */
  14094. loopMode: number;
  14095. }
  14096. }
  14097. declare module BABYLON {
  14098. /**
  14099. * Class used to store bone information
  14100. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14101. */
  14102. export class Bone extends Node {
  14103. /**
  14104. * defines the bone name
  14105. */
  14106. name: string;
  14107. private static _tmpVecs;
  14108. private static _tmpQuat;
  14109. private static _tmpMats;
  14110. /**
  14111. * Gets the list of child bones
  14112. */
  14113. children: Bone[];
  14114. /** Gets the animations associated with this bone */
  14115. animations: Animation[];
  14116. /**
  14117. * Gets or sets bone length
  14118. */
  14119. length: number;
  14120. /**
  14121. * @hidden Internal only
  14122. * Set this value to map this bone to a different index in the transform matrices
  14123. * Set this value to -1 to exclude the bone from the transform matrices
  14124. */
  14125. _index: Nullable<number>;
  14126. private _skeleton;
  14127. private _localMatrix;
  14128. private _restPose;
  14129. private _baseMatrix;
  14130. private _absoluteTransform;
  14131. private _invertedAbsoluteTransform;
  14132. private _parent;
  14133. private _scalingDeterminant;
  14134. private _worldTransform;
  14135. private _localScaling;
  14136. private _localRotation;
  14137. private _localPosition;
  14138. private _needToDecompose;
  14139. private _needToCompose;
  14140. /** @hidden */
  14141. _linkedTransformNode: Nullable<TransformNode>;
  14142. /** @hidden */
  14143. _waitingTransformNodeId: Nullable<string>;
  14144. /** @hidden */
  14145. get _matrix(): Matrix;
  14146. /** @hidden */
  14147. set _matrix(value: Matrix);
  14148. /**
  14149. * Create a new bone
  14150. * @param name defines the bone name
  14151. * @param skeleton defines the parent skeleton
  14152. * @param parentBone defines the parent (can be null if the bone is the root)
  14153. * @param localMatrix defines the local matrix
  14154. * @param restPose defines the rest pose matrix
  14155. * @param baseMatrix defines the base matrix
  14156. * @param index defines index of the bone in the hiearchy
  14157. */
  14158. constructor(
  14159. /**
  14160. * defines the bone name
  14161. */
  14162. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14163. /**
  14164. * Gets the current object class name.
  14165. * @return the class name
  14166. */
  14167. getClassName(): string;
  14168. /**
  14169. * Gets the parent skeleton
  14170. * @returns a skeleton
  14171. */
  14172. getSkeleton(): Skeleton;
  14173. /**
  14174. * Gets parent bone
  14175. * @returns a bone or null if the bone is the root of the bone hierarchy
  14176. */
  14177. getParent(): Nullable<Bone>;
  14178. /**
  14179. * Returns an array containing the root bones
  14180. * @returns an array containing the root bones
  14181. */
  14182. getChildren(): Array<Bone>;
  14183. /**
  14184. * Gets the node index in matrix array generated for rendering
  14185. * @returns the node index
  14186. */
  14187. getIndex(): number;
  14188. /**
  14189. * Sets the parent bone
  14190. * @param parent defines the parent (can be null if the bone is the root)
  14191. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14192. */
  14193. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14194. /**
  14195. * Gets the local matrix
  14196. * @returns a matrix
  14197. */
  14198. getLocalMatrix(): Matrix;
  14199. /**
  14200. * Gets the base matrix (initial matrix which remains unchanged)
  14201. * @returns a matrix
  14202. */
  14203. getBaseMatrix(): Matrix;
  14204. /**
  14205. * Gets the rest pose matrix
  14206. * @returns a matrix
  14207. */
  14208. getRestPose(): Matrix;
  14209. /**
  14210. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14211. */
  14212. getWorldMatrix(): Matrix;
  14213. /**
  14214. * Sets the local matrix to rest pose matrix
  14215. */
  14216. returnToRest(): void;
  14217. /**
  14218. * Gets the inverse of the absolute transform matrix.
  14219. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14220. * @returns a matrix
  14221. */
  14222. getInvertedAbsoluteTransform(): Matrix;
  14223. /**
  14224. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14225. * @returns a matrix
  14226. */
  14227. getAbsoluteTransform(): Matrix;
  14228. /**
  14229. * Links with the given transform node.
  14230. * The local matrix of this bone is copied from the transform node every frame.
  14231. * @param transformNode defines the transform node to link to
  14232. */
  14233. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14234. /**
  14235. * Gets the node used to drive the bone's transformation
  14236. * @returns a transform node or null
  14237. */
  14238. getTransformNode(): Nullable<TransformNode>;
  14239. /** Gets or sets current position (in local space) */
  14240. get position(): Vector3;
  14241. set position(newPosition: Vector3);
  14242. /** Gets or sets current rotation (in local space) */
  14243. get rotation(): Vector3;
  14244. set rotation(newRotation: Vector3);
  14245. /** Gets or sets current rotation quaternion (in local space) */
  14246. get rotationQuaternion(): Quaternion;
  14247. set rotationQuaternion(newRotation: Quaternion);
  14248. /** Gets or sets current scaling (in local space) */
  14249. get scaling(): Vector3;
  14250. set scaling(newScaling: Vector3);
  14251. /**
  14252. * Gets the animation properties override
  14253. */
  14254. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14255. private _decompose;
  14256. private _compose;
  14257. /**
  14258. * Update the base and local matrices
  14259. * @param matrix defines the new base or local matrix
  14260. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14261. * @param updateLocalMatrix defines if the local matrix should be updated
  14262. */
  14263. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14264. /** @hidden */
  14265. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14266. /**
  14267. * Flag the bone as dirty (Forcing it to update everything)
  14268. */
  14269. markAsDirty(): void;
  14270. /** @hidden */
  14271. _markAsDirtyAndCompose(): void;
  14272. private _markAsDirtyAndDecompose;
  14273. /**
  14274. * Translate the bone in local or world space
  14275. * @param vec The amount to translate the bone
  14276. * @param space The space that the translation is in
  14277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14278. */
  14279. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14280. /**
  14281. * Set the postion of the bone in local or world space
  14282. * @param position The position to set the bone
  14283. * @param space The space that the position is in
  14284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14285. */
  14286. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14287. /**
  14288. * Set the absolute position of the bone (world space)
  14289. * @param position The position to set the bone
  14290. * @param mesh The mesh that this bone is attached to
  14291. */
  14292. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14293. /**
  14294. * Scale the bone on the x, y and z axes (in local space)
  14295. * @param x The amount to scale the bone on the x axis
  14296. * @param y The amount to scale the bone on the y axis
  14297. * @param z The amount to scale the bone on the z axis
  14298. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14299. */
  14300. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14301. /**
  14302. * Set the bone scaling in local space
  14303. * @param scale defines the scaling vector
  14304. */
  14305. setScale(scale: Vector3): void;
  14306. /**
  14307. * Gets the current scaling in local space
  14308. * @returns the current scaling vector
  14309. */
  14310. getScale(): Vector3;
  14311. /**
  14312. * Gets the current scaling in local space and stores it in a target vector
  14313. * @param result defines the target vector
  14314. */
  14315. getScaleToRef(result: Vector3): void;
  14316. /**
  14317. * Set the yaw, pitch, and roll of the bone in local or world space
  14318. * @param yaw The rotation of the bone on the y axis
  14319. * @param pitch The rotation of the bone on the x axis
  14320. * @param roll The rotation of the bone on the z axis
  14321. * @param space The space that the axes of rotation are in
  14322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14323. */
  14324. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14325. /**
  14326. * Add a rotation to the bone on an axis in local or world space
  14327. * @param axis The axis to rotate the bone on
  14328. * @param amount The amount to rotate the bone
  14329. * @param space The space that the axis is in
  14330. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14331. */
  14332. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14333. /**
  14334. * Set the rotation of the bone to a particular axis angle in local or world space
  14335. * @param axis The axis to rotate the bone on
  14336. * @param angle The angle that the bone should be rotated to
  14337. * @param space The space that the axis is in
  14338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14339. */
  14340. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14341. /**
  14342. * Set the euler rotation of the bone in local of world space
  14343. * @param rotation The euler rotation that the bone should be set to
  14344. * @param space The space that the rotation is in
  14345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14346. */
  14347. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14348. /**
  14349. * Set the quaternion rotation of the bone in local of world space
  14350. * @param quat The quaternion rotation that the bone should be set to
  14351. * @param space The space that the rotation is in
  14352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14353. */
  14354. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14355. /**
  14356. * Set the rotation matrix of the bone in local of world space
  14357. * @param rotMat The rotation matrix that the bone should be set to
  14358. * @param space The space that the rotation is in
  14359. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14360. */
  14361. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14362. private _rotateWithMatrix;
  14363. private _getNegativeRotationToRef;
  14364. /**
  14365. * Get the position of the bone in local or world space
  14366. * @param space The space that the returned position is in
  14367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14368. * @returns The position of the bone
  14369. */
  14370. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14371. /**
  14372. * Copy the position of the bone to a vector3 in local or world space
  14373. * @param space The space that the returned position is in
  14374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14375. * @param result The vector3 to copy the position to
  14376. */
  14377. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14378. /**
  14379. * Get the absolute position of the bone (world space)
  14380. * @param mesh The mesh that this bone is attached to
  14381. * @returns The absolute position of the bone
  14382. */
  14383. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14384. /**
  14385. * Copy the absolute position of the bone (world space) to the result param
  14386. * @param mesh The mesh that this bone is attached to
  14387. * @param result The vector3 to copy the absolute position to
  14388. */
  14389. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14390. /**
  14391. * Compute the absolute transforms of this bone and its children
  14392. */
  14393. computeAbsoluteTransforms(): void;
  14394. /**
  14395. * Get the world direction from an axis that is in the local space of the bone
  14396. * @param localAxis The local direction that is used to compute the world direction
  14397. * @param mesh The mesh that this bone is attached to
  14398. * @returns The world direction
  14399. */
  14400. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14401. /**
  14402. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14403. * @param localAxis The local direction that is used to compute the world direction
  14404. * @param mesh The mesh that this bone is attached to
  14405. * @param result The vector3 that the world direction will be copied to
  14406. */
  14407. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14408. /**
  14409. * Get the euler rotation of the bone in local or world space
  14410. * @param space The space that the rotation should be in
  14411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14412. * @returns The euler rotation
  14413. */
  14414. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14415. /**
  14416. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14417. * @param space The space that the rotation should be in
  14418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14419. * @param result The vector3 that the rotation should be copied to
  14420. */
  14421. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14422. /**
  14423. * Get the quaternion rotation of the bone in either local or world space
  14424. * @param space The space that the rotation should be in
  14425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14426. * @returns The quaternion rotation
  14427. */
  14428. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14429. /**
  14430. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14431. * @param space The space that the rotation should be in
  14432. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14433. * @param result The quaternion that the rotation should be copied to
  14434. */
  14435. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14436. /**
  14437. * Get the rotation matrix of the bone in local or world space
  14438. * @param space The space that the rotation should be in
  14439. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14440. * @returns The rotation matrix
  14441. */
  14442. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14443. /**
  14444. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14445. * @param space The space that the rotation should be in
  14446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14447. * @param result The quaternion that the rotation should be copied to
  14448. */
  14449. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14450. /**
  14451. * Get the world position of a point that is in the local space of the bone
  14452. * @param position The local position
  14453. * @param mesh The mesh that this bone is attached to
  14454. * @returns The world position
  14455. */
  14456. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14457. /**
  14458. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14459. * @param position The local position
  14460. * @param mesh The mesh that this bone is attached to
  14461. * @param result The vector3 that the world position should be copied to
  14462. */
  14463. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14464. /**
  14465. * Get the local position of a point that is in world space
  14466. * @param position The world position
  14467. * @param mesh The mesh that this bone is attached to
  14468. * @returns The local position
  14469. */
  14470. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14471. /**
  14472. * Get the local position of a point that is in world space and copy it to the result param
  14473. * @param position The world position
  14474. * @param mesh The mesh that this bone is attached to
  14475. * @param result The vector3 that the local position should be copied to
  14476. */
  14477. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14478. }
  14479. }
  14480. declare module BABYLON {
  14481. /**
  14482. * Defines a runtime animation
  14483. */
  14484. export class RuntimeAnimation {
  14485. private _events;
  14486. /**
  14487. * The current frame of the runtime animation
  14488. */
  14489. private _currentFrame;
  14490. /**
  14491. * The animation used by the runtime animation
  14492. */
  14493. private _animation;
  14494. /**
  14495. * The target of the runtime animation
  14496. */
  14497. private _target;
  14498. /**
  14499. * The initiating animatable
  14500. */
  14501. private _host;
  14502. /**
  14503. * The original value of the runtime animation
  14504. */
  14505. private _originalValue;
  14506. /**
  14507. * The original blend value of the runtime animation
  14508. */
  14509. private _originalBlendValue;
  14510. /**
  14511. * The offsets cache of the runtime animation
  14512. */
  14513. private _offsetsCache;
  14514. /**
  14515. * The high limits cache of the runtime animation
  14516. */
  14517. private _highLimitsCache;
  14518. /**
  14519. * Specifies if the runtime animation has been stopped
  14520. */
  14521. private _stopped;
  14522. /**
  14523. * The blending factor of the runtime animation
  14524. */
  14525. private _blendingFactor;
  14526. /**
  14527. * The BabylonJS scene
  14528. */
  14529. private _scene;
  14530. /**
  14531. * The current value of the runtime animation
  14532. */
  14533. private _currentValue;
  14534. /** @hidden */
  14535. _animationState: _IAnimationState;
  14536. /**
  14537. * The active target of the runtime animation
  14538. */
  14539. private _activeTargets;
  14540. private _currentActiveTarget;
  14541. private _directTarget;
  14542. /**
  14543. * The target path of the runtime animation
  14544. */
  14545. private _targetPath;
  14546. /**
  14547. * The weight of the runtime animation
  14548. */
  14549. private _weight;
  14550. /**
  14551. * The ratio offset of the runtime animation
  14552. */
  14553. private _ratioOffset;
  14554. /**
  14555. * The previous delay of the runtime animation
  14556. */
  14557. private _previousDelay;
  14558. /**
  14559. * The previous ratio of the runtime animation
  14560. */
  14561. private _previousRatio;
  14562. private _enableBlending;
  14563. private _keys;
  14564. private _minFrame;
  14565. private _maxFrame;
  14566. private _minValue;
  14567. private _maxValue;
  14568. private _targetIsArray;
  14569. /**
  14570. * Gets the current frame of the runtime animation
  14571. */
  14572. get currentFrame(): number;
  14573. /**
  14574. * Gets the weight of the runtime animation
  14575. */
  14576. get weight(): number;
  14577. /**
  14578. * Gets the current value of the runtime animation
  14579. */
  14580. get currentValue(): any;
  14581. /**
  14582. * Gets the target path of the runtime animation
  14583. */
  14584. get targetPath(): string;
  14585. /**
  14586. * Gets the actual target of the runtime animation
  14587. */
  14588. get target(): any;
  14589. /**
  14590. * Gets the additive state of the runtime animation
  14591. */
  14592. get isAdditive(): boolean;
  14593. /** @hidden */
  14594. _onLoop: () => void;
  14595. /**
  14596. * Create a new RuntimeAnimation object
  14597. * @param target defines the target of the animation
  14598. * @param animation defines the source animation object
  14599. * @param scene defines the hosting scene
  14600. * @param host defines the initiating Animatable
  14601. */
  14602. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14603. private _preparePath;
  14604. /**
  14605. * Gets the animation from the runtime animation
  14606. */
  14607. get animation(): Animation;
  14608. /**
  14609. * Resets the runtime animation to the beginning
  14610. * @param restoreOriginal defines whether to restore the target property to the original value
  14611. */
  14612. reset(restoreOriginal?: boolean): void;
  14613. /**
  14614. * Specifies if the runtime animation is stopped
  14615. * @returns Boolean specifying if the runtime animation is stopped
  14616. */
  14617. isStopped(): boolean;
  14618. /**
  14619. * Disposes of the runtime animation
  14620. */
  14621. dispose(): void;
  14622. /**
  14623. * Apply the interpolated value to the target
  14624. * @param currentValue defines the value computed by the animation
  14625. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14626. */
  14627. setValue(currentValue: any, weight: number): void;
  14628. private _getOriginalValues;
  14629. private _setValue;
  14630. /**
  14631. * Gets the loop pmode of the runtime animation
  14632. * @returns Loop Mode
  14633. */
  14634. private _getCorrectLoopMode;
  14635. /**
  14636. * Move the current animation to a given frame
  14637. * @param frame defines the frame to move to
  14638. */
  14639. goToFrame(frame: number): void;
  14640. /**
  14641. * @hidden Internal use only
  14642. */
  14643. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14644. /**
  14645. * Execute the current animation
  14646. * @param delay defines the delay to add to the current frame
  14647. * @param from defines the lower bound of the animation range
  14648. * @param to defines the upper bound of the animation range
  14649. * @param loop defines if the current animation must loop
  14650. * @param speedRatio defines the current speed ratio
  14651. * @param weight defines the weight of the animation (default is -1 so no weight)
  14652. * @param onLoop optional callback called when animation loops
  14653. * @returns a boolean indicating if the animation is running
  14654. */
  14655. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14656. }
  14657. }
  14658. declare module BABYLON {
  14659. /**
  14660. * Class used to store an actual running animation
  14661. */
  14662. export class Animatable {
  14663. /** defines the target object */
  14664. target: any;
  14665. /** defines the starting frame number (default is 0) */
  14666. fromFrame: number;
  14667. /** defines the ending frame number (default is 100) */
  14668. toFrame: number;
  14669. /** defines if the animation must loop (default is false) */
  14670. loopAnimation: boolean;
  14671. /** defines a callback to call when animation ends if it is not looping */
  14672. onAnimationEnd?: (() => void) | null | undefined;
  14673. /** defines a callback to call when animation loops */
  14674. onAnimationLoop?: (() => void) | null | undefined;
  14675. /** defines whether the animation should be evaluated additively */
  14676. isAdditive: boolean;
  14677. private _localDelayOffset;
  14678. private _pausedDelay;
  14679. private _runtimeAnimations;
  14680. private _paused;
  14681. private _scene;
  14682. private _speedRatio;
  14683. private _weight;
  14684. private _syncRoot;
  14685. /**
  14686. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14687. * This will only apply for non looping animation (default is true)
  14688. */
  14689. disposeOnEnd: boolean;
  14690. /**
  14691. * Gets a boolean indicating if the animation has started
  14692. */
  14693. animationStarted: boolean;
  14694. /**
  14695. * Observer raised when the animation ends
  14696. */
  14697. onAnimationEndObservable: Observable<Animatable>;
  14698. /**
  14699. * Observer raised when the animation loops
  14700. */
  14701. onAnimationLoopObservable: Observable<Animatable>;
  14702. /**
  14703. * Gets the root Animatable used to synchronize and normalize animations
  14704. */
  14705. get syncRoot(): Nullable<Animatable>;
  14706. /**
  14707. * Gets the current frame of the first RuntimeAnimation
  14708. * Used to synchronize Animatables
  14709. */
  14710. get masterFrame(): number;
  14711. /**
  14712. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14713. */
  14714. get weight(): number;
  14715. set weight(value: number);
  14716. /**
  14717. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14718. */
  14719. get speedRatio(): number;
  14720. set speedRatio(value: number);
  14721. /**
  14722. * Creates a new Animatable
  14723. * @param scene defines the hosting scene
  14724. * @param target defines the target object
  14725. * @param fromFrame defines the starting frame number (default is 0)
  14726. * @param toFrame defines the ending frame number (default is 100)
  14727. * @param loopAnimation defines if the animation must loop (default is false)
  14728. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14729. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14730. * @param animations defines a group of animation to add to the new Animatable
  14731. * @param onAnimationLoop defines a callback to call when animation loops
  14732. * @param isAdditive defines whether the animation should be evaluated additively
  14733. */
  14734. constructor(scene: Scene,
  14735. /** defines the target object */
  14736. target: any,
  14737. /** defines the starting frame number (default is 0) */
  14738. fromFrame?: number,
  14739. /** defines the ending frame number (default is 100) */
  14740. toFrame?: number,
  14741. /** defines if the animation must loop (default is false) */
  14742. loopAnimation?: boolean, speedRatio?: number,
  14743. /** defines a callback to call when animation ends if it is not looping */
  14744. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14745. /** defines a callback to call when animation loops */
  14746. onAnimationLoop?: (() => void) | null | undefined,
  14747. /** defines whether the animation should be evaluated additively */
  14748. isAdditive?: boolean);
  14749. /**
  14750. * Synchronize and normalize current Animatable with a source Animatable
  14751. * This is useful when using animation weights and when animations are not of the same length
  14752. * @param root defines the root Animatable to synchronize with
  14753. * @returns the current Animatable
  14754. */
  14755. syncWith(root: Animatable): Animatable;
  14756. /**
  14757. * Gets the list of runtime animations
  14758. * @returns an array of RuntimeAnimation
  14759. */
  14760. getAnimations(): RuntimeAnimation[];
  14761. /**
  14762. * Adds more animations to the current animatable
  14763. * @param target defines the target of the animations
  14764. * @param animations defines the new animations to add
  14765. */
  14766. appendAnimations(target: any, animations: Animation[]): void;
  14767. /**
  14768. * Gets the source animation for a specific property
  14769. * @param property defines the propertyu to look for
  14770. * @returns null or the source animation for the given property
  14771. */
  14772. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14773. /**
  14774. * Gets the runtime animation for a specific property
  14775. * @param property defines the propertyu to look for
  14776. * @returns null or the runtime animation for the given property
  14777. */
  14778. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14779. /**
  14780. * Resets the animatable to its original state
  14781. */
  14782. reset(): void;
  14783. /**
  14784. * Allows the animatable to blend with current running animations
  14785. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14786. * @param blendingSpeed defines the blending speed to use
  14787. */
  14788. enableBlending(blendingSpeed: number): void;
  14789. /**
  14790. * Disable animation blending
  14791. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14792. */
  14793. disableBlending(): void;
  14794. /**
  14795. * Jump directly to a given frame
  14796. * @param frame defines the frame to jump to
  14797. */
  14798. goToFrame(frame: number): void;
  14799. /**
  14800. * Pause the animation
  14801. */
  14802. pause(): void;
  14803. /**
  14804. * Restart the animation
  14805. */
  14806. restart(): void;
  14807. private _raiseOnAnimationEnd;
  14808. /**
  14809. * Stop and delete the current animation
  14810. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14811. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  14812. */
  14813. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14814. /**
  14815. * Wait asynchronously for the animation to end
  14816. * @returns a promise which will be fullfilled when the animation ends
  14817. */
  14818. waitAsync(): Promise<Animatable>;
  14819. /** @hidden */
  14820. _animate(delay: number): boolean;
  14821. }
  14822. interface Scene {
  14823. /** @hidden */
  14824. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14825. /** @hidden */
  14826. _processLateAnimationBindingsForMatrices(holder: {
  14827. totalWeight: number;
  14828. totalAdditiveWeight: number;
  14829. animations: RuntimeAnimation[];
  14830. additiveAnimations: RuntimeAnimation[];
  14831. originalValue: Matrix;
  14832. }): any;
  14833. /** @hidden */
  14834. _processLateAnimationBindingsForQuaternions(holder: {
  14835. totalWeight: number;
  14836. totalAdditiveWeight: number;
  14837. animations: RuntimeAnimation[];
  14838. additiveAnimations: RuntimeAnimation[];
  14839. originalValue: Quaternion;
  14840. }, refQuaternion: Quaternion): Quaternion;
  14841. /** @hidden */
  14842. _processLateAnimationBindings(): void;
  14843. /**
  14844. * Will start the animation sequence of a given target
  14845. * @param target defines the target
  14846. * @param from defines from which frame should animation start
  14847. * @param to defines until which frame should animation run.
  14848. * @param weight defines the weight to apply to the animation (1.0 by default)
  14849. * @param loop defines if the animation loops
  14850. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14851. * @param onAnimationEnd defines the function to be executed when the animation ends
  14852. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14853. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14854. * @param onAnimationLoop defines the callback to call when an animation loops
  14855. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14856. * @returns the animatable object created for this animation
  14857. */
  14858. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14859. /**
  14860. * Will start the animation sequence of a given target
  14861. * @param target defines the target
  14862. * @param from defines from which frame should animation start
  14863. * @param to defines until which frame should animation run.
  14864. * @param loop defines if the animation loops
  14865. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14866. * @param onAnimationEnd defines the function to be executed when the animation ends
  14867. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14868. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14869. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14870. * @param onAnimationLoop defines the callback to call when an animation loops
  14871. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14872. * @returns the animatable object created for this animation
  14873. */
  14874. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14875. /**
  14876. * Will start the animation sequence of a given target and its hierarchy
  14877. * @param target defines the target
  14878. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  14879. * @param from defines from which frame should animation start
  14880. * @param to defines until which frame should animation run.
  14881. * @param loop defines if the animation loops
  14882. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14883. * @param onAnimationEnd defines the function to be executed when the animation ends
  14884. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14885. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14886. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14887. * @param onAnimationLoop defines the callback to call when an animation loops
  14888. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14889. * @returns the list of created animatables
  14890. */
  14891. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14892. /**
  14893. * Begin a new animation on a given node
  14894. * @param target defines the target where the animation will take place
  14895. * @param animations defines the list of animations to start
  14896. * @param from defines the initial value
  14897. * @param to defines the final value
  14898. * @param loop defines if you want animation to loop (off by default)
  14899. * @param speedRatio defines the speed ratio to apply to all animations
  14900. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14901. * @param onAnimationLoop defines the callback to call when an animation loops
  14902. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14903. * @returns the list of created animatables
  14904. */
  14905. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14906. /**
  14907. * Begin a new animation on a given node and its hierarchy
  14908. * @param target defines the root node where the animation will take place
  14909. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  14910. * @param animations defines the list of animations to start
  14911. * @param from defines the initial value
  14912. * @param to defines the final value
  14913. * @param loop defines if you want animation to loop (off by default)
  14914. * @param speedRatio defines the speed ratio to apply to all animations
  14915. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14916. * @param onAnimationLoop defines the callback to call when an animation loops
  14917. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14918. * @returns the list of animatables created for all nodes
  14919. */
  14920. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14921. /**
  14922. * Gets the animatable associated with a specific target
  14923. * @param target defines the target of the animatable
  14924. * @returns the required animatable if found
  14925. */
  14926. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14927. /**
  14928. * Gets all animatables associated with a given target
  14929. * @param target defines the target to look animatables for
  14930. * @returns an array of Animatables
  14931. */
  14932. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14933. /**
  14934. * Stops and removes all animations that have been applied to the scene
  14935. */
  14936. stopAllAnimations(): void;
  14937. /**
  14938. * Gets the current delta time used by animation engine
  14939. */
  14940. deltaTime: number;
  14941. }
  14942. interface Bone {
  14943. /**
  14944. * Copy an animation range from another bone
  14945. * @param source defines the source bone
  14946. * @param rangeName defines the range name to copy
  14947. * @param frameOffset defines the frame offset
  14948. * @param rescaleAsRequired defines if rescaling must be applied if required
  14949. * @param skelDimensionsRatio defines the scaling ratio
  14950. * @returns true if operation was successful
  14951. */
  14952. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14953. }
  14954. }
  14955. declare module BABYLON {
  14956. /**
  14957. * Class used to handle skinning animations
  14958. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14959. */
  14960. export class Skeleton implements IAnimatable {
  14961. /** defines the skeleton name */
  14962. name: string;
  14963. /** defines the skeleton Id */
  14964. id: string;
  14965. /**
  14966. * Defines the list of child bones
  14967. */
  14968. bones: Bone[];
  14969. /**
  14970. * Defines an estimate of the dimension of the skeleton at rest
  14971. */
  14972. dimensionsAtRest: Vector3;
  14973. /**
  14974. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14975. */
  14976. needInitialSkinMatrix: boolean;
  14977. /**
  14978. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14979. */
  14980. overrideMesh: Nullable<AbstractMesh>;
  14981. /**
  14982. * Gets the list of animations attached to this skeleton
  14983. */
  14984. animations: Array<Animation>;
  14985. private _scene;
  14986. private _isDirty;
  14987. private _transformMatrices;
  14988. private _transformMatrixTexture;
  14989. private _meshesWithPoseMatrix;
  14990. private _animatables;
  14991. private _identity;
  14992. private _synchronizedWithMesh;
  14993. private _ranges;
  14994. private _lastAbsoluteTransformsUpdateId;
  14995. private _canUseTextureForBones;
  14996. private _uniqueId;
  14997. /** @hidden */
  14998. _numBonesWithLinkedTransformNode: number;
  14999. /** @hidden */
  15000. _hasWaitingData: Nullable<boolean>;
  15001. /**
  15002. * Specifies if the skeleton should be serialized
  15003. */
  15004. doNotSerialize: boolean;
  15005. private _useTextureToStoreBoneMatrices;
  15006. /**
  15007. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15008. * Please note that this option is not available if the hardware does not support it
  15009. */
  15010. get useTextureToStoreBoneMatrices(): boolean;
  15011. set useTextureToStoreBoneMatrices(value: boolean);
  15012. private _animationPropertiesOverride;
  15013. /**
  15014. * Gets or sets the animation properties override
  15015. */
  15016. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15017. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15018. /**
  15019. * List of inspectable custom properties (used by the Inspector)
  15020. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15021. */
  15022. inspectableCustomProperties: IInspectable[];
  15023. /**
  15024. * An observable triggered before computing the skeleton's matrices
  15025. */
  15026. onBeforeComputeObservable: Observable<Skeleton>;
  15027. /**
  15028. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15029. */
  15030. get isUsingTextureForMatrices(): boolean;
  15031. /**
  15032. * Gets the unique ID of this skeleton
  15033. */
  15034. get uniqueId(): number;
  15035. /**
  15036. * Creates a new skeleton
  15037. * @param name defines the skeleton name
  15038. * @param id defines the skeleton Id
  15039. * @param scene defines the hosting scene
  15040. */
  15041. constructor(
  15042. /** defines the skeleton name */
  15043. name: string,
  15044. /** defines the skeleton Id */
  15045. id: string, scene: Scene);
  15046. /**
  15047. * Gets the current object class name.
  15048. * @return the class name
  15049. */
  15050. getClassName(): string;
  15051. /**
  15052. * Returns an array containing the root bones
  15053. * @returns an array containing the root bones
  15054. */
  15055. getChildren(): Array<Bone>;
  15056. /**
  15057. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15058. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15059. * @returns a Float32Array containing matrices data
  15060. */
  15061. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15062. /**
  15063. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15064. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15065. * @returns a raw texture containing the data
  15066. */
  15067. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15068. /**
  15069. * Gets the current hosting scene
  15070. * @returns a scene object
  15071. */
  15072. getScene(): Scene;
  15073. /**
  15074. * Gets a string representing the current skeleton data
  15075. * @param fullDetails defines a boolean indicating if we want a verbose version
  15076. * @returns a string representing the current skeleton data
  15077. */
  15078. toString(fullDetails?: boolean): string;
  15079. /**
  15080. * Get bone's index searching by name
  15081. * @param name defines bone's name to search for
  15082. * @return the indice of the bone. Returns -1 if not found
  15083. */
  15084. getBoneIndexByName(name: string): number;
  15085. /**
  15086. * Creater a new animation range
  15087. * @param name defines the name of the range
  15088. * @param from defines the start key
  15089. * @param to defines the end key
  15090. */
  15091. createAnimationRange(name: string, from: number, to: number): void;
  15092. /**
  15093. * Delete a specific animation range
  15094. * @param name defines the name of the range
  15095. * @param deleteFrames defines if frames must be removed as well
  15096. */
  15097. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15098. /**
  15099. * Gets a specific animation range
  15100. * @param name defines the name of the range to look for
  15101. * @returns the requested animation range or null if not found
  15102. */
  15103. getAnimationRange(name: string): Nullable<AnimationRange>;
  15104. /**
  15105. * Gets the list of all animation ranges defined on this skeleton
  15106. * @returns an array
  15107. */
  15108. getAnimationRanges(): Nullable<AnimationRange>[];
  15109. /**
  15110. * Copy animation range from a source skeleton.
  15111. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15112. * @param source defines the source skeleton
  15113. * @param name defines the name of the range to copy
  15114. * @param rescaleAsRequired defines if rescaling must be applied if required
  15115. * @returns true if operation was successful
  15116. */
  15117. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15118. /**
  15119. * Forces the skeleton to go to rest pose
  15120. */
  15121. returnToRest(): void;
  15122. private _getHighestAnimationFrame;
  15123. /**
  15124. * Begin a specific animation range
  15125. * @param name defines the name of the range to start
  15126. * @param loop defines if looping must be turned on (false by default)
  15127. * @param speedRatio defines the speed ratio to apply (1 by default)
  15128. * @param onAnimationEnd defines a callback which will be called when animation will end
  15129. * @returns a new animatable
  15130. */
  15131. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15132. /**
  15133. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15134. * @param skeleton defines the Skeleton containing the animation range to convert
  15135. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15136. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15137. * @returns the original skeleton
  15138. */
  15139. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15140. /** @hidden */
  15141. _markAsDirty(): void;
  15142. /** @hidden */
  15143. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15144. /** @hidden */
  15145. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15146. private _computeTransformMatrices;
  15147. /**
  15148. * Build all resources required to render a skeleton
  15149. */
  15150. prepare(): void;
  15151. /**
  15152. * Gets the list of animatables currently running for this skeleton
  15153. * @returns an array of animatables
  15154. */
  15155. getAnimatables(): IAnimatable[];
  15156. /**
  15157. * Clone the current skeleton
  15158. * @param name defines the name of the new skeleton
  15159. * @param id defines the id of the new skeleton
  15160. * @returns the new skeleton
  15161. */
  15162. clone(name: string, id?: string): Skeleton;
  15163. /**
  15164. * Enable animation blending for this skeleton
  15165. * @param blendingSpeed defines the blending speed to apply
  15166. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15167. */
  15168. enableBlending(blendingSpeed?: number): void;
  15169. /**
  15170. * Releases all resources associated with the current skeleton
  15171. */
  15172. dispose(): void;
  15173. /**
  15174. * Serialize the skeleton in a JSON object
  15175. * @returns a JSON object
  15176. */
  15177. serialize(): any;
  15178. /**
  15179. * Creates a new skeleton from serialized data
  15180. * @param parsedSkeleton defines the serialized data
  15181. * @param scene defines the hosting scene
  15182. * @returns a new skeleton
  15183. */
  15184. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15185. /**
  15186. * Compute all node absolute transforms
  15187. * @param forceUpdate defines if computation must be done even if cache is up to date
  15188. */
  15189. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15190. /**
  15191. * Gets the root pose matrix
  15192. * @returns a matrix
  15193. */
  15194. getPoseMatrix(): Nullable<Matrix>;
  15195. /**
  15196. * Sorts bones per internal index
  15197. */
  15198. sortBones(): void;
  15199. private _sortBones;
  15200. }
  15201. }
  15202. declare module BABYLON {
  15203. /**
  15204. * Creates an instance based on a source mesh.
  15205. */
  15206. export class InstancedMesh extends AbstractMesh {
  15207. private _sourceMesh;
  15208. private _currentLOD;
  15209. /** @hidden */
  15210. _indexInSourceMeshInstanceArray: number;
  15211. constructor(name: string, source: Mesh);
  15212. /**
  15213. * Returns the string "InstancedMesh".
  15214. */
  15215. getClassName(): string;
  15216. /** Gets the list of lights affecting that mesh */
  15217. get lightSources(): Light[];
  15218. _resyncLightSources(): void;
  15219. _resyncLightSource(light: Light): void;
  15220. _removeLightSource(light: Light, dispose: boolean): void;
  15221. /**
  15222. * If the source mesh receives shadows
  15223. */
  15224. get receiveShadows(): boolean;
  15225. /**
  15226. * The material of the source mesh
  15227. */
  15228. get material(): Nullable<Material>;
  15229. /**
  15230. * Visibility of the source mesh
  15231. */
  15232. get visibility(): number;
  15233. /**
  15234. * Skeleton of the source mesh
  15235. */
  15236. get skeleton(): Nullable<Skeleton>;
  15237. /**
  15238. * Rendering ground id of the source mesh
  15239. */
  15240. get renderingGroupId(): number;
  15241. set renderingGroupId(value: number);
  15242. /**
  15243. * Returns the total number of vertices (integer).
  15244. */
  15245. getTotalVertices(): number;
  15246. /**
  15247. * Returns a positive integer : the total number of indices in this mesh geometry.
  15248. * @returns the numner of indices or zero if the mesh has no geometry.
  15249. */
  15250. getTotalIndices(): number;
  15251. /**
  15252. * The source mesh of the instance
  15253. */
  15254. get sourceMesh(): Mesh;
  15255. /**
  15256. * Is this node ready to be used/rendered
  15257. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15258. * @return {boolean} is it ready
  15259. */
  15260. isReady(completeCheck?: boolean): boolean;
  15261. /**
  15262. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15263. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15264. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  15265. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15266. */
  15267. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15268. /**
  15269. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15270. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15271. * The `data` are either a numeric array either a Float32Array.
  15272. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15273. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  15274. * Note that a new underlying VertexBuffer object is created each call.
  15275. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15276. *
  15277. * Possible `kind` values :
  15278. * - VertexBuffer.PositionKind
  15279. * - VertexBuffer.UVKind
  15280. * - VertexBuffer.UV2Kind
  15281. * - VertexBuffer.UV3Kind
  15282. * - VertexBuffer.UV4Kind
  15283. * - VertexBuffer.UV5Kind
  15284. * - VertexBuffer.UV6Kind
  15285. * - VertexBuffer.ColorKind
  15286. * - VertexBuffer.MatricesIndicesKind
  15287. * - VertexBuffer.MatricesIndicesExtraKind
  15288. * - VertexBuffer.MatricesWeightsKind
  15289. * - VertexBuffer.MatricesWeightsExtraKind
  15290. *
  15291. * Returns the Mesh.
  15292. */
  15293. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15294. /**
  15295. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15296. * If the mesh has no geometry, it is simply returned as it is.
  15297. * The `data` are either a numeric array either a Float32Array.
  15298. * No new underlying VertexBuffer object is created.
  15299. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15300. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15301. *
  15302. * Possible `kind` values :
  15303. * - VertexBuffer.PositionKind
  15304. * - VertexBuffer.UVKind
  15305. * - VertexBuffer.UV2Kind
  15306. * - VertexBuffer.UV3Kind
  15307. * - VertexBuffer.UV4Kind
  15308. * - VertexBuffer.UV5Kind
  15309. * - VertexBuffer.UV6Kind
  15310. * - VertexBuffer.ColorKind
  15311. * - VertexBuffer.MatricesIndicesKind
  15312. * - VertexBuffer.MatricesIndicesExtraKind
  15313. * - VertexBuffer.MatricesWeightsKind
  15314. * - VertexBuffer.MatricesWeightsExtraKind
  15315. *
  15316. * Returns the Mesh.
  15317. */
  15318. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15319. /**
  15320. * Sets the mesh indices.
  15321. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15322. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15323. * This method creates a new index buffer each call.
  15324. * Returns the Mesh.
  15325. */
  15326. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15327. /**
  15328. * Boolean : True if the mesh owns the requested kind of data.
  15329. */
  15330. isVerticesDataPresent(kind: string): boolean;
  15331. /**
  15332. * Returns an array of indices (IndicesArray).
  15333. */
  15334. getIndices(): Nullable<IndicesArray>;
  15335. get _positions(): Nullable<Vector3[]>;
  15336. /**
  15337. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15338. * This means the mesh underlying bounding box and sphere are recomputed.
  15339. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15340. * @returns the current mesh
  15341. */
  15342. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15343. /** @hidden */
  15344. _preActivate(): InstancedMesh;
  15345. /** @hidden */
  15346. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15347. /** @hidden */
  15348. _postActivate(): void;
  15349. getWorldMatrix(): Matrix;
  15350. get isAnInstance(): boolean;
  15351. /**
  15352. * Returns the current associated LOD AbstractMesh.
  15353. */
  15354. getLOD(camera: Camera): AbstractMesh;
  15355. /** @hidden */
  15356. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15357. /** @hidden */
  15358. _syncSubMeshes(): InstancedMesh;
  15359. /** @hidden */
  15360. _generatePointsArray(): boolean;
  15361. /**
  15362. * Creates a new InstancedMesh from the current mesh.
  15363. * - name (string) : the cloned mesh name
  15364. * - newParent (optional Node) : the optional Node to parent the clone to.
  15365. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15366. *
  15367. * Returns the clone.
  15368. */
  15369. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15370. /**
  15371. * Disposes the InstancedMesh.
  15372. * Returns nothing.
  15373. */
  15374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15375. }
  15376. interface Mesh {
  15377. /**
  15378. * Register a custom buffer that will be instanced
  15379. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15380. * @param kind defines the buffer kind
  15381. * @param stride defines the stride in floats
  15382. */
  15383. registerInstancedBuffer(kind: string, stride: number): void;
  15384. /** @hidden */
  15385. _userInstancedBuffersStorage: {
  15386. data: {
  15387. [key: string]: Float32Array;
  15388. };
  15389. sizes: {
  15390. [key: string]: number;
  15391. };
  15392. vertexBuffers: {
  15393. [key: string]: Nullable<VertexBuffer>;
  15394. };
  15395. strides: {
  15396. [key: string]: number;
  15397. };
  15398. };
  15399. }
  15400. interface AbstractMesh {
  15401. /**
  15402. * Object used to store instanced buffers defined by user
  15403. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15404. */
  15405. instancedBuffers: {
  15406. [key: string]: any;
  15407. };
  15408. }
  15409. }
  15410. declare module BABYLON {
  15411. /**
  15412. * Defines the options associated with the creation of a shader material.
  15413. */
  15414. export interface IShaderMaterialOptions {
  15415. /**
  15416. * Does the material work in alpha blend mode
  15417. */
  15418. needAlphaBlending: boolean;
  15419. /**
  15420. * Does the material work in alpha test mode
  15421. */
  15422. needAlphaTesting: boolean;
  15423. /**
  15424. * The list of attribute names used in the shader
  15425. */
  15426. attributes: string[];
  15427. /**
  15428. * The list of unifrom names used in the shader
  15429. */
  15430. uniforms: string[];
  15431. /**
  15432. * The list of UBO names used in the shader
  15433. */
  15434. uniformBuffers: string[];
  15435. /**
  15436. * The list of sampler names used in the shader
  15437. */
  15438. samplers: string[];
  15439. /**
  15440. * The list of defines used in the shader
  15441. */
  15442. defines: string[];
  15443. }
  15444. /**
  15445. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15446. *
  15447. * This returned material effects how the mesh will look based on the code in the shaders.
  15448. *
  15449. * @see http://doc.babylonjs.com/how_to/shader_material
  15450. */
  15451. export class ShaderMaterial extends Material {
  15452. private _shaderPath;
  15453. private _options;
  15454. private _textures;
  15455. private _textureArrays;
  15456. private _floats;
  15457. private _ints;
  15458. private _floatsArrays;
  15459. private _colors3;
  15460. private _colors3Arrays;
  15461. private _colors4;
  15462. private _colors4Arrays;
  15463. private _vectors2;
  15464. private _vectors3;
  15465. private _vectors4;
  15466. private _matrices;
  15467. private _matrixArrays;
  15468. private _matrices3x3;
  15469. private _matrices2x2;
  15470. private _vectors2Arrays;
  15471. private _vectors3Arrays;
  15472. private _vectors4Arrays;
  15473. private _cachedWorldViewMatrix;
  15474. private _cachedWorldViewProjectionMatrix;
  15475. private _renderId;
  15476. private _multiview;
  15477. /**
  15478. * Instantiate a new shader material.
  15479. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15480. * This returned material effects how the mesh will look based on the code in the shaders.
  15481. * @see http://doc.babylonjs.com/how_to/shader_material
  15482. * @param name Define the name of the material in the scene
  15483. * @param scene Define the scene the material belongs to
  15484. * @param shaderPath Defines the route to the shader code in one of three ways:
  15485. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15486. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15487. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15488. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15489. * @param options Define the options used to create the shader
  15490. */
  15491. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15492. /**
  15493. * Gets the shader path used to define the shader code
  15494. * It can be modified to trigger a new compilation
  15495. */
  15496. get shaderPath(): any;
  15497. /**
  15498. * Sets the shader path used to define the shader code
  15499. * It can be modified to trigger a new compilation
  15500. */
  15501. set shaderPath(shaderPath: any);
  15502. /**
  15503. * Gets the options used to compile the shader.
  15504. * They can be modified to trigger a new compilation
  15505. */
  15506. get options(): IShaderMaterialOptions;
  15507. /**
  15508. * Gets the current class name of the material e.g. "ShaderMaterial"
  15509. * Mainly use in serialization.
  15510. * @returns the class name
  15511. */
  15512. getClassName(): string;
  15513. /**
  15514. * Specifies if the material will require alpha blending
  15515. * @returns a boolean specifying if alpha blending is needed
  15516. */
  15517. needAlphaBlending(): boolean;
  15518. /**
  15519. * Specifies if this material should be rendered in alpha test mode
  15520. * @returns a boolean specifying if an alpha test is needed.
  15521. */
  15522. needAlphaTesting(): boolean;
  15523. private _checkUniform;
  15524. /**
  15525. * Set a texture in the shader.
  15526. * @param name Define the name of the uniform samplers as defined in the shader
  15527. * @param texture Define the texture to bind to this sampler
  15528. * @return the material itself allowing "fluent" like uniform updates
  15529. */
  15530. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15531. /**
  15532. * Set a texture array in the shader.
  15533. * @param name Define the name of the uniform sampler array as defined in the shader
  15534. * @param textures Define the list of textures to bind to this sampler
  15535. * @return the material itself allowing "fluent" like uniform updates
  15536. */
  15537. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15538. /**
  15539. * Set a float in the shader.
  15540. * @param name Define the name of the uniform as defined in the shader
  15541. * @param value Define the value to give to the uniform
  15542. * @return the material itself allowing "fluent" like uniform updates
  15543. */
  15544. setFloat(name: string, value: number): ShaderMaterial;
  15545. /**
  15546. * Set a int in the shader.
  15547. * @param name Define the name of the uniform as defined in the shader
  15548. * @param value Define the value to give to the uniform
  15549. * @return the material itself allowing "fluent" like uniform updates
  15550. */
  15551. setInt(name: string, value: number): ShaderMaterial;
  15552. /**
  15553. * Set an array of floats in the shader.
  15554. * @param name Define the name of the uniform as defined in the shader
  15555. * @param value Define the value to give to the uniform
  15556. * @return the material itself allowing "fluent" like uniform updates
  15557. */
  15558. setFloats(name: string, value: number[]): ShaderMaterial;
  15559. /**
  15560. * Set a vec3 in the shader from a Color3.
  15561. * @param name Define the name of the uniform as defined in the shader
  15562. * @param value Define the value to give to the uniform
  15563. * @return the material itself allowing "fluent" like uniform updates
  15564. */
  15565. setColor3(name: string, value: Color3): ShaderMaterial;
  15566. /**
  15567. * Set a vec3 array in the shader from a Color3 array.
  15568. * @param name Define the name of the uniform as defined in the shader
  15569. * @param value Define the value to give to the uniform
  15570. * @return the material itself allowing "fluent" like uniform updates
  15571. */
  15572. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15573. /**
  15574. * Set a vec4 in the shader from a Color4.
  15575. * @param name Define the name of the uniform as defined in the shader
  15576. * @param value Define the value to give to the uniform
  15577. * @return the material itself allowing "fluent" like uniform updates
  15578. */
  15579. setColor4(name: string, value: Color4): ShaderMaterial;
  15580. /**
  15581. * Set a vec4 array in the shader from a Color4 array.
  15582. * @param name Define the name of the uniform as defined in the shader
  15583. * @param value Define the value to give to the uniform
  15584. * @return the material itself allowing "fluent" like uniform updates
  15585. */
  15586. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15587. /**
  15588. * Set a vec2 in the shader from a Vector2.
  15589. * @param name Define the name of the uniform as defined in the shader
  15590. * @param value Define the value to give to the uniform
  15591. * @return the material itself allowing "fluent" like uniform updates
  15592. */
  15593. setVector2(name: string, value: Vector2): ShaderMaterial;
  15594. /**
  15595. * Set a vec3 in the shader from a Vector3.
  15596. * @param name Define the name of the uniform as defined in the shader
  15597. * @param value Define the value to give to the uniform
  15598. * @return the material itself allowing "fluent" like uniform updates
  15599. */
  15600. setVector3(name: string, value: Vector3): ShaderMaterial;
  15601. /**
  15602. * Set a vec4 in the shader from a Vector4.
  15603. * @param name Define the name of the uniform as defined in the shader
  15604. * @param value Define the value to give to the uniform
  15605. * @return the material itself allowing "fluent" like uniform updates
  15606. */
  15607. setVector4(name: string, value: Vector4): ShaderMaterial;
  15608. /**
  15609. * Set a mat4 in the shader from a Matrix.
  15610. * @param name Define the name of the uniform as defined in the shader
  15611. * @param value Define the value to give to the uniform
  15612. * @return the material itself allowing "fluent" like uniform updates
  15613. */
  15614. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15615. /**
  15616. * Set a float32Array in the shader from a matrix array.
  15617. * @param name Define the name of the uniform as defined in the shader
  15618. * @param value Define the value to give to the uniform
  15619. * @return the material itself allowing "fluent" like uniform updates
  15620. */
  15621. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15622. /**
  15623. * Set a mat3 in the shader from a Float32Array.
  15624. * @param name Define the name of the uniform as defined in the shader
  15625. * @param value Define the value to give to the uniform
  15626. * @return the material itself allowing "fluent" like uniform updates
  15627. */
  15628. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15629. /**
  15630. * Set a mat2 in the shader from a Float32Array.
  15631. * @param name Define the name of the uniform as defined in the shader
  15632. * @param value Define the value to give to the uniform
  15633. * @return the material itself allowing "fluent" like uniform updates
  15634. */
  15635. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15636. /**
  15637. * Set a vec2 array in the shader from a number array.
  15638. * @param name Define the name of the uniform as defined in the shader
  15639. * @param value Define the value to give to the uniform
  15640. * @return the material itself allowing "fluent" like uniform updates
  15641. */
  15642. setArray2(name: string, value: number[]): ShaderMaterial;
  15643. /**
  15644. * Set a vec3 array in the shader from a number array.
  15645. * @param name Define the name of the uniform as defined in the shader
  15646. * @param value Define the value to give to the uniform
  15647. * @return the material itself allowing "fluent" like uniform updates
  15648. */
  15649. setArray3(name: string, value: number[]): ShaderMaterial;
  15650. /**
  15651. * Set a vec4 array in the shader from a number array.
  15652. * @param name Define the name of the uniform as defined in the shader
  15653. * @param value Define the value to give to the uniform
  15654. * @return the material itself allowing "fluent" like uniform updates
  15655. */
  15656. setArray4(name: string, value: number[]): ShaderMaterial;
  15657. private _checkCache;
  15658. /**
  15659. * Specifies that the submesh is ready to be used
  15660. * @param mesh defines the mesh to check
  15661. * @param subMesh defines which submesh to check
  15662. * @param useInstances specifies that instances should be used
  15663. * @returns a boolean indicating that the submesh is ready or not
  15664. */
  15665. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15666. /**
  15667. * Checks if the material is ready to render the requested mesh
  15668. * @param mesh Define the mesh to render
  15669. * @param useInstances Define whether or not the material is used with instances
  15670. * @returns true if ready, otherwise false
  15671. */
  15672. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15673. /**
  15674. * Binds the world matrix to the material
  15675. * @param world defines the world transformation matrix
  15676. */
  15677. bindOnlyWorldMatrix(world: Matrix): void;
  15678. /**
  15679. * Binds the material to the mesh
  15680. * @param world defines the world transformation matrix
  15681. * @param mesh defines the mesh to bind the material to
  15682. */
  15683. bind(world: Matrix, mesh?: Mesh): void;
  15684. /**
  15685. * Gets the active textures from the material
  15686. * @returns an array of textures
  15687. */
  15688. getActiveTextures(): BaseTexture[];
  15689. /**
  15690. * Specifies if the material uses a texture
  15691. * @param texture defines the texture to check against the material
  15692. * @returns a boolean specifying if the material uses the texture
  15693. */
  15694. hasTexture(texture: BaseTexture): boolean;
  15695. /**
  15696. * Makes a duplicate of the material, and gives it a new name
  15697. * @param name defines the new name for the duplicated material
  15698. * @returns the cloned material
  15699. */
  15700. clone(name: string): ShaderMaterial;
  15701. /**
  15702. * Disposes the material
  15703. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15704. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15705. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15706. */
  15707. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15708. /**
  15709. * Serializes this material in a JSON representation
  15710. * @returns the serialized material object
  15711. */
  15712. serialize(): any;
  15713. /**
  15714. * Creates a shader material from parsed shader material data
  15715. * @param source defines the JSON represnetation of the material
  15716. * @param scene defines the hosting scene
  15717. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15718. * @returns a new material
  15719. */
  15720. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15721. }
  15722. }
  15723. declare module BABYLON {
  15724. /** @hidden */
  15725. export var colorPixelShader: {
  15726. name: string;
  15727. shader: string;
  15728. };
  15729. }
  15730. declare module BABYLON {
  15731. /** @hidden */
  15732. export var colorVertexShader: {
  15733. name: string;
  15734. shader: string;
  15735. };
  15736. }
  15737. declare module BABYLON {
  15738. /**
  15739. * Line mesh
  15740. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15741. */
  15742. export class LinesMesh extends Mesh {
  15743. /**
  15744. * If vertex color should be applied to the mesh
  15745. */
  15746. readonly useVertexColor?: boolean | undefined;
  15747. /**
  15748. * If vertex alpha should be applied to the mesh
  15749. */
  15750. readonly useVertexAlpha?: boolean | undefined;
  15751. /**
  15752. * Color of the line (Default: White)
  15753. */
  15754. color: Color3;
  15755. /**
  15756. * Alpha of the line (Default: 1)
  15757. */
  15758. alpha: number;
  15759. /**
  15760. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15761. * This margin is expressed in world space coordinates, so its value may vary.
  15762. * Default value is 0.1
  15763. */
  15764. intersectionThreshold: number;
  15765. private _colorShader;
  15766. private color4;
  15767. /**
  15768. * Creates a new LinesMesh
  15769. * @param name defines the name
  15770. * @param scene defines the hosting scene
  15771. * @param parent defines the parent mesh if any
  15772. * @param source defines the optional source LinesMesh used to clone data from
  15773. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15774. * When false, achieved by calling a clone(), also passing False.
  15775. * This will make creation of children, recursive.
  15776. * @param useVertexColor defines if this LinesMesh supports vertex color
  15777. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15778. */
  15779. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15780. /**
  15781. * If vertex color should be applied to the mesh
  15782. */
  15783. useVertexColor?: boolean | undefined,
  15784. /**
  15785. * If vertex alpha should be applied to the mesh
  15786. */
  15787. useVertexAlpha?: boolean | undefined);
  15788. private _addClipPlaneDefine;
  15789. private _removeClipPlaneDefine;
  15790. isReady(): boolean;
  15791. /**
  15792. * Returns the string "LineMesh"
  15793. */
  15794. getClassName(): string;
  15795. /**
  15796. * @hidden
  15797. */
  15798. get material(): Material;
  15799. /**
  15800. * @hidden
  15801. */
  15802. set material(value: Material);
  15803. /**
  15804. * @hidden
  15805. */
  15806. get checkCollisions(): boolean;
  15807. /** @hidden */
  15808. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15809. /** @hidden */
  15810. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15811. /**
  15812. * Disposes of the line mesh
  15813. * @param doNotRecurse If children should be disposed
  15814. */
  15815. dispose(doNotRecurse?: boolean): void;
  15816. /**
  15817. * Returns a new LineMesh object cloned from the current one.
  15818. */
  15819. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15820. /**
  15821. * Creates a new InstancedLinesMesh object from the mesh model.
  15822. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15823. * @param name defines the name of the new instance
  15824. * @returns a new InstancedLinesMesh
  15825. */
  15826. createInstance(name: string): InstancedLinesMesh;
  15827. }
  15828. /**
  15829. * Creates an instance based on a source LinesMesh
  15830. */
  15831. export class InstancedLinesMesh extends InstancedMesh {
  15832. /**
  15833. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15834. * This margin is expressed in world space coordinates, so its value may vary.
  15835. * Initilized with the intersectionThreshold value of the source LinesMesh
  15836. */
  15837. intersectionThreshold: number;
  15838. constructor(name: string, source: LinesMesh);
  15839. /**
  15840. * Returns the string "InstancedLinesMesh".
  15841. */
  15842. getClassName(): string;
  15843. }
  15844. }
  15845. declare module BABYLON {
  15846. /** @hidden */
  15847. export var linePixelShader: {
  15848. name: string;
  15849. shader: string;
  15850. };
  15851. }
  15852. declare module BABYLON {
  15853. /** @hidden */
  15854. export var lineVertexShader: {
  15855. name: string;
  15856. shader: string;
  15857. };
  15858. }
  15859. declare module BABYLON {
  15860. interface AbstractMesh {
  15861. /**
  15862. * Gets the edgesRenderer associated with the mesh
  15863. */
  15864. edgesRenderer: Nullable<EdgesRenderer>;
  15865. }
  15866. interface LinesMesh {
  15867. /**
  15868. * Enables the edge rendering mode on the mesh.
  15869. * This mode makes the mesh edges visible
  15870. * @param epsilon defines the maximal distance between two angles to detect a face
  15871. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15872. * @returns the currentAbstractMesh
  15873. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15874. */
  15875. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15876. }
  15877. interface InstancedLinesMesh {
  15878. /**
  15879. * Enables the edge rendering mode on the mesh.
  15880. * This mode makes the mesh edges visible
  15881. * @param epsilon defines the maximal distance between two angles to detect a face
  15882. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15883. * @returns the current InstancedLinesMesh
  15884. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15885. */
  15886. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15887. }
  15888. /**
  15889. * Defines the minimum contract an Edges renderer should follow.
  15890. */
  15891. export interface IEdgesRenderer extends IDisposable {
  15892. /**
  15893. * Gets or sets a boolean indicating if the edgesRenderer is active
  15894. */
  15895. isEnabled: boolean;
  15896. /**
  15897. * Renders the edges of the attached mesh,
  15898. */
  15899. render(): void;
  15900. /**
  15901. * Checks wether or not the edges renderer is ready to render.
  15902. * @return true if ready, otherwise false.
  15903. */
  15904. isReady(): boolean;
  15905. }
  15906. /**
  15907. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15908. */
  15909. export class EdgesRenderer implements IEdgesRenderer {
  15910. /**
  15911. * Define the size of the edges with an orthographic camera
  15912. */
  15913. edgesWidthScalerForOrthographic: number;
  15914. /**
  15915. * Define the size of the edges with a perspective camera
  15916. */
  15917. edgesWidthScalerForPerspective: number;
  15918. protected _source: AbstractMesh;
  15919. protected _linesPositions: number[];
  15920. protected _linesNormals: number[];
  15921. protected _linesIndices: number[];
  15922. protected _epsilon: number;
  15923. protected _indicesCount: number;
  15924. protected _lineShader: ShaderMaterial;
  15925. protected _ib: DataBuffer;
  15926. protected _buffers: {
  15927. [key: string]: Nullable<VertexBuffer>;
  15928. };
  15929. protected _checkVerticesInsteadOfIndices: boolean;
  15930. private _meshRebuildObserver;
  15931. private _meshDisposeObserver;
  15932. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15933. isEnabled: boolean;
  15934. /**
  15935. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15936. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15937. * @param source Mesh used to create edges
  15938. * @param epsilon sum of angles in adjacency to check for edge
  15939. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15940. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15941. */
  15942. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15943. protected _prepareRessources(): void;
  15944. /** @hidden */
  15945. _rebuild(): void;
  15946. /**
  15947. * Releases the required resources for the edges renderer
  15948. */
  15949. dispose(): void;
  15950. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15951. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15952. /**
  15953. * Checks if the pair of p0 and p1 is en edge
  15954. * @param faceIndex
  15955. * @param edge
  15956. * @param faceNormals
  15957. * @param p0
  15958. * @param p1
  15959. * @private
  15960. */
  15961. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15962. /**
  15963. * push line into the position, normal and index buffer
  15964. * @protected
  15965. */
  15966. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15967. /**
  15968. * Generates lines edges from adjacencjes
  15969. * @private
  15970. */
  15971. _generateEdgesLines(): void;
  15972. /**
  15973. * Checks wether or not the edges renderer is ready to render.
  15974. * @return true if ready, otherwise false.
  15975. */
  15976. isReady(): boolean;
  15977. /**
  15978. * Renders the edges of the attached mesh,
  15979. */
  15980. render(): void;
  15981. }
  15982. /**
  15983. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15984. */
  15985. export class LineEdgesRenderer extends EdgesRenderer {
  15986. /**
  15987. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15988. * @param source LineMesh used to generate edges
  15989. * @param epsilon not important (specified angle for edge detection)
  15990. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15991. */
  15992. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15993. /**
  15994. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15995. */
  15996. _generateEdgesLines(): void;
  15997. }
  15998. }
  15999. declare module BABYLON {
  16000. /**
  16001. * This represents the object necessary to create a rendering group.
  16002. * This is exclusively used and created by the rendering manager.
  16003. * To modify the behavior, you use the available helpers in your scene or meshes.
  16004. * @hidden
  16005. */
  16006. export class RenderingGroup {
  16007. index: number;
  16008. private static _zeroVector;
  16009. private _scene;
  16010. private _opaqueSubMeshes;
  16011. private _transparentSubMeshes;
  16012. private _alphaTestSubMeshes;
  16013. private _depthOnlySubMeshes;
  16014. private _particleSystems;
  16015. private _spriteManagers;
  16016. private _opaqueSortCompareFn;
  16017. private _alphaTestSortCompareFn;
  16018. private _transparentSortCompareFn;
  16019. private _renderOpaque;
  16020. private _renderAlphaTest;
  16021. private _renderTransparent;
  16022. /** @hidden */
  16023. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16024. onBeforeTransparentRendering: () => void;
  16025. /**
  16026. * Set the opaque sort comparison function.
  16027. * If null the sub meshes will be render in the order they were created
  16028. */
  16029. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16030. /**
  16031. * Set the alpha test sort comparison function.
  16032. * If null the sub meshes will be render in the order they were created
  16033. */
  16034. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16035. /**
  16036. * Set the transparent sort comparison function.
  16037. * If null the sub meshes will be render in the order they were created
  16038. */
  16039. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16040. /**
  16041. * Creates a new rendering group.
  16042. * @param index The rendering group index
  16043. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16044. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16045. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16046. */
  16047. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16048. /**
  16049. * Render all the sub meshes contained in the group.
  16050. * @param customRenderFunction Used to override the default render behaviour of the group.
  16051. * @returns true if rendered some submeshes.
  16052. */
  16053. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16054. /**
  16055. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16056. * @param subMeshes The submeshes to render
  16057. */
  16058. private renderOpaqueSorted;
  16059. /**
  16060. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16061. * @param subMeshes The submeshes to render
  16062. */
  16063. private renderAlphaTestSorted;
  16064. /**
  16065. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16066. * @param subMeshes The submeshes to render
  16067. */
  16068. private renderTransparentSorted;
  16069. /**
  16070. * Renders the submeshes in a specified order.
  16071. * @param subMeshes The submeshes to sort before render
  16072. * @param sortCompareFn The comparison function use to sort
  16073. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16074. * @param transparent Specifies to activate blending if true
  16075. */
  16076. private static renderSorted;
  16077. /**
  16078. * Renders the submeshes in the order they were dispatched (no sort applied).
  16079. * @param subMeshes The submeshes to render
  16080. */
  16081. private static renderUnsorted;
  16082. /**
  16083. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16084. * are rendered back to front if in the same alpha index.
  16085. *
  16086. * @param a The first submesh
  16087. * @param b The second submesh
  16088. * @returns The result of the comparison
  16089. */
  16090. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16091. /**
  16092. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16093. * are rendered back to front.
  16094. *
  16095. * @param a The first submesh
  16096. * @param b The second submesh
  16097. * @returns The result of the comparison
  16098. */
  16099. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16100. /**
  16101. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16102. * are rendered front to back (prevent overdraw).
  16103. *
  16104. * @param a The first submesh
  16105. * @param b The second submesh
  16106. * @returns The result of the comparison
  16107. */
  16108. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16109. /**
  16110. * Resets the different lists of submeshes to prepare a new frame.
  16111. */
  16112. prepare(): void;
  16113. dispose(): void;
  16114. /**
  16115. * Inserts the submesh in its correct queue depending on its material.
  16116. * @param subMesh The submesh to dispatch
  16117. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16118. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16119. */
  16120. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16121. dispatchSprites(spriteManager: ISpriteManager): void;
  16122. dispatchParticles(particleSystem: IParticleSystem): void;
  16123. private _renderParticles;
  16124. private _renderSprites;
  16125. }
  16126. }
  16127. declare module BABYLON {
  16128. /**
  16129. * Interface describing the different options available in the rendering manager
  16130. * regarding Auto Clear between groups.
  16131. */
  16132. export interface IRenderingManagerAutoClearSetup {
  16133. /**
  16134. * Defines whether or not autoclear is enable.
  16135. */
  16136. autoClear: boolean;
  16137. /**
  16138. * Defines whether or not to autoclear the depth buffer.
  16139. */
  16140. depth: boolean;
  16141. /**
  16142. * Defines whether or not to autoclear the stencil buffer.
  16143. */
  16144. stencil: boolean;
  16145. }
  16146. /**
  16147. * This class is used by the onRenderingGroupObservable
  16148. */
  16149. export class RenderingGroupInfo {
  16150. /**
  16151. * The Scene that being rendered
  16152. */
  16153. scene: Scene;
  16154. /**
  16155. * The camera currently used for the rendering pass
  16156. */
  16157. camera: Nullable<Camera>;
  16158. /**
  16159. * The ID of the renderingGroup being processed
  16160. */
  16161. renderingGroupId: number;
  16162. }
  16163. /**
  16164. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16165. * It is enable to manage the different groups as well as the different necessary sort functions.
  16166. * This should not be used directly aside of the few static configurations
  16167. */
  16168. export class RenderingManager {
  16169. /**
  16170. * The max id used for rendering groups (not included)
  16171. */
  16172. static MAX_RENDERINGGROUPS: number;
  16173. /**
  16174. * The min id used for rendering groups (included)
  16175. */
  16176. static MIN_RENDERINGGROUPS: number;
  16177. /**
  16178. * Used to globally prevent autoclearing scenes.
  16179. */
  16180. static AUTOCLEAR: boolean;
  16181. /**
  16182. * @hidden
  16183. */
  16184. _useSceneAutoClearSetup: boolean;
  16185. private _scene;
  16186. private _renderingGroups;
  16187. private _depthStencilBufferAlreadyCleaned;
  16188. private _autoClearDepthStencil;
  16189. private _customOpaqueSortCompareFn;
  16190. private _customAlphaTestSortCompareFn;
  16191. private _customTransparentSortCompareFn;
  16192. private _renderingGroupInfo;
  16193. /**
  16194. * Instantiates a new rendering group for a particular scene
  16195. * @param scene Defines the scene the groups belongs to
  16196. */
  16197. constructor(scene: Scene);
  16198. private _clearDepthStencilBuffer;
  16199. /**
  16200. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16201. * @hidden
  16202. */
  16203. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16204. /**
  16205. * Resets the different information of the group to prepare a new frame
  16206. * @hidden
  16207. */
  16208. reset(): void;
  16209. /**
  16210. * Dispose and release the group and its associated resources.
  16211. * @hidden
  16212. */
  16213. dispose(): void;
  16214. /**
  16215. * Clear the info related to rendering groups preventing retention points during dispose.
  16216. */
  16217. freeRenderingGroups(): void;
  16218. private _prepareRenderingGroup;
  16219. /**
  16220. * Add a sprite manager to the rendering manager in order to render it this frame.
  16221. * @param spriteManager Define the sprite manager to render
  16222. */
  16223. dispatchSprites(spriteManager: ISpriteManager): void;
  16224. /**
  16225. * Add a particle system to the rendering manager in order to render it this frame.
  16226. * @param particleSystem Define the particle system to render
  16227. */
  16228. dispatchParticles(particleSystem: IParticleSystem): void;
  16229. /**
  16230. * Add a submesh to the manager in order to render it this frame
  16231. * @param subMesh The submesh to dispatch
  16232. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16233. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16234. */
  16235. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16236. /**
  16237. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16238. * This allowed control for front to back rendering or reversly depending of the special needs.
  16239. *
  16240. * @param renderingGroupId The rendering group id corresponding to its index
  16241. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16242. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16243. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16244. */
  16245. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  16246. /**
  16247. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16248. *
  16249. * @param renderingGroupId The rendering group id corresponding to its index
  16250. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16251. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16252. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16253. */
  16254. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16255. /**
  16256. * Gets the current auto clear configuration for one rendering group of the rendering
  16257. * manager.
  16258. * @param index the rendering group index to get the information for
  16259. * @returns The auto clear setup for the requested rendering group
  16260. */
  16261. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16262. }
  16263. }
  16264. declare module BABYLON {
  16265. /**
  16266. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16267. */
  16268. export interface ICustomShaderOptions {
  16269. /**
  16270. * Gets or sets the custom shader name to use
  16271. */
  16272. shaderName: string;
  16273. /**
  16274. * The list of attribute names used in the shader
  16275. */
  16276. attributes?: string[];
  16277. /**
  16278. * The list of unifrom names used in the shader
  16279. */
  16280. uniforms?: string[];
  16281. /**
  16282. * The list of sampler names used in the shader
  16283. */
  16284. samplers?: string[];
  16285. /**
  16286. * The list of defines used in the shader
  16287. */
  16288. defines?: string[];
  16289. }
  16290. /**
  16291. * Interface to implement to create a shadow generator compatible with BJS.
  16292. */
  16293. export interface IShadowGenerator {
  16294. /**
  16295. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16296. * @returns The render target texture if present otherwise, null
  16297. */
  16298. getShadowMap(): Nullable<RenderTargetTexture>;
  16299. /**
  16300. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16301. * @param subMesh The submesh we want to render in the shadow map
  16302. * @param useInstances Defines wether will draw in the map using instances
  16303. * @returns true if ready otherwise, false
  16304. */
  16305. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16306. /**
  16307. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16308. * @param defines Defines of the material we want to update
  16309. * @param lightIndex Index of the light in the enabled light list of the material
  16310. */
  16311. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16312. /**
  16313. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16314. * defined in the generator but impacting the effect).
  16315. * It implies the unifroms available on the materials are the standard BJS ones.
  16316. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16317. * @param effect The effect we are binfing the information for
  16318. */
  16319. bindShadowLight(lightIndex: string, effect: Effect): void;
  16320. /**
  16321. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16322. * (eq to shadow prjection matrix * light transform matrix)
  16323. * @returns The transform matrix used to create the shadow map
  16324. */
  16325. getTransformMatrix(): Matrix;
  16326. /**
  16327. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16328. * Cube and 2D textures for instance.
  16329. */
  16330. recreateShadowMap(): void;
  16331. /**
  16332. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16333. * @param onCompiled Callback triggered at the and of the effects compilation
  16334. * @param options Sets of optional options forcing the compilation with different modes
  16335. */
  16336. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16337. useInstances: boolean;
  16338. }>): void;
  16339. /**
  16340. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16341. * @param options Sets of optional options forcing the compilation with different modes
  16342. * @returns A promise that resolves when the compilation completes
  16343. */
  16344. forceCompilationAsync(options?: Partial<{
  16345. useInstances: boolean;
  16346. }>): Promise<void>;
  16347. /**
  16348. * Serializes the shadow generator setup to a json object.
  16349. * @returns The serialized JSON object
  16350. */
  16351. serialize(): any;
  16352. /**
  16353. * Disposes the Shadow map and related Textures and effects.
  16354. */
  16355. dispose(): void;
  16356. }
  16357. /**
  16358. * Default implementation IShadowGenerator.
  16359. * This is the main object responsible of generating shadows in the framework.
  16360. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16361. */
  16362. export class ShadowGenerator implements IShadowGenerator {
  16363. /**
  16364. * Name of the shadow generator class
  16365. */
  16366. static CLASSNAME: string;
  16367. /**
  16368. * Shadow generator mode None: no filtering applied.
  16369. */
  16370. static readonly FILTER_NONE: number;
  16371. /**
  16372. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16373. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16374. */
  16375. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16376. /**
  16377. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16378. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16379. */
  16380. static readonly FILTER_POISSONSAMPLING: number;
  16381. /**
  16382. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16383. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16384. */
  16385. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16386. /**
  16387. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16388. * edge artifacts on steep falloff.
  16389. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16390. */
  16391. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16392. /**
  16393. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16394. * edge artifacts on steep falloff.
  16395. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16396. */
  16397. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16398. /**
  16399. * Shadow generator mode PCF: Percentage Closer Filtering
  16400. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16401. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16402. */
  16403. static readonly FILTER_PCF: number;
  16404. /**
  16405. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16406. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16407. * Contact Hardening
  16408. */
  16409. static readonly FILTER_PCSS: number;
  16410. /**
  16411. * Reserved for PCF and PCSS
  16412. * Highest Quality.
  16413. *
  16414. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16415. *
  16416. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16417. */
  16418. static readonly QUALITY_HIGH: number;
  16419. /**
  16420. * Reserved for PCF and PCSS
  16421. * Good tradeoff for quality/perf cross devices
  16422. *
  16423. * Execute PCF on a 3*3 kernel.
  16424. *
  16425. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16426. */
  16427. static readonly QUALITY_MEDIUM: number;
  16428. /**
  16429. * Reserved for PCF and PCSS
  16430. * The lowest quality but the fastest.
  16431. *
  16432. * Execute PCF on a 1*1 kernel.
  16433. *
  16434. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16435. */
  16436. static readonly QUALITY_LOW: number;
  16437. /** Gets or sets the custom shader name to use */
  16438. customShaderOptions: ICustomShaderOptions;
  16439. /**
  16440. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16441. */
  16442. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16443. /**
  16444. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16445. */
  16446. onAfterShadowMapRenderObservable: Observable<Effect>;
  16447. /**
  16448. * Observable triggered before a mesh is rendered in the shadow map.
  16449. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16450. */
  16451. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16452. /**
  16453. * Observable triggered after a mesh is rendered in the shadow map.
  16454. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16455. */
  16456. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16457. protected _bias: number;
  16458. /**
  16459. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16460. */
  16461. get bias(): number;
  16462. /**
  16463. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16464. */
  16465. set bias(bias: number);
  16466. protected _normalBias: number;
  16467. /**
  16468. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16469. */
  16470. get normalBias(): number;
  16471. /**
  16472. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16473. */
  16474. set normalBias(normalBias: number);
  16475. protected _blurBoxOffset: number;
  16476. /**
  16477. * Gets the blur box offset: offset applied during the blur pass.
  16478. * Only useful if useKernelBlur = false
  16479. */
  16480. get blurBoxOffset(): number;
  16481. /**
  16482. * Sets the blur box offset: offset applied during the blur pass.
  16483. * Only useful if useKernelBlur = false
  16484. */
  16485. set blurBoxOffset(value: number);
  16486. protected _blurScale: number;
  16487. /**
  16488. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16489. * 2 means half of the size.
  16490. */
  16491. get blurScale(): number;
  16492. /**
  16493. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16494. * 2 means half of the size.
  16495. */
  16496. set blurScale(value: number);
  16497. protected _blurKernel: number;
  16498. /**
  16499. * Gets the blur kernel: kernel size of the blur pass.
  16500. * Only useful if useKernelBlur = true
  16501. */
  16502. get blurKernel(): number;
  16503. /**
  16504. * Sets the blur kernel: kernel size of the blur pass.
  16505. * Only useful if useKernelBlur = true
  16506. */
  16507. set blurKernel(value: number);
  16508. protected _useKernelBlur: boolean;
  16509. /**
  16510. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16511. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16512. */
  16513. get useKernelBlur(): boolean;
  16514. /**
  16515. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16516. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16517. */
  16518. set useKernelBlur(value: boolean);
  16519. protected _depthScale: number;
  16520. /**
  16521. * Gets the depth scale used in ESM mode.
  16522. */
  16523. get depthScale(): number;
  16524. /**
  16525. * Sets the depth scale used in ESM mode.
  16526. * This can override the scale stored on the light.
  16527. */
  16528. set depthScale(value: number);
  16529. protected _validateFilter(filter: number): number;
  16530. protected _filter: number;
  16531. /**
  16532. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16533. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16534. */
  16535. get filter(): number;
  16536. /**
  16537. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16538. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16539. */
  16540. set filter(value: number);
  16541. /**
  16542. * Gets if the current filter is set to Poisson Sampling.
  16543. */
  16544. get usePoissonSampling(): boolean;
  16545. /**
  16546. * Sets the current filter to Poisson Sampling.
  16547. */
  16548. set usePoissonSampling(value: boolean);
  16549. /**
  16550. * Gets if the current filter is set to ESM.
  16551. */
  16552. get useExponentialShadowMap(): boolean;
  16553. /**
  16554. * Sets the current filter is to ESM.
  16555. */
  16556. set useExponentialShadowMap(value: boolean);
  16557. /**
  16558. * Gets if the current filter is set to filtered ESM.
  16559. */
  16560. get useBlurExponentialShadowMap(): boolean;
  16561. /**
  16562. * Gets if the current filter is set to filtered ESM.
  16563. */
  16564. set useBlurExponentialShadowMap(value: boolean);
  16565. /**
  16566. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16567. * exponential to prevent steep falloff artifacts).
  16568. */
  16569. get useCloseExponentialShadowMap(): boolean;
  16570. /**
  16571. * Sets the current filter to "close ESM" (using the inverse of the
  16572. * exponential to prevent steep falloff artifacts).
  16573. */
  16574. set useCloseExponentialShadowMap(value: boolean);
  16575. /**
  16576. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16577. * exponential to prevent steep falloff artifacts).
  16578. */
  16579. get useBlurCloseExponentialShadowMap(): boolean;
  16580. /**
  16581. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16582. * exponential to prevent steep falloff artifacts).
  16583. */
  16584. set useBlurCloseExponentialShadowMap(value: boolean);
  16585. /**
  16586. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16587. */
  16588. get usePercentageCloserFiltering(): boolean;
  16589. /**
  16590. * Sets the current filter to "PCF" (percentage closer filtering).
  16591. */
  16592. set usePercentageCloserFiltering(value: boolean);
  16593. protected _filteringQuality: number;
  16594. /**
  16595. * Gets the PCF or PCSS Quality.
  16596. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16597. */
  16598. get filteringQuality(): number;
  16599. /**
  16600. * Sets the PCF or PCSS Quality.
  16601. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16602. */
  16603. set filteringQuality(filteringQuality: number);
  16604. /**
  16605. * Gets if the current filter is set to "PCSS" (contact hardening).
  16606. */
  16607. get useContactHardeningShadow(): boolean;
  16608. /**
  16609. * Sets the current filter to "PCSS" (contact hardening).
  16610. */
  16611. set useContactHardeningShadow(value: boolean);
  16612. protected _contactHardeningLightSizeUVRatio: number;
  16613. /**
  16614. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16615. * Using a ratio helps keeping shape stability independently of the map size.
  16616. *
  16617. * It does not account for the light projection as it was having too much
  16618. * instability during the light setup or during light position changes.
  16619. *
  16620. * Only valid if useContactHardeningShadow is true.
  16621. */
  16622. get contactHardeningLightSizeUVRatio(): number;
  16623. /**
  16624. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16625. * Using a ratio helps keeping shape stability independently of the map size.
  16626. *
  16627. * It does not account for the light projection as it was having too much
  16628. * instability during the light setup or during light position changes.
  16629. *
  16630. * Only valid if useContactHardeningShadow is true.
  16631. */
  16632. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16633. protected _darkness: number;
  16634. /** Gets or sets the actual darkness of a shadow */
  16635. get darkness(): number;
  16636. set darkness(value: number);
  16637. /**
  16638. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16639. * 0 means strongest and 1 would means no shadow.
  16640. * @returns the darkness.
  16641. */
  16642. getDarkness(): number;
  16643. /**
  16644. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16645. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16646. * @returns the shadow generator allowing fluent coding.
  16647. */
  16648. setDarkness(darkness: number): ShadowGenerator;
  16649. protected _transparencyShadow: boolean;
  16650. /** Gets or sets the ability to have transparent shadow */
  16651. get transparencyShadow(): boolean;
  16652. set transparencyShadow(value: boolean);
  16653. /**
  16654. * Sets the ability to have transparent shadow (boolean).
  16655. * @param transparent True if transparent else False
  16656. * @returns the shadow generator allowing fluent coding
  16657. */
  16658. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16659. protected _shadowMap: Nullable<RenderTargetTexture>;
  16660. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16661. /**
  16662. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16663. * @returns The render target texture if present otherwise, null
  16664. */
  16665. getShadowMap(): Nullable<RenderTargetTexture>;
  16666. /**
  16667. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16668. * @returns The render target texture if the shadow map is present otherwise, null
  16669. */
  16670. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16671. /**
  16672. * Gets the class name of that object
  16673. * @returns "ShadowGenerator"
  16674. */
  16675. getClassName(): string;
  16676. /**
  16677. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16678. * @param mesh Mesh to add
  16679. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16680. * @returns the Shadow Generator itself
  16681. */
  16682. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16683. /**
  16684. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16685. * @param mesh Mesh to remove
  16686. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16687. * @returns the Shadow Generator itself
  16688. */
  16689. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16690. /**
  16691. * Controls the extent to which the shadows fade out at the edge of the frustum
  16692. */
  16693. frustumEdgeFalloff: number;
  16694. protected _light: IShadowLight;
  16695. /**
  16696. * Returns the associated light object.
  16697. * @returns the light generating the shadow
  16698. */
  16699. getLight(): IShadowLight;
  16700. /**
  16701. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16702. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16703. * It might on the other hand introduce peter panning.
  16704. */
  16705. forceBackFacesOnly: boolean;
  16706. protected _scene: Scene;
  16707. protected _lightDirection: Vector3;
  16708. protected _effect: Effect;
  16709. protected _viewMatrix: Matrix;
  16710. protected _projectionMatrix: Matrix;
  16711. protected _transformMatrix: Matrix;
  16712. protected _cachedPosition: Vector3;
  16713. protected _cachedDirection: Vector3;
  16714. protected _cachedDefines: string;
  16715. protected _currentRenderID: number;
  16716. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16717. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16718. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16719. protected _blurPostProcesses: PostProcess[];
  16720. protected _mapSize: number;
  16721. protected _currentFaceIndex: number;
  16722. protected _currentFaceIndexCache: number;
  16723. protected _textureType: number;
  16724. protected _defaultTextureMatrix: Matrix;
  16725. protected _storedUniqueId: Nullable<number>;
  16726. /** @hidden */
  16727. static _SceneComponentInitialization: (scene: Scene) => void;
  16728. /**
  16729. * Creates a ShadowGenerator object.
  16730. * A ShadowGenerator is the required tool to use the shadows.
  16731. * Each light casting shadows needs to use its own ShadowGenerator.
  16732. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16733. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16734. * @param light The light object generating the shadows.
  16735. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  16736. */
  16737. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16738. protected _initializeGenerator(): void;
  16739. protected _createTargetRenderTexture(): void;
  16740. protected _initializeShadowMap(): void;
  16741. protected _initializeBlurRTTAndPostProcesses(): void;
  16742. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16743. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16744. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16745. protected _applyFilterValues(): void;
  16746. /**
  16747. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16748. * @param onCompiled Callback triggered at the and of the effects compilation
  16749. * @param options Sets of optional options forcing the compilation with different modes
  16750. */
  16751. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16752. useInstances: boolean;
  16753. }>): void;
  16754. /**
  16755. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16756. * @param options Sets of optional options forcing the compilation with different modes
  16757. * @returns A promise that resolves when the compilation completes
  16758. */
  16759. forceCompilationAsync(options?: Partial<{
  16760. useInstances: boolean;
  16761. }>): Promise<void>;
  16762. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16763. /**
  16764. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16765. * @param subMesh The submesh we want to render in the shadow map
  16766. * @param useInstances Defines wether will draw in the map using instances
  16767. * @returns true if ready otherwise, false
  16768. */
  16769. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16770. /**
  16771. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16772. * @param defines Defines of the material we want to update
  16773. * @param lightIndex Index of the light in the enabled light list of the material
  16774. */
  16775. prepareDefines(defines: any, lightIndex: number): void;
  16776. /**
  16777. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16778. * defined in the generator but impacting the effect).
  16779. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16780. * @param effect The effect we are binfing the information for
  16781. */
  16782. bindShadowLight(lightIndex: string, effect: Effect): void;
  16783. /**
  16784. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16785. * (eq to shadow prjection matrix * light transform matrix)
  16786. * @returns The transform matrix used to create the shadow map
  16787. */
  16788. getTransformMatrix(): Matrix;
  16789. /**
  16790. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16791. * Cube and 2D textures for instance.
  16792. */
  16793. recreateShadowMap(): void;
  16794. protected _disposeBlurPostProcesses(): void;
  16795. protected _disposeRTTandPostProcesses(): void;
  16796. /**
  16797. * Disposes the ShadowGenerator.
  16798. * Returns nothing.
  16799. */
  16800. dispose(): void;
  16801. /**
  16802. * Serializes the shadow generator setup to a json object.
  16803. * @returns The serialized JSON object
  16804. */
  16805. serialize(): any;
  16806. /**
  16807. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16808. * @param parsedShadowGenerator The JSON object to parse
  16809. * @param scene The scene to create the shadow map for
  16810. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16811. * @returns The parsed shadow generator
  16812. */
  16813. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16814. }
  16815. }
  16816. declare module BABYLON {
  16817. /**
  16818. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16819. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16820. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  16821. */
  16822. export abstract class Light extends Node {
  16823. /**
  16824. * Falloff Default: light is falling off following the material specification:
  16825. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16826. */
  16827. static readonly FALLOFF_DEFAULT: number;
  16828. /**
  16829. * Falloff Physical: light is falling off following the inverse squared distance law.
  16830. */
  16831. static readonly FALLOFF_PHYSICAL: number;
  16832. /**
  16833. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16834. * to enhance interoperability with other engines.
  16835. */
  16836. static readonly FALLOFF_GLTF: number;
  16837. /**
  16838. * Falloff Standard: light is falling off like in the standard material
  16839. * to enhance interoperability with other materials.
  16840. */
  16841. static readonly FALLOFF_STANDARD: number;
  16842. /**
  16843. * If every light affecting the material is in this lightmapMode,
  16844. * material.lightmapTexture adds or multiplies
  16845. * (depends on material.useLightmapAsShadowmap)
  16846. * after every other light calculations.
  16847. */
  16848. static readonly LIGHTMAP_DEFAULT: number;
  16849. /**
  16850. * material.lightmapTexture as only diffuse lighting from this light
  16851. * adds only specular lighting from this light
  16852. * adds dynamic shadows
  16853. */
  16854. static readonly LIGHTMAP_SPECULAR: number;
  16855. /**
  16856. * material.lightmapTexture as only lighting
  16857. * no light calculation from this light
  16858. * only adds dynamic shadows from this light
  16859. */
  16860. static readonly LIGHTMAP_SHADOWSONLY: number;
  16861. /**
  16862. * Each light type uses the default quantity according to its type:
  16863. * point/spot lights use luminous intensity
  16864. * directional lights use illuminance
  16865. */
  16866. static readonly INTENSITYMODE_AUTOMATIC: number;
  16867. /**
  16868. * lumen (lm)
  16869. */
  16870. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16871. /**
  16872. * candela (lm/sr)
  16873. */
  16874. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16875. /**
  16876. * lux (lm/m^2)
  16877. */
  16878. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16879. /**
  16880. * nit (cd/m^2)
  16881. */
  16882. static readonly INTENSITYMODE_LUMINANCE: number;
  16883. /**
  16884. * Light type const id of the point light.
  16885. */
  16886. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16887. /**
  16888. * Light type const id of the directional light.
  16889. */
  16890. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16891. /**
  16892. * Light type const id of the spot light.
  16893. */
  16894. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16895. /**
  16896. * Light type const id of the hemispheric light.
  16897. */
  16898. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16899. /**
  16900. * Diffuse gives the basic color to an object.
  16901. */
  16902. diffuse: Color3;
  16903. /**
  16904. * Specular produces a highlight color on an object.
  16905. * Note: This is note affecting PBR materials.
  16906. */
  16907. specular: Color3;
  16908. /**
  16909. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16910. * falling off base on range or angle.
  16911. * This can be set to any values in Light.FALLOFF_x.
  16912. *
  16913. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16914. * other types of materials.
  16915. */
  16916. falloffType: number;
  16917. /**
  16918. * Strength of the light.
  16919. * Note: By default it is define in the framework own unit.
  16920. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16921. */
  16922. intensity: number;
  16923. private _range;
  16924. protected _inverseSquaredRange: number;
  16925. /**
  16926. * Defines how far from the source the light is impacting in scene units.
  16927. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16928. */
  16929. get range(): number;
  16930. /**
  16931. * Defines how far from the source the light is impacting in scene units.
  16932. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16933. */
  16934. set range(value: number);
  16935. /**
  16936. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16937. * of light.
  16938. */
  16939. private _photometricScale;
  16940. private _intensityMode;
  16941. /**
  16942. * Gets the photometric scale used to interpret the intensity.
  16943. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16944. */
  16945. get intensityMode(): number;
  16946. /**
  16947. * Sets the photometric scale used to interpret the intensity.
  16948. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16949. */
  16950. set intensityMode(value: number);
  16951. private _radius;
  16952. /**
  16953. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16954. */
  16955. get radius(): number;
  16956. /**
  16957. * sets the light radius used by PBR Materials to simulate soft area lights.
  16958. */
  16959. set radius(value: number);
  16960. private _renderPriority;
  16961. /**
  16962. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16963. * exceeding the number allowed of the materials.
  16964. */
  16965. renderPriority: number;
  16966. private _shadowEnabled;
  16967. /**
  16968. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16969. * the current shadow generator.
  16970. */
  16971. get shadowEnabled(): boolean;
  16972. /**
  16973. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16974. * the current shadow generator.
  16975. */
  16976. set shadowEnabled(value: boolean);
  16977. private _includedOnlyMeshes;
  16978. /**
  16979. * Gets the only meshes impacted by this light.
  16980. */
  16981. get includedOnlyMeshes(): AbstractMesh[];
  16982. /**
  16983. * Sets the only meshes impacted by this light.
  16984. */
  16985. set includedOnlyMeshes(value: AbstractMesh[]);
  16986. private _excludedMeshes;
  16987. /**
  16988. * Gets the meshes not impacted by this light.
  16989. */
  16990. get excludedMeshes(): AbstractMesh[];
  16991. /**
  16992. * Sets the meshes not impacted by this light.
  16993. */
  16994. set excludedMeshes(value: AbstractMesh[]);
  16995. private _excludeWithLayerMask;
  16996. /**
  16997. * Gets the layer id use to find what meshes are not impacted by the light.
  16998. * Inactive if 0
  16999. */
  17000. get excludeWithLayerMask(): number;
  17001. /**
  17002. * Sets the layer id use to find what meshes are not impacted by the light.
  17003. * Inactive if 0
  17004. */
  17005. set excludeWithLayerMask(value: number);
  17006. private _includeOnlyWithLayerMask;
  17007. /**
  17008. * Gets the layer id use to find what meshes are impacted by the light.
  17009. * Inactive if 0
  17010. */
  17011. get includeOnlyWithLayerMask(): number;
  17012. /**
  17013. * Sets the layer id use to find what meshes are impacted by the light.
  17014. * Inactive if 0
  17015. */
  17016. set includeOnlyWithLayerMask(value: number);
  17017. private _lightmapMode;
  17018. /**
  17019. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17020. */
  17021. get lightmapMode(): number;
  17022. /**
  17023. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17024. */
  17025. set lightmapMode(value: number);
  17026. /**
  17027. * Shadow generator associted to the light.
  17028. * @hidden Internal use only.
  17029. */
  17030. _shadowGenerator: Nullable<IShadowGenerator>;
  17031. /**
  17032. * @hidden Internal use only.
  17033. */
  17034. _excludedMeshesIds: string[];
  17035. /**
  17036. * @hidden Internal use only.
  17037. */
  17038. _includedOnlyMeshesIds: string[];
  17039. /**
  17040. * The current light unifom buffer.
  17041. * @hidden Internal use only.
  17042. */
  17043. _uniformBuffer: UniformBuffer;
  17044. /** @hidden */
  17045. _renderId: number;
  17046. /**
  17047. * Creates a Light object in the scene.
  17048. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17049. * @param name The firendly name of the light
  17050. * @param scene The scene the light belongs too
  17051. */
  17052. constructor(name: string, scene: Scene);
  17053. protected abstract _buildUniformLayout(): void;
  17054. /**
  17055. * Sets the passed Effect "effect" with the Light information.
  17056. * @param effect The effect to update
  17057. * @param lightIndex The index of the light in the effect to update
  17058. * @returns The light
  17059. */
  17060. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17061. /**
  17062. * Sets the passed Effect "effect" with the Light textures.
  17063. * @param effect The effect to update
  17064. * @param lightIndex The index of the light in the effect to update
  17065. * @returns The light
  17066. */
  17067. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17068. /**
  17069. * Binds the lights information from the scene to the effect for the given mesh.
  17070. * @param lightIndex Light index
  17071. * @param scene The scene where the light belongs to
  17072. * @param effect The effect we are binding the data to
  17073. * @param useSpecular Defines if specular is supported
  17074. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17075. */
  17076. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17077. /**
  17078. * Sets the passed Effect "effect" with the Light information.
  17079. * @param effect The effect to update
  17080. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17081. * @returns The light
  17082. */
  17083. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17084. /**
  17085. * Returns the string "Light".
  17086. * @returns the class name
  17087. */
  17088. getClassName(): string;
  17089. /** @hidden */
  17090. readonly _isLight: boolean;
  17091. /**
  17092. * Converts the light information to a readable string for debug purpose.
  17093. * @param fullDetails Supports for multiple levels of logging within scene loading
  17094. * @returns the human readable light info
  17095. */
  17096. toString(fullDetails?: boolean): string;
  17097. /** @hidden */
  17098. protected _syncParentEnabledState(): void;
  17099. /**
  17100. * Set the enabled state of this node.
  17101. * @param value - the new enabled state
  17102. */
  17103. setEnabled(value: boolean): void;
  17104. /**
  17105. * Returns the Light associated shadow generator if any.
  17106. * @return the associated shadow generator.
  17107. */
  17108. getShadowGenerator(): Nullable<IShadowGenerator>;
  17109. /**
  17110. * Returns a Vector3, the absolute light position in the World.
  17111. * @returns the world space position of the light
  17112. */
  17113. getAbsolutePosition(): Vector3;
  17114. /**
  17115. * Specifies if the light will affect the passed mesh.
  17116. * @param mesh The mesh to test against the light
  17117. * @return true the mesh is affected otherwise, false.
  17118. */
  17119. canAffectMesh(mesh: AbstractMesh): boolean;
  17120. /**
  17121. * Sort function to order lights for rendering.
  17122. * @param a First Light object to compare to second.
  17123. * @param b Second Light object to compare first.
  17124. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17125. */
  17126. static CompareLightsPriority(a: Light, b: Light): number;
  17127. /**
  17128. * Releases resources associated with this node.
  17129. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17130. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17131. */
  17132. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17133. /**
  17134. * Returns the light type ID (integer).
  17135. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17136. */
  17137. getTypeID(): number;
  17138. /**
  17139. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17140. * @returns the scaled intensity in intensity mode unit
  17141. */
  17142. getScaledIntensity(): number;
  17143. /**
  17144. * Returns a new Light object, named "name", from the current one.
  17145. * @param name The name of the cloned light
  17146. * @returns the new created light
  17147. */
  17148. clone(name: string): Nullable<Light>;
  17149. /**
  17150. * Serializes the current light into a Serialization object.
  17151. * @returns the serialized object.
  17152. */
  17153. serialize(): any;
  17154. /**
  17155. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17156. * This new light is named "name" and added to the passed scene.
  17157. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17158. * @param name The friendly name of the light
  17159. * @param scene The scene the new light will belong to
  17160. * @returns the constructor function
  17161. */
  17162. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17163. /**
  17164. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17165. * @param parsedLight The JSON representation of the light
  17166. * @param scene The scene to create the parsed light in
  17167. * @returns the created light after parsing
  17168. */
  17169. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17170. private _hookArrayForExcluded;
  17171. private _hookArrayForIncludedOnly;
  17172. private _resyncMeshes;
  17173. /**
  17174. * Forces the meshes to update their light related information in their rendering used effects
  17175. * @hidden Internal Use Only
  17176. */
  17177. _markMeshesAsLightDirty(): void;
  17178. /**
  17179. * Recomputes the cached photometric scale if needed.
  17180. */
  17181. private _computePhotometricScale;
  17182. /**
  17183. * Returns the Photometric Scale according to the light type and intensity mode.
  17184. */
  17185. private _getPhotometricScale;
  17186. /**
  17187. * Reorder the light in the scene according to their defined priority.
  17188. * @hidden Internal Use Only
  17189. */
  17190. _reorderLightsInScene(): void;
  17191. /**
  17192. * Prepares the list of defines specific to the light type.
  17193. * @param defines the list of defines
  17194. * @param lightIndex defines the index of the light for the effect
  17195. */
  17196. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17197. }
  17198. }
  17199. declare module BABYLON {
  17200. /**
  17201. * Interface used to define Action
  17202. */
  17203. export interface IAction {
  17204. /**
  17205. * Trigger for the action
  17206. */
  17207. trigger: number;
  17208. /** Options of the trigger */
  17209. triggerOptions: any;
  17210. /**
  17211. * Gets the trigger parameters
  17212. * @returns the trigger parameters
  17213. */
  17214. getTriggerParameter(): any;
  17215. /**
  17216. * Internal only - executes current action event
  17217. * @hidden
  17218. */
  17219. _executeCurrent(evt?: ActionEvent): void;
  17220. /**
  17221. * Serialize placeholder for child classes
  17222. * @param parent of child
  17223. * @returns the serialized object
  17224. */
  17225. serialize(parent: any): any;
  17226. /**
  17227. * Internal only
  17228. * @hidden
  17229. */
  17230. _prepare(): void;
  17231. /**
  17232. * Internal only - manager for action
  17233. * @hidden
  17234. */
  17235. _actionManager: AbstractActionManager;
  17236. /**
  17237. * Adds action to chain of actions, may be a DoNothingAction
  17238. * @param action defines the next action to execute
  17239. * @returns The action passed in
  17240. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17241. */
  17242. then(action: IAction): IAction;
  17243. }
  17244. /**
  17245. * The action to be carried out following a trigger
  17246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17247. */
  17248. export class Action implements IAction {
  17249. /** the trigger, with or without parameters, for the action */
  17250. triggerOptions: any;
  17251. /**
  17252. * Trigger for the action
  17253. */
  17254. trigger: number;
  17255. /**
  17256. * Internal only - manager for action
  17257. * @hidden
  17258. */
  17259. _actionManager: ActionManager;
  17260. private _nextActiveAction;
  17261. private _child;
  17262. private _condition?;
  17263. private _triggerParameter;
  17264. /**
  17265. * An event triggered prior to action being executed.
  17266. */
  17267. onBeforeExecuteObservable: Observable<Action>;
  17268. /**
  17269. * Creates a new Action
  17270. * @param triggerOptions the trigger, with or without parameters, for the action
  17271. * @param condition an optional determinant of action
  17272. */
  17273. constructor(
  17274. /** the trigger, with or without parameters, for the action */
  17275. triggerOptions: any, condition?: Condition);
  17276. /**
  17277. * Internal only
  17278. * @hidden
  17279. */
  17280. _prepare(): void;
  17281. /**
  17282. * Gets the trigger parameters
  17283. * @returns the trigger parameters
  17284. */
  17285. getTriggerParameter(): any;
  17286. /**
  17287. * Internal only - executes current action event
  17288. * @hidden
  17289. */
  17290. _executeCurrent(evt?: ActionEvent): void;
  17291. /**
  17292. * Execute placeholder for child classes
  17293. * @param evt optional action event
  17294. */
  17295. execute(evt?: ActionEvent): void;
  17296. /**
  17297. * Skips to next active action
  17298. */
  17299. skipToNextActiveAction(): void;
  17300. /**
  17301. * Adds action to chain of actions, may be a DoNothingAction
  17302. * @param action defines the next action to execute
  17303. * @returns The action passed in
  17304. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17305. */
  17306. then(action: Action): Action;
  17307. /**
  17308. * Internal only
  17309. * @hidden
  17310. */
  17311. _getProperty(propertyPath: string): string;
  17312. /**
  17313. * Internal only
  17314. * @hidden
  17315. */
  17316. _getEffectiveTarget(target: any, propertyPath: string): any;
  17317. /**
  17318. * Serialize placeholder for child classes
  17319. * @param parent of child
  17320. * @returns the serialized object
  17321. */
  17322. serialize(parent: any): any;
  17323. /**
  17324. * Internal only called by serialize
  17325. * @hidden
  17326. */
  17327. protected _serialize(serializedAction: any, parent?: any): any;
  17328. /**
  17329. * Internal only
  17330. * @hidden
  17331. */
  17332. static _SerializeValueAsString: (value: any) => string;
  17333. /**
  17334. * Internal only
  17335. * @hidden
  17336. */
  17337. static _GetTargetProperty: (target: Node | Scene) => {
  17338. name: string;
  17339. targetType: string;
  17340. value: string;
  17341. };
  17342. }
  17343. }
  17344. declare module BABYLON {
  17345. /**
  17346. * A Condition applied to an Action
  17347. */
  17348. export class Condition {
  17349. /**
  17350. * Internal only - manager for action
  17351. * @hidden
  17352. */
  17353. _actionManager: ActionManager;
  17354. /**
  17355. * Internal only
  17356. * @hidden
  17357. */
  17358. _evaluationId: number;
  17359. /**
  17360. * Internal only
  17361. * @hidden
  17362. */
  17363. _currentResult: boolean;
  17364. /**
  17365. * Creates a new Condition
  17366. * @param actionManager the manager of the action the condition is applied to
  17367. */
  17368. constructor(actionManager: ActionManager);
  17369. /**
  17370. * Check if the current condition is valid
  17371. * @returns a boolean
  17372. */
  17373. isValid(): boolean;
  17374. /**
  17375. * Internal only
  17376. * @hidden
  17377. */
  17378. _getProperty(propertyPath: string): string;
  17379. /**
  17380. * Internal only
  17381. * @hidden
  17382. */
  17383. _getEffectiveTarget(target: any, propertyPath: string): any;
  17384. /**
  17385. * Serialize placeholder for child classes
  17386. * @returns the serialized object
  17387. */
  17388. serialize(): any;
  17389. /**
  17390. * Internal only
  17391. * @hidden
  17392. */
  17393. protected _serialize(serializedCondition: any): any;
  17394. }
  17395. /**
  17396. * Defines specific conditional operators as extensions of Condition
  17397. */
  17398. export class ValueCondition extends Condition {
  17399. /** path to specify the property of the target the conditional operator uses */
  17400. propertyPath: string;
  17401. /** the value compared by the conditional operator against the current value of the property */
  17402. value: any;
  17403. /** the conditional operator, default ValueCondition.IsEqual */
  17404. operator: number;
  17405. /**
  17406. * Internal only
  17407. * @hidden
  17408. */
  17409. private static _IsEqual;
  17410. /**
  17411. * Internal only
  17412. * @hidden
  17413. */
  17414. private static _IsDifferent;
  17415. /**
  17416. * Internal only
  17417. * @hidden
  17418. */
  17419. private static _IsGreater;
  17420. /**
  17421. * Internal only
  17422. * @hidden
  17423. */
  17424. private static _IsLesser;
  17425. /**
  17426. * returns the number for IsEqual
  17427. */
  17428. static get IsEqual(): number;
  17429. /**
  17430. * Returns the number for IsDifferent
  17431. */
  17432. static get IsDifferent(): number;
  17433. /**
  17434. * Returns the number for IsGreater
  17435. */
  17436. static get IsGreater(): number;
  17437. /**
  17438. * Returns the number for IsLesser
  17439. */
  17440. static get IsLesser(): number;
  17441. /**
  17442. * Internal only The action manager for the condition
  17443. * @hidden
  17444. */
  17445. _actionManager: ActionManager;
  17446. /**
  17447. * Internal only
  17448. * @hidden
  17449. */
  17450. private _target;
  17451. /**
  17452. * Internal only
  17453. * @hidden
  17454. */
  17455. private _effectiveTarget;
  17456. /**
  17457. * Internal only
  17458. * @hidden
  17459. */
  17460. private _property;
  17461. /**
  17462. * Creates a new ValueCondition
  17463. * @param actionManager manager for the action the condition applies to
  17464. * @param target for the action
  17465. * @param propertyPath path to specify the property of the target the conditional operator uses
  17466. * @param value the value compared by the conditional operator against the current value of the property
  17467. * @param operator the conditional operator, default ValueCondition.IsEqual
  17468. */
  17469. constructor(actionManager: ActionManager, target: any,
  17470. /** path to specify the property of the target the conditional operator uses */
  17471. propertyPath: string,
  17472. /** the value compared by the conditional operator against the current value of the property */
  17473. value: any,
  17474. /** the conditional operator, default ValueCondition.IsEqual */
  17475. operator?: number);
  17476. /**
  17477. * Compares the given value with the property value for the specified conditional operator
  17478. * @returns the result of the comparison
  17479. */
  17480. isValid(): boolean;
  17481. /**
  17482. * Serialize the ValueCondition into a JSON compatible object
  17483. * @returns serialization object
  17484. */
  17485. serialize(): any;
  17486. /**
  17487. * Gets the name of the conditional operator for the ValueCondition
  17488. * @param operator the conditional operator
  17489. * @returns the name
  17490. */
  17491. static GetOperatorName(operator: number): string;
  17492. }
  17493. /**
  17494. * Defines a predicate condition as an extension of Condition
  17495. */
  17496. export class PredicateCondition extends Condition {
  17497. /** defines the predicate function used to validate the condition */
  17498. predicate: () => boolean;
  17499. /**
  17500. * Internal only - manager for action
  17501. * @hidden
  17502. */
  17503. _actionManager: ActionManager;
  17504. /**
  17505. * Creates a new PredicateCondition
  17506. * @param actionManager manager for the action the condition applies to
  17507. * @param predicate defines the predicate function used to validate the condition
  17508. */
  17509. constructor(actionManager: ActionManager,
  17510. /** defines the predicate function used to validate the condition */
  17511. predicate: () => boolean);
  17512. /**
  17513. * @returns the validity of the predicate condition
  17514. */
  17515. isValid(): boolean;
  17516. }
  17517. /**
  17518. * Defines a state condition as an extension of Condition
  17519. */
  17520. export class StateCondition extends Condition {
  17521. /** Value to compare with target state */
  17522. value: string;
  17523. /**
  17524. * Internal only - manager for action
  17525. * @hidden
  17526. */
  17527. _actionManager: ActionManager;
  17528. /**
  17529. * Internal only
  17530. * @hidden
  17531. */
  17532. private _target;
  17533. /**
  17534. * Creates a new StateCondition
  17535. * @param actionManager manager for the action the condition applies to
  17536. * @param target of the condition
  17537. * @param value to compare with target state
  17538. */
  17539. constructor(actionManager: ActionManager, target: any,
  17540. /** Value to compare with target state */
  17541. value: string);
  17542. /**
  17543. * Gets a boolean indicating if the current condition is met
  17544. * @returns the validity of the state
  17545. */
  17546. isValid(): boolean;
  17547. /**
  17548. * Serialize the StateCondition into a JSON compatible object
  17549. * @returns serialization object
  17550. */
  17551. serialize(): any;
  17552. }
  17553. }
  17554. declare module BABYLON {
  17555. /**
  17556. * This defines an action responsible to toggle a boolean once triggered.
  17557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17558. */
  17559. export class SwitchBooleanAction extends Action {
  17560. /**
  17561. * The path to the boolean property in the target object
  17562. */
  17563. propertyPath: string;
  17564. private _target;
  17565. private _effectiveTarget;
  17566. private _property;
  17567. /**
  17568. * Instantiate the action
  17569. * @param triggerOptions defines the trigger options
  17570. * @param target defines the object containing the boolean
  17571. * @param propertyPath defines the path to the boolean property in the target object
  17572. * @param condition defines the trigger related conditions
  17573. */
  17574. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17575. /** @hidden */
  17576. _prepare(): void;
  17577. /**
  17578. * Execute the action toggle the boolean value.
  17579. */
  17580. execute(): void;
  17581. /**
  17582. * Serializes the actions and its related information.
  17583. * @param parent defines the object to serialize in
  17584. * @returns the serialized object
  17585. */
  17586. serialize(parent: any): any;
  17587. }
  17588. /**
  17589. * This defines an action responsible to set a the state field of the target
  17590. * to a desired value once triggered.
  17591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17592. */
  17593. export class SetStateAction extends Action {
  17594. /**
  17595. * The value to store in the state field.
  17596. */
  17597. value: string;
  17598. private _target;
  17599. /**
  17600. * Instantiate the action
  17601. * @param triggerOptions defines the trigger options
  17602. * @param target defines the object containing the state property
  17603. * @param value defines the value to store in the state field
  17604. * @param condition defines the trigger related conditions
  17605. */
  17606. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17607. /**
  17608. * Execute the action and store the value on the target state property.
  17609. */
  17610. execute(): void;
  17611. /**
  17612. * Serializes the actions and its related information.
  17613. * @param parent defines the object to serialize in
  17614. * @returns the serialized object
  17615. */
  17616. serialize(parent: any): any;
  17617. }
  17618. /**
  17619. * This defines an action responsible to set a property of the target
  17620. * to a desired value once triggered.
  17621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17622. */
  17623. export class SetValueAction extends Action {
  17624. /**
  17625. * The path of the property to set in the target.
  17626. */
  17627. propertyPath: string;
  17628. /**
  17629. * The value to set in the property
  17630. */
  17631. value: any;
  17632. private _target;
  17633. private _effectiveTarget;
  17634. private _property;
  17635. /**
  17636. * Instantiate the action
  17637. * @param triggerOptions defines the trigger options
  17638. * @param target defines the object containing the property
  17639. * @param propertyPath defines the path of the property to set in the target
  17640. * @param value defines the value to set in the property
  17641. * @param condition defines the trigger related conditions
  17642. */
  17643. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17644. /** @hidden */
  17645. _prepare(): void;
  17646. /**
  17647. * Execute the action and set the targetted property to the desired value.
  17648. */
  17649. execute(): void;
  17650. /**
  17651. * Serializes the actions and its related information.
  17652. * @param parent defines the object to serialize in
  17653. * @returns the serialized object
  17654. */
  17655. serialize(parent: any): any;
  17656. }
  17657. /**
  17658. * This defines an action responsible to increment the target value
  17659. * to a desired value once triggered.
  17660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17661. */
  17662. export class IncrementValueAction extends Action {
  17663. /**
  17664. * The path of the property to increment in the target.
  17665. */
  17666. propertyPath: string;
  17667. /**
  17668. * The value we should increment the property by.
  17669. */
  17670. value: any;
  17671. private _target;
  17672. private _effectiveTarget;
  17673. private _property;
  17674. /**
  17675. * Instantiate the action
  17676. * @param triggerOptions defines the trigger options
  17677. * @param target defines the object containing the property
  17678. * @param propertyPath defines the path of the property to increment in the target
  17679. * @param value defines the value value we should increment the property by
  17680. * @param condition defines the trigger related conditions
  17681. */
  17682. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17683. /** @hidden */
  17684. _prepare(): void;
  17685. /**
  17686. * Execute the action and increment the target of the value amount.
  17687. */
  17688. execute(): void;
  17689. /**
  17690. * Serializes the actions and its related information.
  17691. * @param parent defines the object to serialize in
  17692. * @returns the serialized object
  17693. */
  17694. serialize(parent: any): any;
  17695. }
  17696. /**
  17697. * This defines an action responsible to start an animation once triggered.
  17698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17699. */
  17700. export class PlayAnimationAction extends Action {
  17701. /**
  17702. * Where the animation should start (animation frame)
  17703. */
  17704. from: number;
  17705. /**
  17706. * Where the animation should stop (animation frame)
  17707. */
  17708. to: number;
  17709. /**
  17710. * Define if the animation should loop or stop after the first play.
  17711. */
  17712. loop?: boolean;
  17713. private _target;
  17714. /**
  17715. * Instantiate the action
  17716. * @param triggerOptions defines the trigger options
  17717. * @param target defines the target animation or animation name
  17718. * @param from defines from where the animation should start (animation frame)
  17719. * @param end defines where the animation should stop (animation frame)
  17720. * @param loop defines if the animation should loop or stop after the first play
  17721. * @param condition defines the trigger related conditions
  17722. */
  17723. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17724. /** @hidden */
  17725. _prepare(): void;
  17726. /**
  17727. * Execute the action and play the animation.
  17728. */
  17729. execute(): void;
  17730. /**
  17731. * Serializes the actions and its related information.
  17732. * @param parent defines the object to serialize in
  17733. * @returns the serialized object
  17734. */
  17735. serialize(parent: any): any;
  17736. }
  17737. /**
  17738. * This defines an action responsible to stop an animation once triggered.
  17739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17740. */
  17741. export class StopAnimationAction extends Action {
  17742. private _target;
  17743. /**
  17744. * Instantiate the action
  17745. * @param triggerOptions defines the trigger options
  17746. * @param target defines the target animation or animation name
  17747. * @param condition defines the trigger related conditions
  17748. */
  17749. constructor(triggerOptions: any, target: any, condition?: Condition);
  17750. /** @hidden */
  17751. _prepare(): void;
  17752. /**
  17753. * Execute the action and stop the animation.
  17754. */
  17755. execute(): void;
  17756. /**
  17757. * Serializes the actions and its related information.
  17758. * @param parent defines the object to serialize in
  17759. * @returns the serialized object
  17760. */
  17761. serialize(parent: any): any;
  17762. }
  17763. /**
  17764. * This defines an action responsible that does nothing once triggered.
  17765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17766. */
  17767. export class DoNothingAction extends Action {
  17768. /**
  17769. * Instantiate the action
  17770. * @param triggerOptions defines the trigger options
  17771. * @param condition defines the trigger related conditions
  17772. */
  17773. constructor(triggerOptions?: any, condition?: Condition);
  17774. /**
  17775. * Execute the action and do nothing.
  17776. */
  17777. execute(): void;
  17778. /**
  17779. * Serializes the actions and its related information.
  17780. * @param parent defines the object to serialize in
  17781. * @returns the serialized object
  17782. */
  17783. serialize(parent: any): any;
  17784. }
  17785. /**
  17786. * This defines an action responsible to trigger several actions once triggered.
  17787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17788. */
  17789. export class CombineAction extends Action {
  17790. /**
  17791. * The list of aggregated animations to run.
  17792. */
  17793. children: Action[];
  17794. /**
  17795. * Instantiate the action
  17796. * @param triggerOptions defines the trigger options
  17797. * @param children defines the list of aggregated animations to run
  17798. * @param condition defines the trigger related conditions
  17799. */
  17800. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17801. /** @hidden */
  17802. _prepare(): void;
  17803. /**
  17804. * Execute the action and executes all the aggregated actions.
  17805. */
  17806. execute(evt: ActionEvent): void;
  17807. /**
  17808. * Serializes the actions and its related information.
  17809. * @param parent defines the object to serialize in
  17810. * @returns the serialized object
  17811. */
  17812. serialize(parent: any): any;
  17813. }
  17814. /**
  17815. * This defines an action responsible to run code (external event) once triggered.
  17816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17817. */
  17818. export class ExecuteCodeAction extends Action {
  17819. /**
  17820. * The callback function to run.
  17821. */
  17822. func: (evt: ActionEvent) => void;
  17823. /**
  17824. * Instantiate the action
  17825. * @param triggerOptions defines the trigger options
  17826. * @param func defines the callback function to run
  17827. * @param condition defines the trigger related conditions
  17828. */
  17829. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17830. /**
  17831. * Execute the action and run the attached code.
  17832. */
  17833. execute(evt: ActionEvent): void;
  17834. }
  17835. /**
  17836. * This defines an action responsible to set the parent property of the target once triggered.
  17837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17838. */
  17839. export class SetParentAction extends Action {
  17840. private _parent;
  17841. private _target;
  17842. /**
  17843. * Instantiate the action
  17844. * @param triggerOptions defines the trigger options
  17845. * @param target defines the target containing the parent property
  17846. * @param parent defines from where the animation should start (animation frame)
  17847. * @param condition defines the trigger related conditions
  17848. */
  17849. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17850. /** @hidden */
  17851. _prepare(): void;
  17852. /**
  17853. * Execute the action and set the parent property.
  17854. */
  17855. execute(): void;
  17856. /**
  17857. * Serializes the actions and its related information.
  17858. * @param parent defines the object to serialize in
  17859. * @returns the serialized object
  17860. */
  17861. serialize(parent: any): any;
  17862. }
  17863. }
  17864. declare module BABYLON {
  17865. /**
  17866. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17867. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17869. */
  17870. export class ActionManager extends AbstractActionManager {
  17871. /**
  17872. * Nothing
  17873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17874. */
  17875. static readonly NothingTrigger: number;
  17876. /**
  17877. * On pick
  17878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17879. */
  17880. static readonly OnPickTrigger: number;
  17881. /**
  17882. * On left pick
  17883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17884. */
  17885. static readonly OnLeftPickTrigger: number;
  17886. /**
  17887. * On right pick
  17888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17889. */
  17890. static readonly OnRightPickTrigger: number;
  17891. /**
  17892. * On center pick
  17893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17894. */
  17895. static readonly OnCenterPickTrigger: number;
  17896. /**
  17897. * On pick down
  17898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17899. */
  17900. static readonly OnPickDownTrigger: number;
  17901. /**
  17902. * On double pick
  17903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17904. */
  17905. static readonly OnDoublePickTrigger: number;
  17906. /**
  17907. * On pick up
  17908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17909. */
  17910. static readonly OnPickUpTrigger: number;
  17911. /**
  17912. * On pick out.
  17913. * This trigger will only be raised if you also declared a OnPickDown
  17914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17915. */
  17916. static readonly OnPickOutTrigger: number;
  17917. /**
  17918. * On long press
  17919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17920. */
  17921. static readonly OnLongPressTrigger: number;
  17922. /**
  17923. * On pointer over
  17924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17925. */
  17926. static readonly OnPointerOverTrigger: number;
  17927. /**
  17928. * On pointer out
  17929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17930. */
  17931. static readonly OnPointerOutTrigger: number;
  17932. /**
  17933. * On every frame
  17934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17935. */
  17936. static readonly OnEveryFrameTrigger: number;
  17937. /**
  17938. * On intersection enter
  17939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17940. */
  17941. static readonly OnIntersectionEnterTrigger: number;
  17942. /**
  17943. * On intersection exit
  17944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17945. */
  17946. static readonly OnIntersectionExitTrigger: number;
  17947. /**
  17948. * On key down
  17949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17950. */
  17951. static readonly OnKeyDownTrigger: number;
  17952. /**
  17953. * On key up
  17954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17955. */
  17956. static readonly OnKeyUpTrigger: number;
  17957. private _scene;
  17958. /**
  17959. * Creates a new action manager
  17960. * @param scene defines the hosting scene
  17961. */
  17962. constructor(scene: Scene);
  17963. /**
  17964. * Releases all associated resources
  17965. */
  17966. dispose(): void;
  17967. /**
  17968. * Gets hosting scene
  17969. * @returns the hosting scene
  17970. */
  17971. getScene(): Scene;
  17972. /**
  17973. * Does this action manager handles actions of any of the given triggers
  17974. * @param triggers defines the triggers to be tested
  17975. * @return a boolean indicating whether one (or more) of the triggers is handled
  17976. */
  17977. hasSpecificTriggers(triggers: number[]): boolean;
  17978. /**
  17979. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17980. * speed.
  17981. * @param triggerA defines the trigger to be tested
  17982. * @param triggerB defines the trigger to be tested
  17983. * @return a boolean indicating whether one (or more) of the triggers is handled
  17984. */
  17985. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17986. /**
  17987. * Does this action manager handles actions of a given trigger
  17988. * @param trigger defines the trigger to be tested
  17989. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17990. * @return whether the trigger is handled
  17991. */
  17992. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17993. /**
  17994. * Does this action manager has pointer triggers
  17995. */
  17996. get hasPointerTriggers(): boolean;
  17997. /**
  17998. * Does this action manager has pick triggers
  17999. */
  18000. get hasPickTriggers(): boolean;
  18001. /**
  18002. * Registers an action to this action manager
  18003. * @param action defines the action to be registered
  18004. * @return the action amended (prepared) after registration
  18005. */
  18006. registerAction(action: IAction): Nullable<IAction>;
  18007. /**
  18008. * Unregisters an action to this action manager
  18009. * @param action defines the action to be unregistered
  18010. * @return a boolean indicating whether the action has been unregistered
  18011. */
  18012. unregisterAction(action: IAction): Boolean;
  18013. /**
  18014. * Process a specific trigger
  18015. * @param trigger defines the trigger to process
  18016. * @param evt defines the event details to be processed
  18017. */
  18018. processTrigger(trigger: number, evt?: IActionEvent): void;
  18019. /** @hidden */
  18020. _getEffectiveTarget(target: any, propertyPath: string): any;
  18021. /** @hidden */
  18022. _getProperty(propertyPath: string): string;
  18023. /**
  18024. * Serialize this manager to a JSON object
  18025. * @param name defines the property name to store this manager
  18026. * @returns a JSON representation of this manager
  18027. */
  18028. serialize(name: string): any;
  18029. /**
  18030. * Creates a new ActionManager from a JSON data
  18031. * @param parsedActions defines the JSON data to read from
  18032. * @param object defines the hosting mesh
  18033. * @param scene defines the hosting scene
  18034. */
  18035. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18036. /**
  18037. * Get a trigger name by index
  18038. * @param trigger defines the trigger index
  18039. * @returns a trigger name
  18040. */
  18041. static GetTriggerName(trigger: number): string;
  18042. }
  18043. }
  18044. declare module BABYLON {
  18045. /**
  18046. * Class used to represent a sprite
  18047. * @see http://doc.babylonjs.com/babylon101/sprites
  18048. */
  18049. export class Sprite {
  18050. /** defines the name */
  18051. name: string;
  18052. /** Gets or sets the current world position */
  18053. position: Vector3;
  18054. /** Gets or sets the main color */
  18055. color: Color4;
  18056. /** Gets or sets the width */
  18057. width: number;
  18058. /** Gets or sets the height */
  18059. height: number;
  18060. /** Gets or sets rotation angle */
  18061. angle: number;
  18062. /** Gets or sets the cell index in the sprite sheet */
  18063. cellIndex: number;
  18064. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18065. cellRef: string;
  18066. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18067. invertU: number;
  18068. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18069. invertV: number;
  18070. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18071. disposeWhenFinishedAnimating: boolean;
  18072. /** Gets the list of attached animations */
  18073. animations: Animation[];
  18074. /** Gets or sets a boolean indicating if the sprite can be picked */
  18075. isPickable: boolean;
  18076. /**
  18077. * Gets or sets the associated action manager
  18078. */
  18079. actionManager: Nullable<ActionManager>;
  18080. private _animationStarted;
  18081. private _loopAnimation;
  18082. private _fromIndex;
  18083. private _toIndex;
  18084. private _delay;
  18085. private _direction;
  18086. private _manager;
  18087. private _time;
  18088. private _onAnimationEnd;
  18089. /**
  18090. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18091. */
  18092. isVisible: boolean;
  18093. /**
  18094. * Gets or sets the sprite size
  18095. */
  18096. get size(): number;
  18097. set size(value: number);
  18098. /**
  18099. * Creates a new Sprite
  18100. * @param name defines the name
  18101. * @param manager defines the manager
  18102. */
  18103. constructor(
  18104. /** defines the name */
  18105. name: string, manager: ISpriteManager);
  18106. /**
  18107. * Starts an animation
  18108. * @param from defines the initial key
  18109. * @param to defines the end key
  18110. * @param loop defines if the animation must loop
  18111. * @param delay defines the start delay (in ms)
  18112. * @param onAnimationEnd defines a callback to call when animation ends
  18113. */
  18114. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18115. /** Stops current animation (if any) */
  18116. stopAnimation(): void;
  18117. /** @hidden */
  18118. _animate(deltaTime: number): void;
  18119. /** Release associated resources */
  18120. dispose(): void;
  18121. }
  18122. }
  18123. declare module BABYLON {
  18124. /**
  18125. * Information about the result of picking within a scene
  18126. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18127. */
  18128. export class PickingInfo {
  18129. /** @hidden */
  18130. _pickingUnavailable: boolean;
  18131. /**
  18132. * If the pick collided with an object
  18133. */
  18134. hit: boolean;
  18135. /**
  18136. * Distance away where the pick collided
  18137. */
  18138. distance: number;
  18139. /**
  18140. * The location of pick collision
  18141. */
  18142. pickedPoint: Nullable<Vector3>;
  18143. /**
  18144. * The mesh corresponding the the pick collision
  18145. */
  18146. pickedMesh: Nullable<AbstractMesh>;
  18147. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18148. bu: number;
  18149. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18150. bv: number;
  18151. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18152. faceId: number;
  18153. /** Id of the the submesh that was picked */
  18154. subMeshId: number;
  18155. /** If a sprite was picked, this will be the sprite the pick collided with */
  18156. pickedSprite: Nullable<Sprite>;
  18157. /**
  18158. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18159. */
  18160. originMesh: Nullable<AbstractMesh>;
  18161. /**
  18162. * The ray that was used to perform the picking.
  18163. */
  18164. ray: Nullable<Ray>;
  18165. /**
  18166. * Gets the normal correspodning to the face the pick collided with
  18167. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18168. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18169. * @returns The normal correspodning to the face the pick collided with
  18170. */
  18171. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18172. /**
  18173. * Gets the texture coordinates of where the pick occured
  18174. * @returns the vector containing the coordnates of the texture
  18175. */
  18176. getTextureCoordinates(): Nullable<Vector2>;
  18177. }
  18178. }
  18179. declare module BABYLON {
  18180. /**
  18181. * Gather the list of pointer event types as constants.
  18182. */
  18183. export class PointerEventTypes {
  18184. /**
  18185. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18186. */
  18187. static readonly POINTERDOWN: number;
  18188. /**
  18189. * The pointerup event is fired when a pointer is no longer active.
  18190. */
  18191. static readonly POINTERUP: number;
  18192. /**
  18193. * The pointermove event is fired when a pointer changes coordinates.
  18194. */
  18195. static readonly POINTERMOVE: number;
  18196. /**
  18197. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18198. */
  18199. static readonly POINTERWHEEL: number;
  18200. /**
  18201. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18202. */
  18203. static readonly POINTERPICK: number;
  18204. /**
  18205. * The pointertap event is fired when a the object has been touched and released without drag.
  18206. */
  18207. static readonly POINTERTAP: number;
  18208. /**
  18209. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18210. */
  18211. static readonly POINTERDOUBLETAP: number;
  18212. }
  18213. /**
  18214. * Base class of pointer info types.
  18215. */
  18216. export class PointerInfoBase {
  18217. /**
  18218. * Defines the type of event (PointerEventTypes)
  18219. */
  18220. type: number;
  18221. /**
  18222. * Defines the related dom event
  18223. */
  18224. event: PointerEvent | MouseWheelEvent;
  18225. /**
  18226. * Instantiates the base class of pointers info.
  18227. * @param type Defines the type of event (PointerEventTypes)
  18228. * @param event Defines the related dom event
  18229. */
  18230. constructor(
  18231. /**
  18232. * Defines the type of event (PointerEventTypes)
  18233. */
  18234. type: number,
  18235. /**
  18236. * Defines the related dom event
  18237. */
  18238. event: PointerEvent | MouseWheelEvent);
  18239. }
  18240. /**
  18241. * This class is used to store pointer related info for the onPrePointerObservable event.
  18242. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18243. */
  18244. export class PointerInfoPre extends PointerInfoBase {
  18245. /**
  18246. * Ray from a pointer if availible (eg. 6dof controller)
  18247. */
  18248. ray: Nullable<Ray>;
  18249. /**
  18250. * Defines the local position of the pointer on the canvas.
  18251. */
  18252. localPosition: Vector2;
  18253. /**
  18254. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18255. */
  18256. skipOnPointerObservable: boolean;
  18257. /**
  18258. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18259. * @param type Defines the type of event (PointerEventTypes)
  18260. * @param event Defines the related dom event
  18261. * @param localX Defines the local x coordinates of the pointer when the event occured
  18262. * @param localY Defines the local y coordinates of the pointer when the event occured
  18263. */
  18264. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18265. }
  18266. /**
  18267. * This type contains all the data related to a pointer event in Babylon.js.
  18268. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18269. */
  18270. export class PointerInfo extends PointerInfoBase {
  18271. /**
  18272. * Defines the picking info associated to the info (if any)\
  18273. */
  18274. pickInfo: Nullable<PickingInfo>;
  18275. /**
  18276. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18277. * @param type Defines the type of event (PointerEventTypes)
  18278. * @param event Defines the related dom event
  18279. * @param pickInfo Defines the picking info associated to the info (if any)\
  18280. */
  18281. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18282. /**
  18283. * Defines the picking info associated to the info (if any)\
  18284. */
  18285. pickInfo: Nullable<PickingInfo>);
  18286. }
  18287. /**
  18288. * Data relating to a touch event on the screen.
  18289. */
  18290. export interface PointerTouch {
  18291. /**
  18292. * X coordinate of touch.
  18293. */
  18294. x: number;
  18295. /**
  18296. * Y coordinate of touch.
  18297. */
  18298. y: number;
  18299. /**
  18300. * Id of touch. Unique for each finger.
  18301. */
  18302. pointerId: number;
  18303. /**
  18304. * Event type passed from DOM.
  18305. */
  18306. type: any;
  18307. }
  18308. }
  18309. declare module BABYLON {
  18310. /**
  18311. * Manage the mouse inputs to control the movement of a free camera.
  18312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18313. */
  18314. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18315. /**
  18316. * Define if touch is enabled in the mouse input
  18317. */
  18318. touchEnabled: boolean;
  18319. /**
  18320. * Defines the camera the input is attached to.
  18321. */
  18322. camera: FreeCamera;
  18323. /**
  18324. * Defines the buttons associated with the input to handle camera move.
  18325. */
  18326. buttons: number[];
  18327. /**
  18328. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18329. */
  18330. angularSensibility: number;
  18331. private _pointerInput;
  18332. private _onMouseMove;
  18333. private _observer;
  18334. private previousPosition;
  18335. /**
  18336. * Observable for when a pointer move event occurs containing the move offset
  18337. */
  18338. onPointerMovedObservable: Observable<{
  18339. offsetX: number;
  18340. offsetY: number;
  18341. }>;
  18342. /**
  18343. * @hidden
  18344. * If the camera should be rotated automatically based on pointer movement
  18345. */
  18346. _allowCameraRotation: boolean;
  18347. /**
  18348. * Manage the mouse inputs to control the movement of a free camera.
  18349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18350. * @param touchEnabled Defines if touch is enabled or not
  18351. */
  18352. constructor(
  18353. /**
  18354. * Define if touch is enabled in the mouse input
  18355. */
  18356. touchEnabled?: boolean);
  18357. /**
  18358. * Attach the input controls to a specific dom element to get the input from.
  18359. * @param element Defines the element the controls should be listened from
  18360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18361. */
  18362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18363. /**
  18364. * Called on JS contextmenu event.
  18365. * Override this method to provide functionality.
  18366. */
  18367. protected onContextMenu(evt: PointerEvent): void;
  18368. /**
  18369. * Detach the current controls from the specified dom element.
  18370. * @param element Defines the element to stop listening the inputs from
  18371. */
  18372. detachControl(element: Nullable<HTMLElement>): void;
  18373. /**
  18374. * Gets the class name of the current intput.
  18375. * @returns the class name
  18376. */
  18377. getClassName(): string;
  18378. /**
  18379. * Get the friendly name associated with the input class.
  18380. * @returns the input friendly name
  18381. */
  18382. getSimpleName(): string;
  18383. }
  18384. }
  18385. declare module BABYLON {
  18386. /**
  18387. * Manage the touch inputs to control the movement of a free camera.
  18388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18389. */
  18390. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18391. /**
  18392. * Defines the camera the input is attached to.
  18393. */
  18394. camera: FreeCamera;
  18395. /**
  18396. * Defines the touch sensibility for rotation.
  18397. * The higher the faster.
  18398. */
  18399. touchAngularSensibility: number;
  18400. /**
  18401. * Defines the touch sensibility for move.
  18402. * The higher the faster.
  18403. */
  18404. touchMoveSensibility: number;
  18405. private _offsetX;
  18406. private _offsetY;
  18407. private _pointerPressed;
  18408. private _pointerInput;
  18409. private _observer;
  18410. private _onLostFocus;
  18411. /**
  18412. * Attach the input controls to a specific dom element to get the input from.
  18413. * @param element Defines the element the controls should be listened from
  18414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18415. */
  18416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18417. /**
  18418. * Detach the current controls from the specified dom element.
  18419. * @param element Defines the element to stop listening the inputs from
  18420. */
  18421. detachControl(element: Nullable<HTMLElement>): void;
  18422. /**
  18423. * Update the current camera state depending on the inputs that have been used this frame.
  18424. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18425. */
  18426. checkInputs(): void;
  18427. /**
  18428. * Gets the class name of the current intput.
  18429. * @returns the class name
  18430. */
  18431. getClassName(): string;
  18432. /**
  18433. * Get the friendly name associated with the input class.
  18434. * @returns the input friendly name
  18435. */
  18436. getSimpleName(): string;
  18437. }
  18438. }
  18439. declare module BABYLON {
  18440. /**
  18441. * Default Inputs manager for the FreeCamera.
  18442. * It groups all the default supported inputs for ease of use.
  18443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18444. */
  18445. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18446. /**
  18447. * @hidden
  18448. */
  18449. _mouseInput: Nullable<FreeCameraMouseInput>;
  18450. /**
  18451. * Instantiates a new FreeCameraInputsManager.
  18452. * @param camera Defines the camera the inputs belong to
  18453. */
  18454. constructor(camera: FreeCamera);
  18455. /**
  18456. * Add keyboard input support to the input manager.
  18457. * @returns the current input manager
  18458. */
  18459. addKeyboard(): FreeCameraInputsManager;
  18460. /**
  18461. * Add mouse input support to the input manager.
  18462. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18463. * @returns the current input manager
  18464. */
  18465. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18466. /**
  18467. * Removes the mouse input support from the manager
  18468. * @returns the current input manager
  18469. */
  18470. removeMouse(): FreeCameraInputsManager;
  18471. /**
  18472. * Add touch input support to the input manager.
  18473. * @returns the current input manager
  18474. */
  18475. addTouch(): FreeCameraInputsManager;
  18476. /**
  18477. * Remove all attached input methods from a camera
  18478. */
  18479. clear(): void;
  18480. }
  18481. }
  18482. declare module BABYLON {
  18483. /**
  18484. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18485. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18486. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18487. */
  18488. export class FreeCamera extends TargetCamera {
  18489. /**
  18490. * Define the collision ellipsoid of the camera.
  18491. * This is helpful to simulate a camera body like the player body around the camera
  18492. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18493. */
  18494. ellipsoid: Vector3;
  18495. /**
  18496. * Define an offset for the position of the ellipsoid around the camera.
  18497. * This can be helpful to determine the center of the body near the gravity center of the body
  18498. * instead of its head.
  18499. */
  18500. ellipsoidOffset: Vector3;
  18501. /**
  18502. * Enable or disable collisions of the camera with the rest of the scene objects.
  18503. */
  18504. checkCollisions: boolean;
  18505. /**
  18506. * Enable or disable gravity on the camera.
  18507. */
  18508. applyGravity: boolean;
  18509. /**
  18510. * Define the input manager associated to the camera.
  18511. */
  18512. inputs: FreeCameraInputsManager;
  18513. /**
  18514. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18515. * Higher values reduce sensitivity.
  18516. */
  18517. get angularSensibility(): number;
  18518. /**
  18519. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18520. * Higher values reduce sensitivity.
  18521. */
  18522. set angularSensibility(value: number);
  18523. /**
  18524. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18525. */
  18526. get keysUp(): number[];
  18527. set keysUp(value: number[]);
  18528. /**
  18529. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18530. */
  18531. get keysUpward(): number[];
  18532. set keysUpward(value: number[]);
  18533. /**
  18534. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18535. */
  18536. get keysDown(): number[];
  18537. set keysDown(value: number[]);
  18538. /**
  18539. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18540. */
  18541. get keysDownward(): number[];
  18542. set keysDownward(value: number[]);
  18543. /**
  18544. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18545. */
  18546. get keysLeft(): number[];
  18547. set keysLeft(value: number[]);
  18548. /**
  18549. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18550. */
  18551. get keysRight(): number[];
  18552. set keysRight(value: number[]);
  18553. /**
  18554. * Event raised when the camera collide with a mesh in the scene.
  18555. */
  18556. onCollide: (collidedMesh: AbstractMesh) => void;
  18557. private _collider;
  18558. private _needMoveForGravity;
  18559. private _oldPosition;
  18560. private _diffPosition;
  18561. private _newPosition;
  18562. /** @hidden */
  18563. _localDirection: Vector3;
  18564. /** @hidden */
  18565. _transformedDirection: Vector3;
  18566. /**
  18567. * Instantiates a Free Camera.
  18568. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18569. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18570. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18571. * @param name Define the name of the camera in the scene
  18572. * @param position Define the start position of the camera in the scene
  18573. * @param scene Define the scene the camera belongs to
  18574. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18575. */
  18576. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18577. /**
  18578. * Attached controls to the current camera.
  18579. * @param element Defines the element the controls should be listened from
  18580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18581. */
  18582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18583. /**
  18584. * Detach the current controls from the camera.
  18585. * The camera will stop reacting to inputs.
  18586. * @param element Defines the element to stop listening the inputs from
  18587. */
  18588. detachControl(element: HTMLElement): void;
  18589. private _collisionMask;
  18590. /**
  18591. * Define a collision mask to limit the list of object the camera can collide with
  18592. */
  18593. get collisionMask(): number;
  18594. set collisionMask(mask: number);
  18595. /** @hidden */
  18596. _collideWithWorld(displacement: Vector3): void;
  18597. private _onCollisionPositionChange;
  18598. /** @hidden */
  18599. _checkInputs(): void;
  18600. /** @hidden */
  18601. _decideIfNeedsToMove(): boolean;
  18602. /** @hidden */
  18603. _updatePosition(): void;
  18604. /**
  18605. * Destroy the camera and release the current resources hold by it.
  18606. */
  18607. dispose(): void;
  18608. /**
  18609. * Gets the current object class name.
  18610. * @return the class name
  18611. */
  18612. getClassName(): string;
  18613. }
  18614. }
  18615. declare module BABYLON {
  18616. /**
  18617. * Represents a gamepad control stick position
  18618. */
  18619. export class StickValues {
  18620. /**
  18621. * The x component of the control stick
  18622. */
  18623. x: number;
  18624. /**
  18625. * The y component of the control stick
  18626. */
  18627. y: number;
  18628. /**
  18629. * Initializes the gamepad x and y control stick values
  18630. * @param x The x component of the gamepad control stick value
  18631. * @param y The y component of the gamepad control stick value
  18632. */
  18633. constructor(
  18634. /**
  18635. * The x component of the control stick
  18636. */
  18637. x: number,
  18638. /**
  18639. * The y component of the control stick
  18640. */
  18641. y: number);
  18642. }
  18643. /**
  18644. * An interface which manages callbacks for gamepad button changes
  18645. */
  18646. export interface GamepadButtonChanges {
  18647. /**
  18648. * Called when a gamepad has been changed
  18649. */
  18650. changed: boolean;
  18651. /**
  18652. * Called when a gamepad press event has been triggered
  18653. */
  18654. pressChanged: boolean;
  18655. /**
  18656. * Called when a touch event has been triggered
  18657. */
  18658. touchChanged: boolean;
  18659. /**
  18660. * Called when a value has changed
  18661. */
  18662. valueChanged: boolean;
  18663. }
  18664. /**
  18665. * Represents a gamepad
  18666. */
  18667. export class Gamepad {
  18668. /**
  18669. * The id of the gamepad
  18670. */
  18671. id: string;
  18672. /**
  18673. * The index of the gamepad
  18674. */
  18675. index: number;
  18676. /**
  18677. * The browser gamepad
  18678. */
  18679. browserGamepad: any;
  18680. /**
  18681. * Specifies what type of gamepad this represents
  18682. */
  18683. type: number;
  18684. private _leftStick;
  18685. private _rightStick;
  18686. /** @hidden */
  18687. _isConnected: boolean;
  18688. private _leftStickAxisX;
  18689. private _leftStickAxisY;
  18690. private _rightStickAxisX;
  18691. private _rightStickAxisY;
  18692. /**
  18693. * Triggered when the left control stick has been changed
  18694. */
  18695. private _onleftstickchanged;
  18696. /**
  18697. * Triggered when the right control stick has been changed
  18698. */
  18699. private _onrightstickchanged;
  18700. /**
  18701. * Represents a gamepad controller
  18702. */
  18703. static GAMEPAD: number;
  18704. /**
  18705. * Represents a generic controller
  18706. */
  18707. static GENERIC: number;
  18708. /**
  18709. * Represents an XBox controller
  18710. */
  18711. static XBOX: number;
  18712. /**
  18713. * Represents a pose-enabled controller
  18714. */
  18715. static POSE_ENABLED: number;
  18716. /**
  18717. * Represents an Dual Shock controller
  18718. */
  18719. static DUALSHOCK: number;
  18720. /**
  18721. * Specifies whether the left control stick should be Y-inverted
  18722. */
  18723. protected _invertLeftStickY: boolean;
  18724. /**
  18725. * Specifies if the gamepad has been connected
  18726. */
  18727. get isConnected(): boolean;
  18728. /**
  18729. * Initializes the gamepad
  18730. * @param id The id of the gamepad
  18731. * @param index The index of the gamepad
  18732. * @param browserGamepad The browser gamepad
  18733. * @param leftStickX The x component of the left joystick
  18734. * @param leftStickY The y component of the left joystick
  18735. * @param rightStickX The x component of the right joystick
  18736. * @param rightStickY The y component of the right joystick
  18737. */
  18738. constructor(
  18739. /**
  18740. * The id of the gamepad
  18741. */
  18742. id: string,
  18743. /**
  18744. * The index of the gamepad
  18745. */
  18746. index: number,
  18747. /**
  18748. * The browser gamepad
  18749. */
  18750. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18751. /**
  18752. * Callback triggered when the left joystick has changed
  18753. * @param callback
  18754. */
  18755. onleftstickchanged(callback: (values: StickValues) => void): void;
  18756. /**
  18757. * Callback triggered when the right joystick has changed
  18758. * @param callback
  18759. */
  18760. onrightstickchanged(callback: (values: StickValues) => void): void;
  18761. /**
  18762. * Gets the left joystick
  18763. */
  18764. get leftStick(): StickValues;
  18765. /**
  18766. * Sets the left joystick values
  18767. */
  18768. set leftStick(newValues: StickValues);
  18769. /**
  18770. * Gets the right joystick
  18771. */
  18772. get rightStick(): StickValues;
  18773. /**
  18774. * Sets the right joystick value
  18775. */
  18776. set rightStick(newValues: StickValues);
  18777. /**
  18778. * Updates the gamepad joystick positions
  18779. */
  18780. update(): void;
  18781. /**
  18782. * Disposes the gamepad
  18783. */
  18784. dispose(): void;
  18785. }
  18786. /**
  18787. * Represents a generic gamepad
  18788. */
  18789. export class GenericPad extends Gamepad {
  18790. private _buttons;
  18791. private _onbuttondown;
  18792. private _onbuttonup;
  18793. /**
  18794. * Observable triggered when a button has been pressed
  18795. */
  18796. onButtonDownObservable: Observable<number>;
  18797. /**
  18798. * Observable triggered when a button has been released
  18799. */
  18800. onButtonUpObservable: Observable<number>;
  18801. /**
  18802. * Callback triggered when a button has been pressed
  18803. * @param callback Called when a button has been pressed
  18804. */
  18805. onbuttondown(callback: (buttonPressed: number) => void): void;
  18806. /**
  18807. * Callback triggered when a button has been released
  18808. * @param callback Called when a button has been released
  18809. */
  18810. onbuttonup(callback: (buttonReleased: number) => void): void;
  18811. /**
  18812. * Initializes the generic gamepad
  18813. * @param id The id of the generic gamepad
  18814. * @param index The index of the generic gamepad
  18815. * @param browserGamepad The browser gamepad
  18816. */
  18817. constructor(id: string, index: number, browserGamepad: any);
  18818. private _setButtonValue;
  18819. /**
  18820. * Updates the generic gamepad
  18821. */
  18822. update(): void;
  18823. /**
  18824. * Disposes the generic gamepad
  18825. */
  18826. dispose(): void;
  18827. }
  18828. }
  18829. declare module BABYLON {
  18830. /**
  18831. * Defines the types of pose enabled controllers that are supported
  18832. */
  18833. export enum PoseEnabledControllerType {
  18834. /**
  18835. * HTC Vive
  18836. */
  18837. VIVE = 0,
  18838. /**
  18839. * Oculus Rift
  18840. */
  18841. OCULUS = 1,
  18842. /**
  18843. * Windows mixed reality
  18844. */
  18845. WINDOWS = 2,
  18846. /**
  18847. * Samsung gear VR
  18848. */
  18849. GEAR_VR = 3,
  18850. /**
  18851. * Google Daydream
  18852. */
  18853. DAYDREAM = 4,
  18854. /**
  18855. * Generic
  18856. */
  18857. GENERIC = 5
  18858. }
  18859. /**
  18860. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18861. */
  18862. export interface MutableGamepadButton {
  18863. /**
  18864. * Value of the button/trigger
  18865. */
  18866. value: number;
  18867. /**
  18868. * If the button/trigger is currently touched
  18869. */
  18870. touched: boolean;
  18871. /**
  18872. * If the button/trigger is currently pressed
  18873. */
  18874. pressed: boolean;
  18875. }
  18876. /**
  18877. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18878. * @hidden
  18879. */
  18880. export interface ExtendedGamepadButton extends GamepadButton {
  18881. /**
  18882. * If the button/trigger is currently pressed
  18883. */
  18884. readonly pressed: boolean;
  18885. /**
  18886. * If the button/trigger is currently touched
  18887. */
  18888. readonly touched: boolean;
  18889. /**
  18890. * Value of the button/trigger
  18891. */
  18892. readonly value: number;
  18893. }
  18894. /** @hidden */
  18895. export interface _GamePadFactory {
  18896. /**
  18897. * Returns whether or not the current gamepad can be created for this type of controller.
  18898. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18899. * @returns true if it can be created, otherwise false
  18900. */
  18901. canCreate(gamepadInfo: any): boolean;
  18902. /**
  18903. * Creates a new instance of the Gamepad.
  18904. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18905. * @returns the new gamepad instance
  18906. */
  18907. create(gamepadInfo: any): Gamepad;
  18908. }
  18909. /**
  18910. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18911. */
  18912. export class PoseEnabledControllerHelper {
  18913. /** @hidden */
  18914. static _ControllerFactories: _GamePadFactory[];
  18915. /** @hidden */
  18916. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18917. /**
  18918. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18919. * @param vrGamepad the gamepad to initialized
  18920. * @returns a vr controller of the type the gamepad identified as
  18921. */
  18922. static InitiateController(vrGamepad: any): Gamepad;
  18923. }
  18924. /**
  18925. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18926. */
  18927. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18928. /**
  18929. * If the controller is used in a webXR session
  18930. */
  18931. isXR: boolean;
  18932. private _deviceRoomPosition;
  18933. private _deviceRoomRotationQuaternion;
  18934. /**
  18935. * The device position in babylon space
  18936. */
  18937. devicePosition: Vector3;
  18938. /**
  18939. * The device rotation in babylon space
  18940. */
  18941. deviceRotationQuaternion: Quaternion;
  18942. /**
  18943. * The scale factor of the device in babylon space
  18944. */
  18945. deviceScaleFactor: number;
  18946. /**
  18947. * (Likely devicePosition should be used instead) The device position in its room space
  18948. */
  18949. position: Vector3;
  18950. /**
  18951. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18952. */
  18953. rotationQuaternion: Quaternion;
  18954. /**
  18955. * The type of controller (Eg. Windows mixed reality)
  18956. */
  18957. controllerType: PoseEnabledControllerType;
  18958. protected _calculatedPosition: Vector3;
  18959. private _calculatedRotation;
  18960. /**
  18961. * The raw pose from the device
  18962. */
  18963. rawPose: DevicePose;
  18964. private _trackPosition;
  18965. private _maxRotationDistFromHeadset;
  18966. private _draggedRoomRotation;
  18967. /**
  18968. * @hidden
  18969. */
  18970. _disableTrackPosition(fixedPosition: Vector3): void;
  18971. /**
  18972. * Internal, the mesh attached to the controller
  18973. * @hidden
  18974. */
  18975. _mesh: Nullable<AbstractMesh>;
  18976. private _poseControlledCamera;
  18977. private _leftHandSystemQuaternion;
  18978. /**
  18979. * Internal, matrix used to convert room space to babylon space
  18980. * @hidden
  18981. */
  18982. _deviceToWorld: Matrix;
  18983. /**
  18984. * Node to be used when casting a ray from the controller
  18985. * @hidden
  18986. */
  18987. _pointingPoseNode: Nullable<TransformNode>;
  18988. /**
  18989. * Name of the child mesh that can be used to cast a ray from the controller
  18990. */
  18991. static readonly POINTING_POSE: string;
  18992. /**
  18993. * Creates a new PoseEnabledController from a gamepad
  18994. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18995. */
  18996. constructor(browserGamepad: any);
  18997. private _workingMatrix;
  18998. /**
  18999. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19000. */
  19001. update(): void;
  19002. /**
  19003. * Updates only the pose device and mesh without doing any button event checking
  19004. */
  19005. protected _updatePoseAndMesh(): void;
  19006. /**
  19007. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19008. * @param poseData raw pose fromthe device
  19009. */
  19010. updateFromDevice(poseData: DevicePose): void;
  19011. /**
  19012. * @hidden
  19013. */
  19014. _meshAttachedObservable: Observable<AbstractMesh>;
  19015. /**
  19016. * Attaches a mesh to the controller
  19017. * @param mesh the mesh to be attached
  19018. */
  19019. attachToMesh(mesh: AbstractMesh): void;
  19020. /**
  19021. * Attaches the controllers mesh to a camera
  19022. * @param camera the camera the mesh should be attached to
  19023. */
  19024. attachToPoseControlledCamera(camera: TargetCamera): void;
  19025. /**
  19026. * Disposes of the controller
  19027. */
  19028. dispose(): void;
  19029. /**
  19030. * The mesh that is attached to the controller
  19031. */
  19032. get mesh(): Nullable<AbstractMesh>;
  19033. /**
  19034. * Gets the ray of the controller in the direction the controller is pointing
  19035. * @param length the length the resulting ray should be
  19036. * @returns a ray in the direction the controller is pointing
  19037. */
  19038. getForwardRay(length?: number): Ray;
  19039. }
  19040. }
  19041. declare module BABYLON {
  19042. /**
  19043. * Defines the WebVRController object that represents controllers tracked in 3D space
  19044. */
  19045. export abstract class WebVRController extends PoseEnabledController {
  19046. /**
  19047. * Internal, the default controller model for the controller
  19048. */
  19049. protected _defaultModel: Nullable<AbstractMesh>;
  19050. /**
  19051. * Fired when the trigger state has changed
  19052. */
  19053. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19054. /**
  19055. * Fired when the main button state has changed
  19056. */
  19057. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19058. /**
  19059. * Fired when the secondary button state has changed
  19060. */
  19061. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19062. /**
  19063. * Fired when the pad state has changed
  19064. */
  19065. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19066. /**
  19067. * Fired when controllers stick values have changed
  19068. */
  19069. onPadValuesChangedObservable: Observable<StickValues>;
  19070. /**
  19071. * Array of button availible on the controller
  19072. */
  19073. protected _buttons: Array<MutableGamepadButton>;
  19074. private _onButtonStateChange;
  19075. /**
  19076. * Fired when a controller button's state has changed
  19077. * @param callback the callback containing the button that was modified
  19078. */
  19079. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19080. /**
  19081. * X and Y axis corresponding to the controllers joystick
  19082. */
  19083. pad: StickValues;
  19084. /**
  19085. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19086. */
  19087. hand: string;
  19088. /**
  19089. * The default controller model for the controller
  19090. */
  19091. get defaultModel(): Nullable<AbstractMesh>;
  19092. /**
  19093. * Creates a new WebVRController from a gamepad
  19094. * @param vrGamepad the gamepad that the WebVRController should be created from
  19095. */
  19096. constructor(vrGamepad: any);
  19097. /**
  19098. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19099. */
  19100. update(): void;
  19101. /**
  19102. * Function to be called when a button is modified
  19103. */
  19104. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19105. /**
  19106. * Loads a mesh and attaches it to the controller
  19107. * @param scene the scene the mesh should be added to
  19108. * @param meshLoaded callback for when the mesh has been loaded
  19109. */
  19110. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19111. private _setButtonValue;
  19112. private _changes;
  19113. private _checkChanges;
  19114. /**
  19115. * Disposes of th webVRCOntroller
  19116. */
  19117. dispose(): void;
  19118. }
  19119. }
  19120. declare module BABYLON {
  19121. /**
  19122. * The HemisphericLight simulates the ambient environment light,
  19123. * so the passed direction is the light reflection direction, not the incoming direction.
  19124. */
  19125. export class HemisphericLight extends Light {
  19126. /**
  19127. * The groundColor is the light in the opposite direction to the one specified during creation.
  19128. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  19129. */
  19130. groundColor: Color3;
  19131. /**
  19132. * The light reflection direction, not the incoming direction.
  19133. */
  19134. direction: Vector3;
  19135. /**
  19136. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19137. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19138. * The HemisphericLight can't cast shadows.
  19139. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19140. * @param name The friendly name of the light
  19141. * @param direction The direction of the light reflection
  19142. * @param scene The scene the light belongs to
  19143. */
  19144. constructor(name: string, direction: Vector3, scene: Scene);
  19145. protected _buildUniformLayout(): void;
  19146. /**
  19147. * Returns the string "HemisphericLight".
  19148. * @return The class name
  19149. */
  19150. getClassName(): string;
  19151. /**
  19152. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19153. * Returns the updated direction.
  19154. * @param target The target the direction should point to
  19155. * @return The computed direction
  19156. */
  19157. setDirectionToTarget(target: Vector3): Vector3;
  19158. /**
  19159. * Returns the shadow generator associated to the light.
  19160. * @returns Always null for hemispheric lights because it does not support shadows.
  19161. */
  19162. getShadowGenerator(): Nullable<IShadowGenerator>;
  19163. /**
  19164. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19165. * @param effect The effect to update
  19166. * @param lightIndex The index of the light in the effect to update
  19167. * @returns The hemispheric light
  19168. */
  19169. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19170. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19171. /**
  19172. * Computes the world matrix of the node
  19173. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19174. * @param useWasUpdatedFlag defines a reserved property
  19175. * @returns the world matrix
  19176. */
  19177. computeWorldMatrix(): Matrix;
  19178. /**
  19179. * Returns the integer 3.
  19180. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19181. */
  19182. getTypeID(): number;
  19183. /**
  19184. * Prepares the list of defines specific to the light type.
  19185. * @param defines the list of defines
  19186. * @param lightIndex defines the index of the light for the effect
  19187. */
  19188. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19189. }
  19190. }
  19191. declare module BABYLON {
  19192. /** @hidden */
  19193. export var vrMultiviewToSingleviewPixelShader: {
  19194. name: string;
  19195. shader: string;
  19196. };
  19197. }
  19198. declare module BABYLON {
  19199. /**
  19200. * Renders to multiple views with a single draw call
  19201. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19202. */
  19203. export class MultiviewRenderTarget extends RenderTargetTexture {
  19204. /**
  19205. * Creates a multiview render target
  19206. * @param scene scene used with the render target
  19207. * @param size the size of the render target (used for each view)
  19208. */
  19209. constructor(scene: Scene, size?: number | {
  19210. width: number;
  19211. height: number;
  19212. } | {
  19213. ratio: number;
  19214. });
  19215. /**
  19216. * @hidden
  19217. * @param faceIndex the face index, if its a cube texture
  19218. */
  19219. _bindFrameBuffer(faceIndex?: number): void;
  19220. /**
  19221. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19222. * @returns the view count
  19223. */
  19224. getViewCount(): number;
  19225. }
  19226. }
  19227. declare module BABYLON {
  19228. /**
  19229. * Represents a camera frustum
  19230. */
  19231. export class Frustum {
  19232. /**
  19233. * Gets the planes representing the frustum
  19234. * @param transform matrix to be applied to the returned planes
  19235. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19236. */
  19237. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19238. /**
  19239. * Gets the near frustum plane transformed by the transform matrix
  19240. * @param transform transformation matrix to be applied to the resulting frustum plane
  19241. * @param frustumPlane the resuling frustum plane
  19242. */
  19243. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19244. /**
  19245. * Gets the far frustum plane transformed by the transform matrix
  19246. * @param transform transformation matrix to be applied to the resulting frustum plane
  19247. * @param frustumPlane the resuling frustum plane
  19248. */
  19249. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19250. /**
  19251. * Gets the left frustum plane transformed by the transform matrix
  19252. * @param transform transformation matrix to be applied to the resulting frustum plane
  19253. * @param frustumPlane the resuling frustum plane
  19254. */
  19255. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19256. /**
  19257. * Gets the right frustum plane transformed by the transform matrix
  19258. * @param transform transformation matrix to be applied to the resulting frustum plane
  19259. * @param frustumPlane the resuling frustum plane
  19260. */
  19261. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19262. /**
  19263. * Gets the top frustum plane transformed by the transform matrix
  19264. * @param transform transformation matrix to be applied to the resulting frustum plane
  19265. * @param frustumPlane the resuling frustum plane
  19266. */
  19267. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19268. /**
  19269. * Gets the bottom frustum plane transformed by the transform matrix
  19270. * @param transform transformation matrix to be applied to the resulting frustum plane
  19271. * @param frustumPlane the resuling frustum plane
  19272. */
  19273. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19274. /**
  19275. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19276. * @param transform transformation matrix to be applied to the resulting frustum planes
  19277. * @param frustumPlanes the resuling frustum planes
  19278. */
  19279. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19280. }
  19281. }
  19282. declare module BABYLON {
  19283. interface Engine {
  19284. /**
  19285. * Creates a new multiview render target
  19286. * @param width defines the width of the texture
  19287. * @param height defines the height of the texture
  19288. * @returns the created multiview texture
  19289. */
  19290. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19291. /**
  19292. * Binds a multiview framebuffer to be drawn to
  19293. * @param multiviewTexture texture to bind
  19294. */
  19295. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19296. }
  19297. interface Camera {
  19298. /**
  19299. * @hidden
  19300. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19301. */
  19302. _useMultiviewToSingleView: boolean;
  19303. /**
  19304. * @hidden
  19305. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19306. */
  19307. _multiviewTexture: Nullable<RenderTargetTexture>;
  19308. /**
  19309. * @hidden
  19310. * ensures the multiview texture of the camera exists and has the specified width/height
  19311. * @param width height to set on the multiview texture
  19312. * @param height width to set on the multiview texture
  19313. */
  19314. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19315. }
  19316. interface Scene {
  19317. /** @hidden */
  19318. _transformMatrixR: Matrix;
  19319. /** @hidden */
  19320. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19321. /** @hidden */
  19322. _createMultiviewUbo(): void;
  19323. /** @hidden */
  19324. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19325. /** @hidden */
  19326. _renderMultiviewToSingleView(camera: Camera): void;
  19327. }
  19328. }
  19329. declare module BABYLON {
  19330. /**
  19331. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19332. * This will not be used for webXR as it supports displaying texture arrays directly
  19333. */
  19334. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19335. /**
  19336. * Initializes a VRMultiviewToSingleview
  19337. * @param name name of the post process
  19338. * @param camera camera to be applied to
  19339. * @param scaleFactor scaling factor to the size of the output texture
  19340. */
  19341. constructor(name: string, camera: Camera, scaleFactor: number);
  19342. }
  19343. }
  19344. declare module BABYLON {
  19345. /**
  19346. * Interface used to define additional presentation attributes
  19347. */
  19348. export interface IVRPresentationAttributes {
  19349. /**
  19350. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19351. */
  19352. highRefreshRate: boolean;
  19353. /**
  19354. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19355. */
  19356. foveationLevel: number;
  19357. }
  19358. interface Engine {
  19359. /** @hidden */
  19360. _vrDisplay: any;
  19361. /** @hidden */
  19362. _vrSupported: boolean;
  19363. /** @hidden */
  19364. _oldSize: Size;
  19365. /** @hidden */
  19366. _oldHardwareScaleFactor: number;
  19367. /** @hidden */
  19368. _vrExclusivePointerMode: boolean;
  19369. /** @hidden */
  19370. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19371. /** @hidden */
  19372. _onVRDisplayPointerRestricted: () => void;
  19373. /** @hidden */
  19374. _onVRDisplayPointerUnrestricted: () => void;
  19375. /** @hidden */
  19376. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19377. /** @hidden */
  19378. _onVrDisplayDisconnect: Nullable<() => void>;
  19379. /** @hidden */
  19380. _onVrDisplayPresentChange: Nullable<() => void>;
  19381. /**
  19382. * Observable signaled when VR display mode changes
  19383. */
  19384. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19385. /**
  19386. * Observable signaled when VR request present is complete
  19387. */
  19388. onVRRequestPresentComplete: Observable<boolean>;
  19389. /**
  19390. * Observable signaled when VR request present starts
  19391. */
  19392. onVRRequestPresentStart: Observable<Engine>;
  19393. /**
  19394. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19395. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19396. */
  19397. isInVRExclusivePointerMode: boolean;
  19398. /**
  19399. * Gets a boolean indicating if a webVR device was detected
  19400. * @returns true if a webVR device was detected
  19401. */
  19402. isVRDevicePresent(): boolean;
  19403. /**
  19404. * Gets the current webVR device
  19405. * @returns the current webVR device (or null)
  19406. */
  19407. getVRDevice(): any;
  19408. /**
  19409. * Initializes a webVR display and starts listening to display change events
  19410. * The onVRDisplayChangedObservable will be notified upon these changes
  19411. * @returns A promise containing a VRDisplay and if vr is supported
  19412. */
  19413. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19414. /** @hidden */
  19415. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19416. /**
  19417. * Gets or sets the presentation attributes used to configure VR rendering
  19418. */
  19419. vrPresentationAttributes?: IVRPresentationAttributes;
  19420. /**
  19421. * Call this function to switch to webVR mode
  19422. * Will do nothing if webVR is not supported or if there is no webVR device
  19423. * @param options the webvr options provided to the camera. mainly used for multiview
  19424. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19425. */
  19426. enableVR(options: WebVROptions): void;
  19427. /** @hidden */
  19428. _onVRFullScreenTriggered(): void;
  19429. }
  19430. }
  19431. declare module BABYLON {
  19432. /**
  19433. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19434. * IMPORTANT!! The data is right-hand data.
  19435. * @export
  19436. * @interface DevicePose
  19437. */
  19438. export interface DevicePose {
  19439. /**
  19440. * The position of the device, values in array are [x,y,z].
  19441. */
  19442. readonly position: Nullable<Float32Array>;
  19443. /**
  19444. * The linearVelocity of the device, values in array are [x,y,z].
  19445. */
  19446. readonly linearVelocity: Nullable<Float32Array>;
  19447. /**
  19448. * The linearAcceleration of the device, values in array are [x,y,z].
  19449. */
  19450. readonly linearAcceleration: Nullable<Float32Array>;
  19451. /**
  19452. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19453. */
  19454. readonly orientation: Nullable<Float32Array>;
  19455. /**
  19456. * The angularVelocity of the device, values in array are [x,y,z].
  19457. */
  19458. readonly angularVelocity: Nullable<Float32Array>;
  19459. /**
  19460. * The angularAcceleration of the device, values in array are [x,y,z].
  19461. */
  19462. readonly angularAcceleration: Nullable<Float32Array>;
  19463. }
  19464. /**
  19465. * Interface representing a pose controlled object in Babylon.
  19466. * A pose controlled object has both regular pose values as well as pose values
  19467. * from an external device such as a VR head mounted display
  19468. */
  19469. export interface PoseControlled {
  19470. /**
  19471. * The position of the object in babylon space.
  19472. */
  19473. position: Vector3;
  19474. /**
  19475. * The rotation quaternion of the object in babylon space.
  19476. */
  19477. rotationQuaternion: Quaternion;
  19478. /**
  19479. * The position of the device in babylon space.
  19480. */
  19481. devicePosition?: Vector3;
  19482. /**
  19483. * The rotation quaternion of the device in babylon space.
  19484. */
  19485. deviceRotationQuaternion: Quaternion;
  19486. /**
  19487. * The raw pose coming from the device.
  19488. */
  19489. rawPose: Nullable<DevicePose>;
  19490. /**
  19491. * The scale of the device to be used when translating from device space to babylon space.
  19492. */
  19493. deviceScaleFactor: number;
  19494. /**
  19495. * Updates the poseControlled values based on the input device pose.
  19496. * @param poseData the pose data to update the object with
  19497. */
  19498. updateFromDevice(poseData: DevicePose): void;
  19499. }
  19500. /**
  19501. * Set of options to customize the webVRCamera
  19502. */
  19503. export interface WebVROptions {
  19504. /**
  19505. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19506. */
  19507. trackPosition?: boolean;
  19508. /**
  19509. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19510. */
  19511. positionScale?: number;
  19512. /**
  19513. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19514. */
  19515. displayName?: string;
  19516. /**
  19517. * Should the native controller meshes be initialized. (default: true)
  19518. */
  19519. controllerMeshes?: boolean;
  19520. /**
  19521. * Creating a default HemiLight only on controllers. (default: true)
  19522. */
  19523. defaultLightingOnControllers?: boolean;
  19524. /**
  19525. * If you don't want to use the default VR button of the helper. (default: false)
  19526. */
  19527. useCustomVRButton?: boolean;
  19528. /**
  19529. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19530. */
  19531. customVRButton?: HTMLButtonElement;
  19532. /**
  19533. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19534. */
  19535. rayLength?: number;
  19536. /**
  19537. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19538. */
  19539. defaultHeight?: number;
  19540. /**
  19541. * If multiview should be used if availible (default: false)
  19542. */
  19543. useMultiview?: boolean;
  19544. }
  19545. /**
  19546. * This represents a WebVR camera.
  19547. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19548. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19549. */
  19550. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19551. private webVROptions;
  19552. /**
  19553. * @hidden
  19554. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19555. */
  19556. _vrDevice: any;
  19557. /**
  19558. * The rawPose of the vrDevice.
  19559. */
  19560. rawPose: Nullable<DevicePose>;
  19561. private _onVREnabled;
  19562. private _specsVersion;
  19563. private _attached;
  19564. private _frameData;
  19565. protected _descendants: Array<Node>;
  19566. private _deviceRoomPosition;
  19567. /** @hidden */
  19568. _deviceRoomRotationQuaternion: Quaternion;
  19569. private _standingMatrix;
  19570. /**
  19571. * Represents device position in babylon space.
  19572. */
  19573. devicePosition: Vector3;
  19574. /**
  19575. * Represents device rotation in babylon space.
  19576. */
  19577. deviceRotationQuaternion: Quaternion;
  19578. /**
  19579. * The scale of the device to be used when translating from device space to babylon space.
  19580. */
  19581. deviceScaleFactor: number;
  19582. private _deviceToWorld;
  19583. private _worldToDevice;
  19584. /**
  19585. * References to the webVR controllers for the vrDevice.
  19586. */
  19587. controllers: Array<WebVRController>;
  19588. /**
  19589. * Emits an event when a controller is attached.
  19590. */
  19591. onControllersAttachedObservable: Observable<WebVRController[]>;
  19592. /**
  19593. * Emits an event when a controller's mesh has been loaded;
  19594. */
  19595. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19596. /**
  19597. * Emits an event when the HMD's pose has been updated.
  19598. */
  19599. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19600. private _poseSet;
  19601. /**
  19602. * If the rig cameras be used as parent instead of this camera.
  19603. */
  19604. rigParenting: boolean;
  19605. private _lightOnControllers;
  19606. private _defaultHeight?;
  19607. /**
  19608. * Instantiates a WebVRFreeCamera.
  19609. * @param name The name of the WebVRFreeCamera
  19610. * @param position The starting anchor position for the camera
  19611. * @param scene The scene the camera belongs to
  19612. * @param webVROptions a set of customizable options for the webVRCamera
  19613. */
  19614. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19615. /**
  19616. * Gets the device distance from the ground in meters.
  19617. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  19618. */
  19619. deviceDistanceToRoomGround(): number;
  19620. /**
  19621. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19622. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19623. */
  19624. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19625. /**
  19626. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19627. * @returns A promise with a boolean set to if the standing matrix is supported.
  19628. */
  19629. useStandingMatrixAsync(): Promise<boolean>;
  19630. /**
  19631. * Disposes the camera
  19632. */
  19633. dispose(): void;
  19634. /**
  19635. * Gets a vrController by name.
  19636. * @param name The name of the controller to retreive
  19637. * @returns the controller matching the name specified or null if not found
  19638. */
  19639. getControllerByName(name: string): Nullable<WebVRController>;
  19640. private _leftController;
  19641. /**
  19642. * The controller corresponding to the users left hand.
  19643. */
  19644. get leftController(): Nullable<WebVRController>;
  19645. private _rightController;
  19646. /**
  19647. * The controller corresponding to the users right hand.
  19648. */
  19649. get rightController(): Nullable<WebVRController>;
  19650. /**
  19651. * Casts a ray forward from the vrCamera's gaze.
  19652. * @param length Length of the ray (default: 100)
  19653. * @returns the ray corresponding to the gaze
  19654. */
  19655. getForwardRay(length?: number): Ray;
  19656. /**
  19657. * @hidden
  19658. * Updates the camera based on device's frame data
  19659. */
  19660. _checkInputs(): void;
  19661. /**
  19662. * Updates the poseControlled values based on the input device pose.
  19663. * @param poseData Pose coming from the device
  19664. */
  19665. updateFromDevice(poseData: DevicePose): void;
  19666. private _htmlElementAttached;
  19667. private _detachIfAttached;
  19668. /**
  19669. * WebVR's attach control will start broadcasting frames to the device.
  19670. * Note that in certain browsers (chrome for example) this function must be called
  19671. * within a user-interaction callback. Example:
  19672. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19673. *
  19674. * @param element html element to attach the vrDevice to
  19675. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19676. */
  19677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19678. /**
  19679. * Detaches the camera from the html element and disables VR
  19680. *
  19681. * @param element html element to detach from
  19682. */
  19683. detachControl(element: HTMLElement): void;
  19684. /**
  19685. * @returns the name of this class
  19686. */
  19687. getClassName(): string;
  19688. /**
  19689. * Calls resetPose on the vrDisplay
  19690. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19691. */
  19692. resetToCurrentRotation(): void;
  19693. /**
  19694. * @hidden
  19695. * Updates the rig cameras (left and right eye)
  19696. */
  19697. _updateRigCameras(): void;
  19698. private _workingVector;
  19699. private _oneVector;
  19700. private _workingMatrix;
  19701. private updateCacheCalled;
  19702. private _correctPositionIfNotTrackPosition;
  19703. /**
  19704. * @hidden
  19705. * Updates the cached values of the camera
  19706. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19707. */
  19708. _updateCache(ignoreParentClass?: boolean): void;
  19709. /**
  19710. * @hidden
  19711. * Get current device position in babylon world
  19712. */
  19713. _computeDevicePosition(): void;
  19714. /**
  19715. * Updates the current device position and rotation in the babylon world
  19716. */
  19717. update(): void;
  19718. /**
  19719. * @hidden
  19720. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19721. * @returns an identity matrix
  19722. */
  19723. _getViewMatrix(): Matrix;
  19724. private _tmpMatrix;
  19725. /**
  19726. * This function is called by the two RIG cameras.
  19727. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19728. * @hidden
  19729. */
  19730. _getWebVRViewMatrix(): Matrix;
  19731. /** @hidden */
  19732. _getWebVRProjectionMatrix(): Matrix;
  19733. private _onGamepadConnectedObserver;
  19734. private _onGamepadDisconnectedObserver;
  19735. private _updateCacheWhenTrackingDisabledObserver;
  19736. /**
  19737. * Initializes the controllers and their meshes
  19738. */
  19739. initControllers(): void;
  19740. }
  19741. }
  19742. declare module BABYLON {
  19743. /**
  19744. * Size options for a post process
  19745. */
  19746. export type PostProcessOptions = {
  19747. width: number;
  19748. height: number;
  19749. };
  19750. /**
  19751. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19752. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19753. */
  19754. export class PostProcess {
  19755. /** Name of the PostProcess. */
  19756. name: string;
  19757. /**
  19758. * Gets or sets the unique id of the post process
  19759. */
  19760. uniqueId: number;
  19761. /**
  19762. * Width of the texture to apply the post process on
  19763. */
  19764. width: number;
  19765. /**
  19766. * Height of the texture to apply the post process on
  19767. */
  19768. height: number;
  19769. /**
  19770. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19771. * @hidden
  19772. */
  19773. _outputTexture: Nullable<InternalTexture>;
  19774. /**
  19775. * Sampling mode used by the shader
  19776. * See https://doc.babylonjs.com/classes/3.1/texture
  19777. */
  19778. renderTargetSamplingMode: number;
  19779. /**
  19780. * Clear color to use when screen clearing
  19781. */
  19782. clearColor: Color4;
  19783. /**
  19784. * If the buffer needs to be cleared before applying the post process. (default: true)
  19785. * Should be set to false if shader will overwrite all previous pixels.
  19786. */
  19787. autoClear: boolean;
  19788. /**
  19789. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19790. */
  19791. alphaMode: number;
  19792. /**
  19793. * Sets the setAlphaBlendConstants of the babylon engine
  19794. */
  19795. alphaConstants: Color4;
  19796. /**
  19797. * Animations to be used for the post processing
  19798. */
  19799. animations: Animation[];
  19800. /**
  19801. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19802. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19803. */
  19804. enablePixelPerfectMode: boolean;
  19805. /**
  19806. * Force the postprocess to be applied without taking in account viewport
  19807. */
  19808. forceFullscreenViewport: boolean;
  19809. /**
  19810. * List of inspectable custom properties (used by the Inspector)
  19811. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19812. */
  19813. inspectableCustomProperties: IInspectable[];
  19814. /**
  19815. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19816. *
  19817. * | Value | Type | Description |
  19818. * | ----- | ----------------------------------- | ----------- |
  19819. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19820. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19821. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19822. *
  19823. */
  19824. scaleMode: number;
  19825. /**
  19826. * Force textures to be a power of two (default: false)
  19827. */
  19828. alwaysForcePOT: boolean;
  19829. private _samples;
  19830. /**
  19831. * Number of sample textures (default: 1)
  19832. */
  19833. get samples(): number;
  19834. set samples(n: number);
  19835. /**
  19836. * Modify the scale of the post process to be the same as the viewport (default: false)
  19837. */
  19838. adaptScaleToCurrentViewport: boolean;
  19839. private _camera;
  19840. private _scene;
  19841. private _engine;
  19842. private _options;
  19843. private _reusable;
  19844. private _textureType;
  19845. private _textureFormat;
  19846. /**
  19847. * Smart array of input and output textures for the post process.
  19848. * @hidden
  19849. */
  19850. _textures: SmartArray<InternalTexture>;
  19851. /**
  19852. * The index in _textures that corresponds to the output texture.
  19853. * @hidden
  19854. */
  19855. _currentRenderTextureInd: number;
  19856. private _effect;
  19857. private _samplers;
  19858. private _fragmentUrl;
  19859. private _vertexUrl;
  19860. private _parameters;
  19861. private _scaleRatio;
  19862. protected _indexParameters: any;
  19863. private _shareOutputWithPostProcess;
  19864. private _texelSize;
  19865. private _forcedOutputTexture;
  19866. /**
  19867. * Returns the fragment url or shader name used in the post process.
  19868. * @returns the fragment url or name in the shader store.
  19869. */
  19870. getEffectName(): string;
  19871. /**
  19872. * An event triggered when the postprocess is activated.
  19873. */
  19874. onActivateObservable: Observable<Camera>;
  19875. private _onActivateObserver;
  19876. /**
  19877. * A function that is added to the onActivateObservable
  19878. */
  19879. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19880. /**
  19881. * An event triggered when the postprocess changes its size.
  19882. */
  19883. onSizeChangedObservable: Observable<PostProcess>;
  19884. private _onSizeChangedObserver;
  19885. /**
  19886. * A function that is added to the onSizeChangedObservable
  19887. */
  19888. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19889. /**
  19890. * An event triggered when the postprocess applies its effect.
  19891. */
  19892. onApplyObservable: Observable<Effect>;
  19893. private _onApplyObserver;
  19894. /**
  19895. * A function that is added to the onApplyObservable
  19896. */
  19897. set onApply(callback: (effect: Effect) => void);
  19898. /**
  19899. * An event triggered before rendering the postprocess
  19900. */
  19901. onBeforeRenderObservable: Observable<Effect>;
  19902. private _onBeforeRenderObserver;
  19903. /**
  19904. * A function that is added to the onBeforeRenderObservable
  19905. */
  19906. set onBeforeRender(callback: (effect: Effect) => void);
  19907. /**
  19908. * An event triggered after rendering the postprocess
  19909. */
  19910. onAfterRenderObservable: Observable<Effect>;
  19911. private _onAfterRenderObserver;
  19912. /**
  19913. * A function that is added to the onAfterRenderObservable
  19914. */
  19915. set onAfterRender(callback: (efect: Effect) => void);
  19916. /**
  19917. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  19918. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19919. */
  19920. get inputTexture(): InternalTexture;
  19921. set inputTexture(value: InternalTexture);
  19922. /**
  19923. * Gets the camera which post process is applied to.
  19924. * @returns The camera the post process is applied to.
  19925. */
  19926. getCamera(): Camera;
  19927. /**
  19928. * Gets the texel size of the postprocess.
  19929. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19930. */
  19931. get texelSize(): Vector2;
  19932. /**
  19933. * Creates a new instance PostProcess
  19934. * @param name The name of the PostProcess.
  19935. * @param fragmentUrl The url of the fragment shader to be used.
  19936. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19937. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19938. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19939. * @param camera The camera to apply the render pass to.
  19940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19941. * @param engine The engine which the post process will be applied. (default: current engine)
  19942. * @param reusable If the post process can be reused on the same frame. (default: false)
  19943. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19944. * @param textureType Type of textures used when performing the post process. (default: 0)
  19945. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19946. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  19947. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19948. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19949. */
  19950. constructor(
  19951. /** Name of the PostProcess. */
  19952. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  19953. /**
  19954. * Gets a string idenfifying the name of the class
  19955. * @returns "PostProcess" string
  19956. */
  19957. getClassName(): string;
  19958. /**
  19959. * Gets the engine which this post process belongs to.
  19960. * @returns The engine the post process was enabled with.
  19961. */
  19962. getEngine(): Engine;
  19963. /**
  19964. * The effect that is created when initializing the post process.
  19965. * @returns The created effect corresponding the the postprocess.
  19966. */
  19967. getEffect(): Effect;
  19968. /**
  19969. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19970. * @param postProcess The post process to share the output with.
  19971. * @returns This post process.
  19972. */
  19973. shareOutputWith(postProcess: PostProcess): PostProcess;
  19974. /**
  19975. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19976. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19977. */
  19978. useOwnOutput(): void;
  19979. /**
  19980. * Updates the effect with the current post process compile time values and recompiles the shader.
  19981. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19982. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19983. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19984. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  19985. * @param onCompiled Called when the shader has been compiled.
  19986. * @param onError Called if there is an error when compiling a shader.
  19987. */
  19988. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19989. /**
  19990. * The post process is reusable if it can be used multiple times within one frame.
  19991. * @returns If the post process is reusable
  19992. */
  19993. isReusable(): boolean;
  19994. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19995. markTextureDirty(): void;
  19996. /**
  19997. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19998. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  19999. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20000. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20001. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20002. * @returns The target texture that was bound to be written to.
  20003. */
  20004. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20005. /**
  20006. * If the post process is supported.
  20007. */
  20008. get isSupported(): boolean;
  20009. /**
  20010. * The aspect ratio of the output texture.
  20011. */
  20012. get aspectRatio(): number;
  20013. /**
  20014. * Get a value indicating if the post-process is ready to be used
  20015. * @returns true if the post-process is ready (shader is compiled)
  20016. */
  20017. isReady(): boolean;
  20018. /**
  20019. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20020. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20021. */
  20022. apply(): Nullable<Effect>;
  20023. private _disposeTextures;
  20024. /**
  20025. * Disposes the post process.
  20026. * @param camera The camera to dispose the post process on.
  20027. */
  20028. dispose(camera?: Camera): void;
  20029. }
  20030. }
  20031. declare module BABYLON {
  20032. /** @hidden */
  20033. export var kernelBlurVaryingDeclaration: {
  20034. name: string;
  20035. shader: string;
  20036. };
  20037. }
  20038. declare module BABYLON {
  20039. /** @hidden */
  20040. export var kernelBlurFragment: {
  20041. name: string;
  20042. shader: string;
  20043. };
  20044. }
  20045. declare module BABYLON {
  20046. /** @hidden */
  20047. export var kernelBlurFragment2: {
  20048. name: string;
  20049. shader: string;
  20050. };
  20051. }
  20052. declare module BABYLON {
  20053. /** @hidden */
  20054. export var kernelBlurPixelShader: {
  20055. name: string;
  20056. shader: string;
  20057. };
  20058. }
  20059. declare module BABYLON {
  20060. /** @hidden */
  20061. export var kernelBlurVertex: {
  20062. name: string;
  20063. shader: string;
  20064. };
  20065. }
  20066. declare module BABYLON {
  20067. /** @hidden */
  20068. export var kernelBlurVertexShader: {
  20069. name: string;
  20070. shader: string;
  20071. };
  20072. }
  20073. declare module BABYLON {
  20074. /**
  20075. * The Blur Post Process which blurs an image based on a kernel and direction.
  20076. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20077. */
  20078. export class BlurPostProcess extends PostProcess {
  20079. /** The direction in which to blur the image. */
  20080. direction: Vector2;
  20081. private blockCompilation;
  20082. protected _kernel: number;
  20083. protected _idealKernel: number;
  20084. protected _packedFloat: boolean;
  20085. private _staticDefines;
  20086. /**
  20087. * Sets the length in pixels of the blur sample region
  20088. */
  20089. set kernel(v: number);
  20090. /**
  20091. * Gets the length in pixels of the blur sample region
  20092. */
  20093. get kernel(): number;
  20094. /**
  20095. * Sets wether or not the blur needs to unpack/repack floats
  20096. */
  20097. set packedFloat(v: boolean);
  20098. /**
  20099. * Gets wether or not the blur is unpacking/repacking floats
  20100. */
  20101. get packedFloat(): boolean;
  20102. /**
  20103. * Creates a new instance BlurPostProcess
  20104. * @param name The name of the effect.
  20105. * @param direction The direction in which to blur the image.
  20106. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  20107. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20108. * @param camera The camera to apply the render pass to.
  20109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20110. * @param engine The engine which the post process will be applied. (default: current engine)
  20111. * @param reusable If the post process can be reused on the same frame. (default: false)
  20112. * @param textureType Type of textures used when performing the post process. (default: 0)
  20113. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20114. */
  20115. constructor(name: string,
  20116. /** The direction in which to blur the image. */
  20117. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20118. /**
  20119. * Updates the effect with the current post process compile time values and recompiles the shader.
  20120. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20121. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20122. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20123. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20124. * @param onCompiled Called when the shader has been compiled.
  20125. * @param onError Called if there is an error when compiling a shader.
  20126. */
  20127. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20128. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20129. /**
  20130. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20131. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20132. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20133. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20134. * The gaps between physical kernels are compensated for in the weighting of the samples
  20135. * @param idealKernel Ideal blur kernel.
  20136. * @return Nearest best kernel.
  20137. */
  20138. protected _nearestBestKernel(idealKernel: number): number;
  20139. /**
  20140. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20141. * @param x The point on the Gaussian distribution to sample.
  20142. * @return the value of the Gaussian function at x.
  20143. */
  20144. protected _gaussianWeight(x: number): number;
  20145. /**
  20146. * Generates a string that can be used as a floating point number in GLSL.
  20147. * @param x Value to print.
  20148. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20149. * @return GLSL float string.
  20150. */
  20151. protected _glslFloat(x: number, decimalFigures?: number): string;
  20152. }
  20153. }
  20154. declare module BABYLON {
  20155. /**
  20156. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20157. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20158. * You can then easily use it as a reflectionTexture on a flat surface.
  20159. * In case the surface is not a plane, please consider relying on reflection probes.
  20160. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20161. */
  20162. export class MirrorTexture extends RenderTargetTexture {
  20163. private scene;
  20164. /**
  20165. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20166. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  20167. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20168. */
  20169. mirrorPlane: Plane;
  20170. /**
  20171. * Define the blur ratio used to blur the reflection if needed.
  20172. */
  20173. set blurRatio(value: number);
  20174. get blurRatio(): number;
  20175. /**
  20176. * Define the adaptive blur kernel used to blur the reflection if needed.
  20177. * This will autocompute the closest best match for the `blurKernel`
  20178. */
  20179. set adaptiveBlurKernel(value: number);
  20180. /**
  20181. * Define the blur kernel used to blur the reflection if needed.
  20182. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20183. */
  20184. set blurKernel(value: number);
  20185. /**
  20186. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20187. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20188. */
  20189. set blurKernelX(value: number);
  20190. get blurKernelX(): number;
  20191. /**
  20192. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20193. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20194. */
  20195. set blurKernelY(value: number);
  20196. get blurKernelY(): number;
  20197. private _autoComputeBlurKernel;
  20198. protected _onRatioRescale(): void;
  20199. private _updateGammaSpace;
  20200. private _imageProcessingConfigChangeObserver;
  20201. private _transformMatrix;
  20202. private _mirrorMatrix;
  20203. private _savedViewMatrix;
  20204. private _blurX;
  20205. private _blurY;
  20206. private _adaptiveBlurKernel;
  20207. private _blurKernelX;
  20208. private _blurKernelY;
  20209. private _blurRatio;
  20210. /**
  20211. * Instantiates a Mirror Texture.
  20212. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20213. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20214. * You can then easily use it as a reflectionTexture on a flat surface.
  20215. * In case the surface is not a plane, please consider relying on reflection probes.
  20216. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20217. * @param name
  20218. * @param size
  20219. * @param scene
  20220. * @param generateMipMaps
  20221. * @param type
  20222. * @param samplingMode
  20223. * @param generateDepthBuffer
  20224. */
  20225. constructor(name: string, size: number | {
  20226. width: number;
  20227. height: number;
  20228. } | {
  20229. ratio: number;
  20230. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20231. private _preparePostProcesses;
  20232. /**
  20233. * Clone the mirror texture.
  20234. * @returns the cloned texture
  20235. */
  20236. clone(): MirrorTexture;
  20237. /**
  20238. * Serialize the texture to a JSON representation you could use in Parse later on
  20239. * @returns the serialized JSON representation
  20240. */
  20241. serialize(): any;
  20242. /**
  20243. * Dispose the texture and release its associated resources.
  20244. */
  20245. dispose(): void;
  20246. }
  20247. }
  20248. declare module BABYLON {
  20249. /**
  20250. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20251. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20252. */
  20253. export class Texture extends BaseTexture {
  20254. /**
  20255. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20256. */
  20257. static SerializeBuffers: boolean;
  20258. /** @hidden */
  20259. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20260. /** @hidden */
  20261. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20262. /** @hidden */
  20263. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20264. /** nearest is mag = nearest and min = nearest and mip = linear */
  20265. static readonly NEAREST_SAMPLINGMODE: number;
  20266. /** nearest is mag = nearest and min = nearest and mip = linear */
  20267. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20268. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20269. static readonly BILINEAR_SAMPLINGMODE: number;
  20270. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20271. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20272. /** Trilinear is mag = linear and min = linear and mip = linear */
  20273. static readonly TRILINEAR_SAMPLINGMODE: number;
  20274. /** Trilinear is mag = linear and min = linear and mip = linear */
  20275. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20276. /** mag = nearest and min = nearest and mip = nearest */
  20277. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20278. /** mag = nearest and min = linear and mip = nearest */
  20279. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20280. /** mag = nearest and min = linear and mip = linear */
  20281. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20282. /** mag = nearest and min = linear and mip = none */
  20283. static readonly NEAREST_LINEAR: number;
  20284. /** mag = nearest and min = nearest and mip = none */
  20285. static readonly NEAREST_NEAREST: number;
  20286. /** mag = linear and min = nearest and mip = nearest */
  20287. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20288. /** mag = linear and min = nearest and mip = linear */
  20289. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20290. /** mag = linear and min = linear and mip = none */
  20291. static readonly LINEAR_LINEAR: number;
  20292. /** mag = linear and min = nearest and mip = none */
  20293. static readonly LINEAR_NEAREST: number;
  20294. /** Explicit coordinates mode */
  20295. static readonly EXPLICIT_MODE: number;
  20296. /** Spherical coordinates mode */
  20297. static readonly SPHERICAL_MODE: number;
  20298. /** Planar coordinates mode */
  20299. static readonly PLANAR_MODE: number;
  20300. /** Cubic coordinates mode */
  20301. static readonly CUBIC_MODE: number;
  20302. /** Projection coordinates mode */
  20303. static readonly PROJECTION_MODE: number;
  20304. /** Inverse Cubic coordinates mode */
  20305. static readonly SKYBOX_MODE: number;
  20306. /** Inverse Cubic coordinates mode */
  20307. static readonly INVCUBIC_MODE: number;
  20308. /** Equirectangular coordinates mode */
  20309. static readonly EQUIRECTANGULAR_MODE: number;
  20310. /** Equirectangular Fixed coordinates mode */
  20311. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20312. /** Equirectangular Fixed Mirrored coordinates mode */
  20313. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20314. /** Texture is not repeating outside of 0..1 UVs */
  20315. static readonly CLAMP_ADDRESSMODE: number;
  20316. /** Texture is repeating outside of 0..1 UVs */
  20317. static readonly WRAP_ADDRESSMODE: number;
  20318. /** Texture is repeating and mirrored */
  20319. static readonly MIRROR_ADDRESSMODE: number;
  20320. /**
  20321. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  20322. */
  20323. static UseSerializedUrlIfAny: boolean;
  20324. /**
  20325. * Define the url of the texture.
  20326. */
  20327. url: Nullable<string>;
  20328. /**
  20329. * Define an offset on the texture to offset the u coordinates of the UVs
  20330. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20331. */
  20332. uOffset: number;
  20333. /**
  20334. * Define an offset on the texture to offset the v coordinates of the UVs
  20335. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20336. */
  20337. vOffset: number;
  20338. /**
  20339. * Define an offset on the texture to scale the u coordinates of the UVs
  20340. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20341. */
  20342. uScale: number;
  20343. /**
  20344. * Define an offset on the texture to scale the v coordinates of the UVs
  20345. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20346. */
  20347. vScale: number;
  20348. /**
  20349. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20350. * @see http://doc.babylonjs.com/how_to/more_materials
  20351. */
  20352. uAng: number;
  20353. /**
  20354. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20355. * @see http://doc.babylonjs.com/how_to/more_materials
  20356. */
  20357. vAng: number;
  20358. /**
  20359. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20360. * @see http://doc.babylonjs.com/how_to/more_materials
  20361. */
  20362. wAng: number;
  20363. /**
  20364. * Defines the center of rotation (U)
  20365. */
  20366. uRotationCenter: number;
  20367. /**
  20368. * Defines the center of rotation (V)
  20369. */
  20370. vRotationCenter: number;
  20371. /**
  20372. * Defines the center of rotation (W)
  20373. */
  20374. wRotationCenter: number;
  20375. /**
  20376. * Are mip maps generated for this texture or not.
  20377. */
  20378. get noMipmap(): boolean;
  20379. /**
  20380. * List of inspectable custom properties (used by the Inspector)
  20381. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20382. */
  20383. inspectableCustomProperties: Nullable<IInspectable[]>;
  20384. private _noMipmap;
  20385. /** @hidden */
  20386. _invertY: boolean;
  20387. private _rowGenerationMatrix;
  20388. private _cachedTextureMatrix;
  20389. private _projectionModeMatrix;
  20390. private _t0;
  20391. private _t1;
  20392. private _t2;
  20393. private _cachedUOffset;
  20394. private _cachedVOffset;
  20395. private _cachedUScale;
  20396. private _cachedVScale;
  20397. private _cachedUAng;
  20398. private _cachedVAng;
  20399. private _cachedWAng;
  20400. private _cachedProjectionMatrixId;
  20401. private _cachedCoordinatesMode;
  20402. /** @hidden */
  20403. protected _initialSamplingMode: number;
  20404. /** @hidden */
  20405. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20406. private _deleteBuffer;
  20407. protected _format: Nullable<number>;
  20408. private _delayedOnLoad;
  20409. private _delayedOnError;
  20410. private _mimeType?;
  20411. /**
  20412. * Observable triggered once the texture has been loaded.
  20413. */
  20414. onLoadObservable: Observable<Texture>;
  20415. protected _isBlocking: boolean;
  20416. /**
  20417. * Is the texture preventing material to render while loading.
  20418. * If false, a default texture will be used instead of the loading one during the preparation step.
  20419. */
  20420. set isBlocking(value: boolean);
  20421. get isBlocking(): boolean;
  20422. /**
  20423. * Get the current sampling mode associated with the texture.
  20424. */
  20425. get samplingMode(): number;
  20426. /**
  20427. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20428. */
  20429. get invertY(): boolean;
  20430. /**
  20431. * Instantiates a new texture.
  20432. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20433. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20434. * @param url defines the url of the picture to load as a texture
  20435. * @param scene defines the scene or engine the texture will belong to
  20436. * @param noMipmap defines if the texture will require mip maps or not
  20437. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20438. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20439. * @param onLoad defines a callback triggered when the texture has been loaded
  20440. * @param onError defines a callback triggered when an error occurred during the loading session
  20441. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20442. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20443. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20444. * @param mimeType defines an optional mime type information
  20445. */
  20446. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  20447. /**
  20448. * Update the url (and optional buffer) of this texture if url was null during construction.
  20449. * @param url the url of the texture
  20450. * @param buffer the buffer of the texture (defaults to null)
  20451. * @param onLoad callback called when the texture is loaded (defaults to null)
  20452. */
  20453. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20454. /**
  20455. * Finish the loading sequence of a texture flagged as delayed load.
  20456. * @hidden
  20457. */
  20458. delayLoad(): void;
  20459. private _prepareRowForTextureGeneration;
  20460. /**
  20461. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20462. * @returns the transform matrix of the texture.
  20463. */
  20464. getTextureMatrix(uBase?: number): Matrix;
  20465. /**
  20466. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20467. * @returns The reflection texture transform
  20468. */
  20469. getReflectionTextureMatrix(): Matrix;
  20470. /**
  20471. * Clones the texture.
  20472. * @returns the cloned texture
  20473. */
  20474. clone(): Texture;
  20475. /**
  20476. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20477. * @returns The JSON representation of the texture
  20478. */
  20479. serialize(): any;
  20480. /**
  20481. * Get the current class name of the texture useful for serialization or dynamic coding.
  20482. * @returns "Texture"
  20483. */
  20484. getClassName(): string;
  20485. /**
  20486. * Dispose the texture and release its associated resources.
  20487. */
  20488. dispose(): void;
  20489. /**
  20490. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20491. * @param parsedTexture Define the JSON representation of the texture
  20492. * @param scene Define the scene the parsed texture should be instantiated in
  20493. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20494. * @returns The parsed texture if successful
  20495. */
  20496. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20497. /**
  20498. * Creates a texture from its base 64 representation.
  20499. * @param data Define the base64 payload without the data: prefix
  20500. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20501. * @param scene Define the scene the texture should belong to
  20502. * @param noMipmap Forces the texture to not create mip map information if true
  20503. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20504. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20505. * @param onLoad define a callback triggered when the texture has been loaded
  20506. * @param onError define a callback triggered when an error occurred during the loading session
  20507. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20508. * @returns the created texture
  20509. */
  20510. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20511. /**
  20512. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20513. * @param data Define the base64 payload without the data: prefix
  20514. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20515. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20516. * @param scene Define the scene the texture should belong to
  20517. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20518. * @param noMipmap Forces the texture to not create mip map information if true
  20519. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20520. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20521. * @param onLoad define a callback triggered when the texture has been loaded
  20522. * @param onError define a callback triggered when an error occurred during the loading session
  20523. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20524. * @returns the created texture
  20525. */
  20526. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  20527. }
  20528. }
  20529. declare module BABYLON {
  20530. /**
  20531. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20532. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20533. */
  20534. export class PostProcessManager {
  20535. private _scene;
  20536. private _indexBuffer;
  20537. private _vertexBuffers;
  20538. /**
  20539. * Creates a new instance PostProcess
  20540. * @param scene The scene that the post process is associated with.
  20541. */
  20542. constructor(scene: Scene);
  20543. private _prepareBuffers;
  20544. private _buildIndexBuffer;
  20545. /**
  20546. * Rebuilds the vertex buffers of the manager.
  20547. * @hidden
  20548. */
  20549. _rebuild(): void;
  20550. /**
  20551. * Prepares a frame to be run through a post process.
  20552. * @param sourceTexture The input texture to the post procesess. (default: null)
  20553. * @param postProcesses An array of post processes to be run. (default: null)
  20554. * @returns True if the post processes were able to be run.
  20555. * @hidden
  20556. */
  20557. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20558. /**
  20559. * Manually render a set of post processes to a texture.
  20560. * @param postProcesses An array of post processes to be run.
  20561. * @param targetTexture The target texture to render to.
  20562. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20563. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20564. * @param lodLevel defines which lod of the texture to render to
  20565. */
  20566. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20567. /**
  20568. * Finalize the result of the output of the postprocesses.
  20569. * @param doNotPresent If true the result will not be displayed to the screen.
  20570. * @param targetTexture The target texture to render to.
  20571. * @param faceIndex The index of the face to bind the target texture to.
  20572. * @param postProcesses The array of post processes to render.
  20573. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20574. * @hidden
  20575. */
  20576. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20577. /**
  20578. * Disposes of the post process manager.
  20579. */
  20580. dispose(): void;
  20581. }
  20582. }
  20583. declare module BABYLON {
  20584. /**
  20585. * This Helps creating a texture that will be created from a camera in your scene.
  20586. * It is basically a dynamic texture that could be used to create special effects for instance.
  20587. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20588. */
  20589. export class RenderTargetTexture extends Texture {
  20590. isCube: boolean;
  20591. /**
  20592. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20593. */
  20594. static readonly REFRESHRATE_RENDER_ONCE: number;
  20595. /**
  20596. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20597. */
  20598. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20599. /**
  20600. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20601. * the central point of your effect and can save a lot of performances.
  20602. */
  20603. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20604. /**
  20605. * Use this predicate to dynamically define the list of mesh you want to render.
  20606. * If set, the renderList property will be overwritten.
  20607. */
  20608. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20609. private _renderList;
  20610. /**
  20611. * Use this list to define the list of mesh you want to render.
  20612. */
  20613. get renderList(): Nullable<Array<AbstractMesh>>;
  20614. set renderList(value: Nullable<Array<AbstractMesh>>);
  20615. /**
  20616. * Use this function to overload the renderList array at rendering time.
  20617. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20618. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20619. * the cube (if the RTT is a cube, else layerOrFace=0).
  20620. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20621. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20622. * hold dummy elements!
  20623. */
  20624. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20625. private _hookArray;
  20626. /**
  20627. * Define if particles should be rendered in your texture.
  20628. */
  20629. renderParticles: boolean;
  20630. /**
  20631. * Define if sprites should be rendered in your texture.
  20632. */
  20633. renderSprites: boolean;
  20634. /**
  20635. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20636. */
  20637. coordinatesMode: number;
  20638. /**
  20639. * Define the camera used to render the texture.
  20640. */
  20641. activeCamera: Nullable<Camera>;
  20642. /**
  20643. * Override the mesh isReady function with your own one.
  20644. */
  20645. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20646. /**
  20647. * Override the render function of the texture with your own one.
  20648. */
  20649. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20650. /**
  20651. * Define if camera post processes should be use while rendering the texture.
  20652. */
  20653. useCameraPostProcesses: boolean;
  20654. /**
  20655. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20656. */
  20657. ignoreCameraViewport: boolean;
  20658. private _postProcessManager;
  20659. private _postProcesses;
  20660. private _resizeObserver;
  20661. /**
  20662. * An event triggered when the texture is unbind.
  20663. */
  20664. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20665. /**
  20666. * An event triggered when the texture is unbind.
  20667. */
  20668. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20669. private _onAfterUnbindObserver;
  20670. /**
  20671. * Set a after unbind callback in the texture.
  20672. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20673. */
  20674. set onAfterUnbind(callback: () => void);
  20675. /**
  20676. * An event triggered before rendering the texture
  20677. */
  20678. onBeforeRenderObservable: Observable<number>;
  20679. private _onBeforeRenderObserver;
  20680. /**
  20681. * Set a before render callback in the texture.
  20682. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20683. */
  20684. set onBeforeRender(callback: (faceIndex: number) => void);
  20685. /**
  20686. * An event triggered after rendering the texture
  20687. */
  20688. onAfterRenderObservable: Observable<number>;
  20689. private _onAfterRenderObserver;
  20690. /**
  20691. * Set a after render callback in the texture.
  20692. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20693. */
  20694. set onAfterRender(callback: (faceIndex: number) => void);
  20695. /**
  20696. * An event triggered after the texture clear
  20697. */
  20698. onClearObservable: Observable<Engine>;
  20699. private _onClearObserver;
  20700. /**
  20701. * Set a clear callback in the texture.
  20702. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20703. */
  20704. set onClear(callback: (Engine: Engine) => void);
  20705. /**
  20706. * An event triggered when the texture is resized.
  20707. */
  20708. onResizeObservable: Observable<RenderTargetTexture>;
  20709. /**
  20710. * Define the clear color of the Render Target if it should be different from the scene.
  20711. */
  20712. clearColor: Color4;
  20713. protected _size: number | {
  20714. width: number;
  20715. height: number;
  20716. layers?: number;
  20717. };
  20718. protected _initialSizeParameter: number | {
  20719. width: number;
  20720. height: number;
  20721. } | {
  20722. ratio: number;
  20723. };
  20724. protected _sizeRatio: Nullable<number>;
  20725. /** @hidden */
  20726. _generateMipMaps: boolean;
  20727. protected _renderingManager: RenderingManager;
  20728. /** @hidden */
  20729. _waitingRenderList: string[];
  20730. protected _doNotChangeAspectRatio: boolean;
  20731. protected _currentRefreshId: number;
  20732. protected _refreshRate: number;
  20733. protected _textureMatrix: Matrix;
  20734. protected _samples: number;
  20735. protected _renderTargetOptions: RenderTargetCreationOptions;
  20736. /**
  20737. * Gets render target creation options that were used.
  20738. */
  20739. get renderTargetOptions(): RenderTargetCreationOptions;
  20740. protected _engine: Engine;
  20741. protected _onRatioRescale(): void;
  20742. /**
  20743. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20744. * It must define where the camera used to render the texture is set
  20745. */
  20746. boundingBoxPosition: Vector3;
  20747. private _boundingBoxSize;
  20748. /**
  20749. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20750. * When defined, the cubemap will switch to local mode
  20751. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20752. * @example https://www.babylonjs-playground.com/#RNASML
  20753. */
  20754. set boundingBoxSize(value: Vector3);
  20755. get boundingBoxSize(): Vector3;
  20756. /**
  20757. * In case the RTT has been created with a depth texture, get the associated
  20758. * depth texture.
  20759. * Otherwise, return null.
  20760. */
  20761. get depthStencilTexture(): Nullable<InternalTexture>;
  20762. /**
  20763. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20764. * or used a shadow, depth texture...
  20765. * @param name The friendly name of the texture
  20766. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  20767. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20768. * @param generateMipMaps True if mip maps need to be generated after render.
  20769. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20770. * @param type The type of the buffer in the RTT (int, half float, float...)
  20771. * @param isCube True if a cube texture needs to be created
  20772. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20773. * @param generateDepthBuffer True to generate a depth buffer
  20774. * @param generateStencilBuffer True to generate a stencil buffer
  20775. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20776. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20777. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20778. */
  20779. constructor(name: string, size: number | {
  20780. width: number;
  20781. height: number;
  20782. layers?: number;
  20783. } | {
  20784. ratio: number;
  20785. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20786. /**
  20787. * Creates a depth stencil texture.
  20788. * This is only available in WebGL 2 or with the depth texture extension available.
  20789. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20790. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20791. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20792. */
  20793. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20794. private _processSizeParameter;
  20795. /**
  20796. * Define the number of samples to use in case of MSAA.
  20797. * It defaults to one meaning no MSAA has been enabled.
  20798. */
  20799. get samples(): number;
  20800. set samples(value: number);
  20801. /**
  20802. * Resets the refresh counter of the texture and start bak from scratch.
  20803. * Could be useful to regenerate the texture if it is setup to render only once.
  20804. */
  20805. resetRefreshCounter(): void;
  20806. /**
  20807. * Define the refresh rate of the texture or the rendering frequency.
  20808. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20809. */
  20810. get refreshRate(): number;
  20811. set refreshRate(value: number);
  20812. /**
  20813. * Adds a post process to the render target rendering passes.
  20814. * @param postProcess define the post process to add
  20815. */
  20816. addPostProcess(postProcess: PostProcess): void;
  20817. /**
  20818. * Clear all the post processes attached to the render target
  20819. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20820. */
  20821. clearPostProcesses(dispose?: boolean): void;
  20822. /**
  20823. * Remove one of the post process from the list of attached post processes to the texture
  20824. * @param postProcess define the post process to remove from the list
  20825. */
  20826. removePostProcess(postProcess: PostProcess): void;
  20827. /** @hidden */
  20828. _shouldRender(): boolean;
  20829. /**
  20830. * Gets the actual render size of the texture.
  20831. * @returns the width of the render size
  20832. */
  20833. getRenderSize(): number;
  20834. /**
  20835. * Gets the actual render width of the texture.
  20836. * @returns the width of the render size
  20837. */
  20838. getRenderWidth(): number;
  20839. /**
  20840. * Gets the actual render height of the texture.
  20841. * @returns the height of the render size
  20842. */
  20843. getRenderHeight(): number;
  20844. /**
  20845. * Gets the actual number of layers of the texture.
  20846. * @returns the number of layers
  20847. */
  20848. getRenderLayers(): number;
  20849. /**
  20850. * Get if the texture can be rescaled or not.
  20851. */
  20852. get canRescale(): boolean;
  20853. /**
  20854. * Resize the texture using a ratio.
  20855. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20856. */
  20857. scale(ratio: number): void;
  20858. /**
  20859. * Get the texture reflection matrix used to rotate/transform the reflection.
  20860. * @returns the reflection matrix
  20861. */
  20862. getReflectionTextureMatrix(): Matrix;
  20863. /**
  20864. * Resize the texture to a new desired size.
  20865. * Be carrefull as it will recreate all the data in the new texture.
  20866. * @param size Define the new size. It can be:
  20867. * - a number for squared texture,
  20868. * - an object containing { width: number, height: number }
  20869. * - or an object containing a ratio { ratio: number }
  20870. */
  20871. resize(size: number | {
  20872. width: number;
  20873. height: number;
  20874. } | {
  20875. ratio: number;
  20876. }): void;
  20877. private _defaultRenderListPrepared;
  20878. /**
  20879. * Renders all the objects from the render list into the texture.
  20880. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20881. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20882. */
  20883. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20884. private _bestReflectionRenderTargetDimension;
  20885. private _prepareRenderingManager;
  20886. /**
  20887. * @hidden
  20888. * @param faceIndex face index to bind to if this is a cubetexture
  20889. * @param layer defines the index of the texture to bind in the array
  20890. */
  20891. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20892. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20893. private renderToTarget;
  20894. /**
  20895. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20896. * This allowed control for front to back rendering or reversly depending of the special needs.
  20897. *
  20898. * @param renderingGroupId The rendering group id corresponding to its index
  20899. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20900. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20901. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20902. */
  20903. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20904. /**
  20905. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20906. *
  20907. * @param renderingGroupId The rendering group id corresponding to its index
  20908. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20909. */
  20910. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20911. /**
  20912. * Clones the texture.
  20913. * @returns the cloned texture
  20914. */
  20915. clone(): RenderTargetTexture;
  20916. /**
  20917. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20918. * @returns The JSON representation of the texture
  20919. */
  20920. serialize(): any;
  20921. /**
  20922. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20923. */
  20924. disposeFramebufferObjects(): void;
  20925. /**
  20926. * Dispose the texture and release its associated resources.
  20927. */
  20928. dispose(): void;
  20929. /** @hidden */
  20930. _rebuild(): void;
  20931. /**
  20932. * Clear the info related to rendering groups preventing retention point in material dispose.
  20933. */
  20934. freeRenderingGroups(): void;
  20935. /**
  20936. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20937. * @returns the view count
  20938. */
  20939. getViewCount(): number;
  20940. }
  20941. }
  20942. declare module BABYLON {
  20943. /**
  20944. * Options for compiling materials.
  20945. */
  20946. export interface IMaterialCompilationOptions {
  20947. /**
  20948. * Defines whether clip planes are enabled.
  20949. */
  20950. clipPlane: boolean;
  20951. /**
  20952. * Defines whether instances are enabled.
  20953. */
  20954. useInstances: boolean;
  20955. }
  20956. /**
  20957. * Base class for the main features of a material in Babylon.js
  20958. */
  20959. export class Material implements IAnimatable {
  20960. /**
  20961. * Returns the triangle fill mode
  20962. */
  20963. static readonly TriangleFillMode: number;
  20964. /**
  20965. * Returns the wireframe mode
  20966. */
  20967. static readonly WireFrameFillMode: number;
  20968. /**
  20969. * Returns the point fill mode
  20970. */
  20971. static readonly PointFillMode: number;
  20972. /**
  20973. * Returns the point list draw mode
  20974. */
  20975. static readonly PointListDrawMode: number;
  20976. /**
  20977. * Returns the line list draw mode
  20978. */
  20979. static readonly LineListDrawMode: number;
  20980. /**
  20981. * Returns the line loop draw mode
  20982. */
  20983. static readonly LineLoopDrawMode: number;
  20984. /**
  20985. * Returns the line strip draw mode
  20986. */
  20987. static readonly LineStripDrawMode: number;
  20988. /**
  20989. * Returns the triangle strip draw mode
  20990. */
  20991. static readonly TriangleStripDrawMode: number;
  20992. /**
  20993. * Returns the triangle fan draw mode
  20994. */
  20995. static readonly TriangleFanDrawMode: number;
  20996. /**
  20997. * Stores the clock-wise side orientation
  20998. */
  20999. static readonly ClockWiseSideOrientation: number;
  21000. /**
  21001. * Stores the counter clock-wise side orientation
  21002. */
  21003. static readonly CounterClockWiseSideOrientation: number;
  21004. /**
  21005. * The dirty texture flag value
  21006. */
  21007. static readonly TextureDirtyFlag: number;
  21008. /**
  21009. * The dirty light flag value
  21010. */
  21011. static readonly LightDirtyFlag: number;
  21012. /**
  21013. * The dirty fresnel flag value
  21014. */
  21015. static readonly FresnelDirtyFlag: number;
  21016. /**
  21017. * The dirty attribute flag value
  21018. */
  21019. static readonly AttributesDirtyFlag: number;
  21020. /**
  21021. * The dirty misc flag value
  21022. */
  21023. static readonly MiscDirtyFlag: number;
  21024. /**
  21025. * The all dirty flag value
  21026. */
  21027. static readonly AllDirtyFlag: number;
  21028. /**
  21029. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21030. */
  21031. static readonly MATERIAL_OPAQUE: number;
  21032. /**
  21033. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21034. */
  21035. static readonly MATERIAL_ALPHATEST: number;
  21036. /**
  21037. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21038. */
  21039. static readonly MATERIAL_ALPHABLEND: number;
  21040. /**
  21041. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21042. * They are also discarded below the alpha cutoff threshold to improve performances.
  21043. */
  21044. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21045. /**
  21046. * The ID of the material
  21047. */
  21048. id: string;
  21049. /**
  21050. * Gets or sets the unique id of the material
  21051. */
  21052. uniqueId: number;
  21053. /**
  21054. * The name of the material
  21055. */
  21056. name: string;
  21057. /**
  21058. * Gets or sets user defined metadata
  21059. */
  21060. metadata: any;
  21061. /**
  21062. * For internal use only. Please do not use.
  21063. */
  21064. reservedDataStore: any;
  21065. /**
  21066. * Specifies if the ready state should be checked on each call
  21067. */
  21068. checkReadyOnEveryCall: boolean;
  21069. /**
  21070. * Specifies if the ready state should be checked once
  21071. */
  21072. checkReadyOnlyOnce: boolean;
  21073. /**
  21074. * The state of the material
  21075. */
  21076. state: string;
  21077. /**
  21078. * The alpha value of the material
  21079. */
  21080. protected _alpha: number;
  21081. /**
  21082. * List of inspectable custom properties (used by the Inspector)
  21083. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21084. */
  21085. inspectableCustomProperties: IInspectable[];
  21086. /**
  21087. * Sets the alpha value of the material
  21088. */
  21089. set alpha(value: number);
  21090. /**
  21091. * Gets the alpha value of the material
  21092. */
  21093. get alpha(): number;
  21094. /**
  21095. * Specifies if back face culling is enabled
  21096. */
  21097. protected _backFaceCulling: boolean;
  21098. /**
  21099. * Sets the back-face culling state
  21100. */
  21101. set backFaceCulling(value: boolean);
  21102. /**
  21103. * Gets the back-face culling state
  21104. */
  21105. get backFaceCulling(): boolean;
  21106. /**
  21107. * Stores the value for side orientation
  21108. */
  21109. sideOrientation: number;
  21110. /**
  21111. * Callback triggered when the material is compiled
  21112. */
  21113. onCompiled: Nullable<(effect: Effect) => void>;
  21114. /**
  21115. * Callback triggered when an error occurs
  21116. */
  21117. onError: Nullable<(effect: Effect, errors: string) => void>;
  21118. /**
  21119. * Callback triggered to get the render target textures
  21120. */
  21121. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21122. /**
  21123. * Gets a boolean indicating that current material needs to register RTT
  21124. */
  21125. get hasRenderTargetTextures(): boolean;
  21126. /**
  21127. * Specifies if the material should be serialized
  21128. */
  21129. doNotSerialize: boolean;
  21130. /**
  21131. * @hidden
  21132. */
  21133. _storeEffectOnSubMeshes: boolean;
  21134. /**
  21135. * Stores the animations for the material
  21136. */
  21137. animations: Nullable<Array<Animation>>;
  21138. /**
  21139. * An event triggered when the material is disposed
  21140. */
  21141. onDisposeObservable: Observable<Material>;
  21142. /**
  21143. * An observer which watches for dispose events
  21144. */
  21145. private _onDisposeObserver;
  21146. private _onUnBindObservable;
  21147. /**
  21148. * Called during a dispose event
  21149. */
  21150. set onDispose(callback: () => void);
  21151. private _onBindObservable;
  21152. /**
  21153. * An event triggered when the material is bound
  21154. */
  21155. get onBindObservable(): Observable<AbstractMesh>;
  21156. /**
  21157. * An observer which watches for bind events
  21158. */
  21159. private _onBindObserver;
  21160. /**
  21161. * Called during a bind event
  21162. */
  21163. set onBind(callback: (Mesh: AbstractMesh) => void);
  21164. /**
  21165. * An event triggered when the material is unbound
  21166. */
  21167. get onUnBindObservable(): Observable<Material>;
  21168. /**
  21169. * Stores the value of the alpha mode
  21170. */
  21171. private _alphaMode;
  21172. /**
  21173. * Sets the value of the alpha mode.
  21174. *
  21175. * | Value | Type | Description |
  21176. * | --- | --- | --- |
  21177. * | 0 | ALPHA_DISABLE | |
  21178. * | 1 | ALPHA_ADD | |
  21179. * | 2 | ALPHA_COMBINE | |
  21180. * | 3 | ALPHA_SUBTRACT | |
  21181. * | 4 | ALPHA_MULTIPLY | |
  21182. * | 5 | ALPHA_MAXIMIZED | |
  21183. * | 6 | ALPHA_ONEONE | |
  21184. * | 7 | ALPHA_PREMULTIPLIED | |
  21185. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21186. * | 9 | ALPHA_INTERPOLATE | |
  21187. * | 10 | ALPHA_SCREENMODE | |
  21188. *
  21189. */
  21190. set alphaMode(value: number);
  21191. /**
  21192. * Gets the value of the alpha mode
  21193. */
  21194. get alphaMode(): number;
  21195. /**
  21196. * Stores the state of the need depth pre-pass value
  21197. */
  21198. private _needDepthPrePass;
  21199. /**
  21200. * Sets the need depth pre-pass value
  21201. */
  21202. set needDepthPrePass(value: boolean);
  21203. /**
  21204. * Gets the depth pre-pass value
  21205. */
  21206. get needDepthPrePass(): boolean;
  21207. /**
  21208. * Specifies if depth writing should be disabled
  21209. */
  21210. disableDepthWrite: boolean;
  21211. /**
  21212. * Specifies if depth writing should be forced
  21213. */
  21214. forceDepthWrite: boolean;
  21215. /**
  21216. * Specifies the depth function that should be used. 0 means the default engine function
  21217. */
  21218. depthFunction: number;
  21219. /**
  21220. * Specifies if there should be a separate pass for culling
  21221. */
  21222. separateCullingPass: boolean;
  21223. /**
  21224. * Stores the state specifing if fog should be enabled
  21225. */
  21226. private _fogEnabled;
  21227. /**
  21228. * Sets the state for enabling fog
  21229. */
  21230. set fogEnabled(value: boolean);
  21231. /**
  21232. * Gets the value of the fog enabled state
  21233. */
  21234. get fogEnabled(): boolean;
  21235. /**
  21236. * Stores the size of points
  21237. */
  21238. pointSize: number;
  21239. /**
  21240. * Stores the z offset value
  21241. */
  21242. zOffset: number;
  21243. /**
  21244. * Gets a value specifying if wireframe mode is enabled
  21245. */
  21246. get wireframe(): boolean;
  21247. /**
  21248. * Sets the state of wireframe mode
  21249. */
  21250. set wireframe(value: boolean);
  21251. /**
  21252. * Gets the value specifying if point clouds are enabled
  21253. */
  21254. get pointsCloud(): boolean;
  21255. /**
  21256. * Sets the state of point cloud mode
  21257. */
  21258. set pointsCloud(value: boolean);
  21259. /**
  21260. * Gets the material fill mode
  21261. */
  21262. get fillMode(): number;
  21263. /**
  21264. * Sets the material fill mode
  21265. */
  21266. set fillMode(value: number);
  21267. /**
  21268. * @hidden
  21269. * Stores the effects for the material
  21270. */
  21271. _effect: Nullable<Effect>;
  21272. /**
  21273. * Specifies if uniform buffers should be used
  21274. */
  21275. private _useUBO;
  21276. /**
  21277. * Stores a reference to the scene
  21278. */
  21279. private _scene;
  21280. /**
  21281. * Stores the fill mode state
  21282. */
  21283. private _fillMode;
  21284. /**
  21285. * Specifies if the depth write state should be cached
  21286. */
  21287. private _cachedDepthWriteState;
  21288. /**
  21289. * Specifies if the depth function state should be cached
  21290. */
  21291. private _cachedDepthFunctionState;
  21292. /**
  21293. * Stores the uniform buffer
  21294. */
  21295. protected _uniformBuffer: UniformBuffer;
  21296. /** @hidden */
  21297. _indexInSceneMaterialArray: number;
  21298. /** @hidden */
  21299. meshMap: Nullable<{
  21300. [id: string]: AbstractMesh | undefined;
  21301. }>;
  21302. /**
  21303. * Creates a material instance
  21304. * @param name defines the name of the material
  21305. * @param scene defines the scene to reference
  21306. * @param doNotAdd specifies if the material should be added to the scene
  21307. */
  21308. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21309. /**
  21310. * Returns a string representation of the current material
  21311. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21312. * @returns a string with material information
  21313. */
  21314. toString(fullDetails?: boolean): string;
  21315. /**
  21316. * Gets the class name of the material
  21317. * @returns a string with the class name of the material
  21318. */
  21319. getClassName(): string;
  21320. /**
  21321. * Specifies if updates for the material been locked
  21322. */
  21323. get isFrozen(): boolean;
  21324. /**
  21325. * Locks updates for the material
  21326. */
  21327. freeze(): void;
  21328. /**
  21329. * Unlocks updates for the material
  21330. */
  21331. unfreeze(): void;
  21332. /**
  21333. * Specifies if the material is ready to be used
  21334. * @param mesh defines the mesh to check
  21335. * @param useInstances specifies if instances should be used
  21336. * @returns a boolean indicating if the material is ready to be used
  21337. */
  21338. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21339. /**
  21340. * Specifies that the submesh is ready to be used
  21341. * @param mesh defines the mesh to check
  21342. * @param subMesh defines which submesh to check
  21343. * @param useInstances specifies that instances should be used
  21344. * @returns a boolean indicating that the submesh is ready or not
  21345. */
  21346. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21347. /**
  21348. * Returns the material effect
  21349. * @returns the effect associated with the material
  21350. */
  21351. getEffect(): Nullable<Effect>;
  21352. /**
  21353. * Returns the current scene
  21354. * @returns a Scene
  21355. */
  21356. getScene(): Scene;
  21357. /**
  21358. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21359. */
  21360. protected _forceAlphaTest: boolean;
  21361. /**
  21362. * The transparency mode of the material.
  21363. */
  21364. protected _transparencyMode: Nullable<number>;
  21365. /**
  21366. * Gets the current transparency mode.
  21367. */
  21368. get transparencyMode(): Nullable<number>;
  21369. /**
  21370. * Sets the transparency mode of the material.
  21371. *
  21372. * | Value | Type | Description |
  21373. * | ----- | ----------------------------------- | ----------- |
  21374. * | 0 | OPAQUE | |
  21375. * | 1 | ALPHATEST | |
  21376. * | 2 | ALPHABLEND | |
  21377. * | 3 | ALPHATESTANDBLEND | |
  21378. *
  21379. */
  21380. set transparencyMode(value: Nullable<number>);
  21381. /**
  21382. * Returns true if alpha blending should be disabled.
  21383. */
  21384. protected get _disableAlphaBlending(): boolean;
  21385. /**
  21386. * Specifies whether or not this material should be rendered in alpha blend mode.
  21387. * @returns a boolean specifying if alpha blending is needed
  21388. */
  21389. needAlphaBlending(): boolean;
  21390. /**
  21391. * Specifies if the mesh will require alpha blending
  21392. * @param mesh defines the mesh to check
  21393. * @returns a boolean specifying if alpha blending is needed for the mesh
  21394. */
  21395. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21396. /**
  21397. * Specifies whether or not this material should be rendered in alpha test mode.
  21398. * @returns a boolean specifying if an alpha test is needed.
  21399. */
  21400. needAlphaTesting(): boolean;
  21401. /**
  21402. * Specifies if material alpha testing should be turned on for the mesh
  21403. * @param mesh defines the mesh to check
  21404. */
  21405. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21406. /**
  21407. * Gets the texture used for the alpha test
  21408. * @returns the texture to use for alpha testing
  21409. */
  21410. getAlphaTestTexture(): Nullable<BaseTexture>;
  21411. /**
  21412. * Marks the material to indicate that it needs to be re-calculated
  21413. */
  21414. markDirty(): void;
  21415. /** @hidden */
  21416. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21417. /**
  21418. * Binds the material to the mesh
  21419. * @param world defines the world transformation matrix
  21420. * @param mesh defines the mesh to bind the material to
  21421. */
  21422. bind(world: Matrix, mesh?: Mesh): void;
  21423. /**
  21424. * Binds the submesh to the material
  21425. * @param world defines the world transformation matrix
  21426. * @param mesh defines the mesh containing the submesh
  21427. * @param subMesh defines the submesh to bind the material to
  21428. */
  21429. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21430. /**
  21431. * Binds the world matrix to the material
  21432. * @param world defines the world transformation matrix
  21433. */
  21434. bindOnlyWorldMatrix(world: Matrix): void;
  21435. /**
  21436. * Binds the scene's uniform buffer to the effect.
  21437. * @param effect defines the effect to bind to the scene uniform buffer
  21438. * @param sceneUbo defines the uniform buffer storing scene data
  21439. */
  21440. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21441. /**
  21442. * Binds the view matrix to the effect
  21443. * @param effect defines the effect to bind the view matrix to
  21444. */
  21445. bindView(effect: Effect): void;
  21446. /**
  21447. * Binds the view projection matrix to the effect
  21448. * @param effect defines the effect to bind the view projection matrix to
  21449. */
  21450. bindViewProjection(effect: Effect): void;
  21451. /**
  21452. * Processes to execute after binding the material to a mesh
  21453. * @param mesh defines the rendered mesh
  21454. */
  21455. protected _afterBind(mesh?: Mesh): void;
  21456. /**
  21457. * Unbinds the material from the mesh
  21458. */
  21459. unbind(): void;
  21460. /**
  21461. * Gets the active textures from the material
  21462. * @returns an array of textures
  21463. */
  21464. getActiveTextures(): BaseTexture[];
  21465. /**
  21466. * Specifies if the material uses a texture
  21467. * @param texture defines the texture to check against the material
  21468. * @returns a boolean specifying if the material uses the texture
  21469. */
  21470. hasTexture(texture: BaseTexture): boolean;
  21471. /**
  21472. * Makes a duplicate of the material, and gives it a new name
  21473. * @param name defines the new name for the duplicated material
  21474. * @returns the cloned material
  21475. */
  21476. clone(name: string): Nullable<Material>;
  21477. /**
  21478. * Gets the meshes bound to the material
  21479. * @returns an array of meshes bound to the material
  21480. */
  21481. getBindedMeshes(): AbstractMesh[];
  21482. /**
  21483. * Force shader compilation
  21484. * @param mesh defines the mesh associated with this material
  21485. * @param onCompiled defines a function to execute once the material is compiled
  21486. * @param options defines the options to configure the compilation
  21487. * @param onError defines a function to execute if the material fails compiling
  21488. */
  21489. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21490. /**
  21491. * Force shader compilation
  21492. * @param mesh defines the mesh that will use this material
  21493. * @param options defines additional options for compiling the shaders
  21494. * @returns a promise that resolves when the compilation completes
  21495. */
  21496. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21497. private static readonly _AllDirtyCallBack;
  21498. private static readonly _ImageProcessingDirtyCallBack;
  21499. private static readonly _TextureDirtyCallBack;
  21500. private static readonly _FresnelDirtyCallBack;
  21501. private static readonly _MiscDirtyCallBack;
  21502. private static readonly _LightsDirtyCallBack;
  21503. private static readonly _AttributeDirtyCallBack;
  21504. private static _FresnelAndMiscDirtyCallBack;
  21505. private static _TextureAndMiscDirtyCallBack;
  21506. private static readonly _DirtyCallbackArray;
  21507. private static readonly _RunDirtyCallBacks;
  21508. /**
  21509. * Marks a define in the material to indicate that it needs to be re-computed
  21510. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21511. */
  21512. markAsDirty(flag: number): void;
  21513. /**
  21514. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21515. * @param func defines a function which checks material defines against the submeshes
  21516. */
  21517. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21518. /**
  21519. * Indicates that we need to re-calculated for all submeshes
  21520. */
  21521. protected _markAllSubMeshesAsAllDirty(): void;
  21522. /**
  21523. * Indicates that image processing needs to be re-calculated for all submeshes
  21524. */
  21525. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21526. /**
  21527. * Indicates that textures need to be re-calculated for all submeshes
  21528. */
  21529. protected _markAllSubMeshesAsTexturesDirty(): void;
  21530. /**
  21531. * Indicates that fresnel needs to be re-calculated for all submeshes
  21532. */
  21533. protected _markAllSubMeshesAsFresnelDirty(): void;
  21534. /**
  21535. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21536. */
  21537. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21538. /**
  21539. * Indicates that lights need to be re-calculated for all submeshes
  21540. */
  21541. protected _markAllSubMeshesAsLightsDirty(): void;
  21542. /**
  21543. * Indicates that attributes need to be re-calculated for all submeshes
  21544. */
  21545. protected _markAllSubMeshesAsAttributesDirty(): void;
  21546. /**
  21547. * Indicates that misc needs to be re-calculated for all submeshes
  21548. */
  21549. protected _markAllSubMeshesAsMiscDirty(): void;
  21550. /**
  21551. * Indicates that textures and misc need to be re-calculated for all submeshes
  21552. */
  21553. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21554. /**
  21555. * Disposes the material
  21556. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21557. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21558. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21559. */
  21560. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21561. /** @hidden */
  21562. private releaseVertexArrayObject;
  21563. /**
  21564. * Serializes this material
  21565. * @returns the serialized material object
  21566. */
  21567. serialize(): any;
  21568. /**
  21569. * Creates a material from parsed material data
  21570. * @param parsedMaterial defines parsed material data
  21571. * @param scene defines the hosting scene
  21572. * @param rootUrl defines the root URL to use to load textures
  21573. * @returns a new material
  21574. */
  21575. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21576. }
  21577. }
  21578. declare module BABYLON {
  21579. /**
  21580. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21581. * separate meshes. This can be use to improve performances.
  21582. * @see http://doc.babylonjs.com/how_to/multi_materials
  21583. */
  21584. export class MultiMaterial extends Material {
  21585. private _subMaterials;
  21586. /**
  21587. * Gets or Sets the list of Materials used within the multi material.
  21588. * They need to be ordered according to the submeshes order in the associated mesh
  21589. */
  21590. get subMaterials(): Nullable<Material>[];
  21591. set subMaterials(value: Nullable<Material>[]);
  21592. /**
  21593. * Function used to align with Node.getChildren()
  21594. * @returns the list of Materials used within the multi material
  21595. */
  21596. getChildren(): Nullable<Material>[];
  21597. /**
  21598. * Instantiates a new Multi Material
  21599. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21600. * separate meshes. This can be use to improve performances.
  21601. * @see http://doc.babylonjs.com/how_to/multi_materials
  21602. * @param name Define the name in the scene
  21603. * @param scene Define the scene the material belongs to
  21604. */
  21605. constructor(name: string, scene: Scene);
  21606. private _hookArray;
  21607. /**
  21608. * Get one of the submaterial by its index in the submaterials array
  21609. * @param index The index to look the sub material at
  21610. * @returns The Material if the index has been defined
  21611. */
  21612. getSubMaterial(index: number): Nullable<Material>;
  21613. /**
  21614. * Get the list of active textures for the whole sub materials list.
  21615. * @returns All the textures that will be used during the rendering
  21616. */
  21617. getActiveTextures(): BaseTexture[];
  21618. /**
  21619. * Gets the current class name of the material e.g. "MultiMaterial"
  21620. * Mainly use in serialization.
  21621. * @returns the class name
  21622. */
  21623. getClassName(): string;
  21624. /**
  21625. * Checks if the material is ready to render the requested sub mesh
  21626. * @param mesh Define the mesh the submesh belongs to
  21627. * @param subMesh Define the sub mesh to look readyness for
  21628. * @param useInstances Define whether or not the material is used with instances
  21629. * @returns true if ready, otherwise false
  21630. */
  21631. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21632. /**
  21633. * Clones the current material and its related sub materials
  21634. * @param name Define the name of the newly cloned material
  21635. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21636. * @returns the cloned material
  21637. */
  21638. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21639. /**
  21640. * Serializes the materials into a JSON representation.
  21641. * @returns the JSON representation
  21642. */
  21643. serialize(): any;
  21644. /**
  21645. * Dispose the material and release its associated resources
  21646. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  21647. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  21648. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21649. */
  21650. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21651. /**
  21652. * Creates a MultiMaterial from parsed MultiMaterial data.
  21653. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21654. * @param scene defines the hosting scene
  21655. * @returns a new MultiMaterial
  21656. */
  21657. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21658. }
  21659. }
  21660. declare module BABYLON {
  21661. /**
  21662. * Base class for submeshes
  21663. */
  21664. export class BaseSubMesh {
  21665. /** @hidden */
  21666. _materialDefines: Nullable<MaterialDefines>;
  21667. /** @hidden */
  21668. _materialEffect: Nullable<Effect>;
  21669. /**
  21670. * Gets material defines used by the effect associated to the sub mesh
  21671. */
  21672. get materialDefines(): Nullable<MaterialDefines>;
  21673. /**
  21674. * Sets material defines used by the effect associated to the sub mesh
  21675. */
  21676. set materialDefines(defines: Nullable<MaterialDefines>);
  21677. /**
  21678. * Gets associated effect
  21679. */
  21680. get effect(): Nullable<Effect>;
  21681. /**
  21682. * Sets associated effect (effect used to render this submesh)
  21683. * @param effect defines the effect to associate with
  21684. * @param defines defines the set of defines used to compile this effect
  21685. */
  21686. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21687. }
  21688. /**
  21689. * Defines a subdivision inside a mesh
  21690. */
  21691. export class SubMesh extends BaseSubMesh implements ICullable {
  21692. /** the material index to use */
  21693. materialIndex: number;
  21694. /** vertex index start */
  21695. verticesStart: number;
  21696. /** vertices count */
  21697. verticesCount: number;
  21698. /** index start */
  21699. indexStart: number;
  21700. /** indices count */
  21701. indexCount: number;
  21702. /** @hidden */
  21703. _linesIndexCount: number;
  21704. private _mesh;
  21705. private _renderingMesh;
  21706. private _boundingInfo;
  21707. private _linesIndexBuffer;
  21708. /** @hidden */
  21709. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21710. /** @hidden */
  21711. _trianglePlanes: Plane[];
  21712. /** @hidden */
  21713. _lastColliderTransformMatrix: Nullable<Matrix>;
  21714. /** @hidden */
  21715. _renderId: number;
  21716. /** @hidden */
  21717. _alphaIndex: number;
  21718. /** @hidden */
  21719. _distanceToCamera: number;
  21720. /** @hidden */
  21721. _id: number;
  21722. private _currentMaterial;
  21723. /**
  21724. * Add a new submesh to a mesh
  21725. * @param materialIndex defines the material index to use
  21726. * @param verticesStart defines vertex index start
  21727. * @param verticesCount defines vertices count
  21728. * @param indexStart defines index start
  21729. * @param indexCount defines indices count
  21730. * @param mesh defines the parent mesh
  21731. * @param renderingMesh defines an optional rendering mesh
  21732. * @param createBoundingBox defines if bounding box should be created for this submesh
  21733. * @returns the new submesh
  21734. */
  21735. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21736. /**
  21737. * Creates a new submesh
  21738. * @param materialIndex defines the material index to use
  21739. * @param verticesStart defines vertex index start
  21740. * @param verticesCount defines vertices count
  21741. * @param indexStart defines index start
  21742. * @param indexCount defines indices count
  21743. * @param mesh defines the parent mesh
  21744. * @param renderingMesh defines an optional rendering mesh
  21745. * @param createBoundingBox defines if bounding box should be created for this submesh
  21746. */
  21747. constructor(
  21748. /** the material index to use */
  21749. materialIndex: number,
  21750. /** vertex index start */
  21751. verticesStart: number,
  21752. /** vertices count */
  21753. verticesCount: number,
  21754. /** index start */
  21755. indexStart: number,
  21756. /** indices count */
  21757. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21758. /**
  21759. * Returns true if this submesh covers the entire parent mesh
  21760. * @ignorenaming
  21761. */
  21762. get IsGlobal(): boolean;
  21763. /**
  21764. * Returns the submesh BoudingInfo object
  21765. * @returns current bounding info (or mesh's one if the submesh is global)
  21766. */
  21767. getBoundingInfo(): BoundingInfo;
  21768. /**
  21769. * Sets the submesh BoundingInfo
  21770. * @param boundingInfo defines the new bounding info to use
  21771. * @returns the SubMesh
  21772. */
  21773. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21774. /**
  21775. * Returns the mesh of the current submesh
  21776. * @return the parent mesh
  21777. */
  21778. getMesh(): AbstractMesh;
  21779. /**
  21780. * Returns the rendering mesh of the submesh
  21781. * @returns the rendering mesh (could be different from parent mesh)
  21782. */
  21783. getRenderingMesh(): Mesh;
  21784. /**
  21785. * Returns the submesh material
  21786. * @returns null or the current material
  21787. */
  21788. getMaterial(): Nullable<Material>;
  21789. /**
  21790. * Sets a new updated BoundingInfo object to the submesh
  21791. * @param data defines an optional position array to use to determine the bounding info
  21792. * @returns the SubMesh
  21793. */
  21794. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21795. /** @hidden */
  21796. _checkCollision(collider: Collider): boolean;
  21797. /**
  21798. * Updates the submesh BoundingInfo
  21799. * @param world defines the world matrix to use to update the bounding info
  21800. * @returns the submesh
  21801. */
  21802. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21803. /**
  21804. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21805. * @param frustumPlanes defines the frustum planes
  21806. * @returns true if the submesh is intersecting with the frustum
  21807. */
  21808. isInFrustum(frustumPlanes: Plane[]): boolean;
  21809. /**
  21810. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21811. * @param frustumPlanes defines the frustum planes
  21812. * @returns true if the submesh is inside the frustum
  21813. */
  21814. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21815. /**
  21816. * Renders the submesh
  21817. * @param enableAlphaMode defines if alpha needs to be used
  21818. * @returns the submesh
  21819. */
  21820. render(enableAlphaMode: boolean): SubMesh;
  21821. /**
  21822. * @hidden
  21823. */
  21824. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21825. /**
  21826. * Checks if the submesh intersects with a ray
  21827. * @param ray defines the ray to test
  21828. * @returns true is the passed ray intersects the submesh bounding box
  21829. */
  21830. canIntersects(ray: Ray): boolean;
  21831. /**
  21832. * Intersects current submesh with a ray
  21833. * @param ray defines the ray to test
  21834. * @param positions defines mesh's positions array
  21835. * @param indices defines mesh's indices array
  21836. * @param fastCheck defines if only bounding info should be used
  21837. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21838. * @returns intersection info or null if no intersection
  21839. */
  21840. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21841. /** @hidden */
  21842. private _intersectLines;
  21843. /** @hidden */
  21844. private _intersectUnIndexedLines;
  21845. /** @hidden */
  21846. private _intersectTriangles;
  21847. /** @hidden */
  21848. private _intersectUnIndexedTriangles;
  21849. /** @hidden */
  21850. _rebuild(): void;
  21851. /**
  21852. * Creates a new submesh from the passed mesh
  21853. * @param newMesh defines the new hosting mesh
  21854. * @param newRenderingMesh defines an optional rendering mesh
  21855. * @returns the new submesh
  21856. */
  21857. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21858. /**
  21859. * Release associated resources
  21860. */
  21861. dispose(): void;
  21862. /**
  21863. * Gets the class name
  21864. * @returns the string "SubMesh".
  21865. */
  21866. getClassName(): string;
  21867. /**
  21868. * Creates a new submesh from indices data
  21869. * @param materialIndex the index of the main mesh material
  21870. * @param startIndex the index where to start the copy in the mesh indices array
  21871. * @param indexCount the number of indices to copy then from the startIndex
  21872. * @param mesh the main mesh to create the submesh from
  21873. * @param renderingMesh the optional rendering mesh
  21874. * @returns a new submesh
  21875. */
  21876. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21877. }
  21878. }
  21879. declare module BABYLON {
  21880. /**
  21881. * Class used to represent data loading progression
  21882. */
  21883. export class SceneLoaderFlags {
  21884. private static _ForceFullSceneLoadingForIncremental;
  21885. private static _ShowLoadingScreen;
  21886. private static _CleanBoneMatrixWeights;
  21887. private static _loggingLevel;
  21888. /**
  21889. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21890. */
  21891. static get ForceFullSceneLoadingForIncremental(): boolean;
  21892. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21893. /**
  21894. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21895. */
  21896. static get ShowLoadingScreen(): boolean;
  21897. static set ShowLoadingScreen(value: boolean);
  21898. /**
  21899. * Defines the current logging level (while loading the scene)
  21900. * @ignorenaming
  21901. */
  21902. static get loggingLevel(): number;
  21903. static set loggingLevel(value: number);
  21904. /**
  21905. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21906. */
  21907. static get CleanBoneMatrixWeights(): boolean;
  21908. static set CleanBoneMatrixWeights(value: boolean);
  21909. }
  21910. }
  21911. declare module BABYLON {
  21912. /**
  21913. * Class used to store geometry data (vertex buffers + index buffer)
  21914. */
  21915. export class Geometry implements IGetSetVerticesData {
  21916. /**
  21917. * Gets or sets the ID of the geometry
  21918. */
  21919. id: string;
  21920. /**
  21921. * Gets or sets the unique ID of the geometry
  21922. */
  21923. uniqueId: number;
  21924. /**
  21925. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21926. */
  21927. delayLoadState: number;
  21928. /**
  21929. * Gets the file containing the data to load when running in delay load state
  21930. */
  21931. delayLoadingFile: Nullable<string>;
  21932. /**
  21933. * Callback called when the geometry is updated
  21934. */
  21935. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21936. private _scene;
  21937. private _engine;
  21938. private _meshes;
  21939. private _totalVertices;
  21940. /** @hidden */
  21941. _indices: IndicesArray;
  21942. /** @hidden */
  21943. _vertexBuffers: {
  21944. [key: string]: VertexBuffer;
  21945. };
  21946. private _isDisposed;
  21947. private _extend;
  21948. private _boundingBias;
  21949. /** @hidden */
  21950. _delayInfo: Array<string>;
  21951. private _indexBuffer;
  21952. private _indexBufferIsUpdatable;
  21953. /** @hidden */
  21954. _boundingInfo: Nullable<BoundingInfo>;
  21955. /** @hidden */
  21956. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21957. /** @hidden */
  21958. _softwareSkinningFrameId: number;
  21959. private _vertexArrayObjects;
  21960. private _updatable;
  21961. /** @hidden */
  21962. _positions: Nullable<Vector3[]>;
  21963. /**
  21964. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21965. */
  21966. get boundingBias(): Vector2;
  21967. /**
  21968. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21969. */
  21970. set boundingBias(value: Vector2);
  21971. /**
  21972. * Static function used to attach a new empty geometry to a mesh
  21973. * @param mesh defines the mesh to attach the geometry to
  21974. * @returns the new Geometry
  21975. */
  21976. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21977. /** Get the list of meshes using this geometry */
  21978. get meshes(): Mesh[];
  21979. /**
  21980. * Creates a new geometry
  21981. * @param id defines the unique ID
  21982. * @param scene defines the hosting scene
  21983. * @param vertexData defines the VertexData used to get geometry data
  21984. * @param updatable defines if geometry must be updatable (false by default)
  21985. * @param mesh defines the mesh that will be associated with the geometry
  21986. */
  21987. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21988. /**
  21989. * Gets the current extend of the geometry
  21990. */
  21991. get extend(): {
  21992. minimum: Vector3;
  21993. maximum: Vector3;
  21994. };
  21995. /**
  21996. * Gets the hosting scene
  21997. * @returns the hosting Scene
  21998. */
  21999. getScene(): Scene;
  22000. /**
  22001. * Gets the hosting engine
  22002. * @returns the hosting Engine
  22003. */
  22004. getEngine(): Engine;
  22005. /**
  22006. * Defines if the geometry is ready to use
  22007. * @returns true if the geometry is ready to be used
  22008. */
  22009. isReady(): boolean;
  22010. /**
  22011. * Gets a value indicating that the geometry should not be serialized
  22012. */
  22013. get doNotSerialize(): boolean;
  22014. /** @hidden */
  22015. _rebuild(): void;
  22016. /**
  22017. * Affects all geometry data in one call
  22018. * @param vertexData defines the geometry data
  22019. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22020. */
  22021. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22022. /**
  22023. * Set specific vertex data
  22024. * @param kind defines the data kind (Position, normal, etc...)
  22025. * @param data defines the vertex data to use
  22026. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22027. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22028. */
  22029. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22030. /**
  22031. * Removes a specific vertex data
  22032. * @param kind defines the data kind (Position, normal, etc...)
  22033. */
  22034. removeVerticesData(kind: string): void;
  22035. /**
  22036. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22037. * @param buffer defines the vertex buffer to use
  22038. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22039. */
  22040. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22041. /**
  22042. * Update a specific vertex buffer
  22043. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22044. * It will do nothing if the buffer is not updatable
  22045. * @param kind defines the data kind (Position, normal, etc...)
  22046. * @param data defines the data to use
  22047. * @param offset defines the offset in the target buffer where to store the data
  22048. * @param useBytes set to true if the offset is in bytes
  22049. */
  22050. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22051. /**
  22052. * Update a specific vertex buffer
  22053. * This function will create a new buffer if the current one is not updatable
  22054. * @param kind defines the data kind (Position, normal, etc...)
  22055. * @param data defines the data to use
  22056. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22057. */
  22058. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22059. private _updateBoundingInfo;
  22060. /** @hidden */
  22061. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22062. /**
  22063. * Gets total number of vertices
  22064. * @returns the total number of vertices
  22065. */
  22066. getTotalVertices(): number;
  22067. /**
  22068. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22069. * @param kind defines the data kind (Position, normal, etc...)
  22070. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22071. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22072. * @returns a float array containing vertex data
  22073. */
  22074. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22075. /**
  22076. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22077. * @param kind defines the data kind (Position, normal, etc...)
  22078. * @returns true if the vertex buffer with the specified kind is updatable
  22079. */
  22080. isVertexBufferUpdatable(kind: string): boolean;
  22081. /**
  22082. * Gets a specific vertex buffer
  22083. * @param kind defines the data kind (Position, normal, etc...)
  22084. * @returns a VertexBuffer
  22085. */
  22086. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22087. /**
  22088. * Returns all vertex buffers
  22089. * @return an object holding all vertex buffers indexed by kind
  22090. */
  22091. getVertexBuffers(): Nullable<{
  22092. [key: string]: VertexBuffer;
  22093. }>;
  22094. /**
  22095. * Gets a boolean indicating if specific vertex buffer is present
  22096. * @param kind defines the data kind (Position, normal, etc...)
  22097. * @returns true if data is present
  22098. */
  22099. isVerticesDataPresent(kind: string): boolean;
  22100. /**
  22101. * Gets a list of all attached data kinds (Position, normal, etc...)
  22102. * @returns a list of string containing all kinds
  22103. */
  22104. getVerticesDataKinds(): string[];
  22105. /**
  22106. * Update index buffer
  22107. * @param indices defines the indices to store in the index buffer
  22108. * @param offset defines the offset in the target buffer where to store the data
  22109. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22110. */
  22111. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22112. /**
  22113. * Creates a new index buffer
  22114. * @param indices defines the indices to store in the index buffer
  22115. * @param totalVertices defines the total number of vertices (could be null)
  22116. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22117. */
  22118. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22119. /**
  22120. * Return the total number of indices
  22121. * @returns the total number of indices
  22122. */
  22123. getTotalIndices(): number;
  22124. /**
  22125. * Gets the index buffer array
  22126. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22127. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22128. * @returns the index buffer array
  22129. */
  22130. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22131. /**
  22132. * Gets the index buffer
  22133. * @return the index buffer
  22134. */
  22135. getIndexBuffer(): Nullable<DataBuffer>;
  22136. /** @hidden */
  22137. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22138. /**
  22139. * Release the associated resources for a specific mesh
  22140. * @param mesh defines the source mesh
  22141. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22142. */
  22143. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22144. /**
  22145. * Apply current geometry to a given mesh
  22146. * @param mesh defines the mesh to apply geometry to
  22147. */
  22148. applyToMesh(mesh: Mesh): void;
  22149. private _updateExtend;
  22150. private _applyToMesh;
  22151. private notifyUpdate;
  22152. /**
  22153. * Load the geometry if it was flagged as delay loaded
  22154. * @param scene defines the hosting scene
  22155. * @param onLoaded defines a callback called when the geometry is loaded
  22156. */
  22157. load(scene: Scene, onLoaded?: () => void): void;
  22158. private _queueLoad;
  22159. /**
  22160. * Invert the geometry to move from a right handed system to a left handed one.
  22161. */
  22162. toLeftHanded(): void;
  22163. /** @hidden */
  22164. _resetPointsArrayCache(): void;
  22165. /** @hidden */
  22166. _generatePointsArray(): boolean;
  22167. /**
  22168. * Gets a value indicating if the geometry is disposed
  22169. * @returns true if the geometry was disposed
  22170. */
  22171. isDisposed(): boolean;
  22172. private _disposeVertexArrayObjects;
  22173. /**
  22174. * Free all associated resources
  22175. */
  22176. dispose(): void;
  22177. /**
  22178. * Clone the current geometry into a new geometry
  22179. * @param id defines the unique ID of the new geometry
  22180. * @returns a new geometry object
  22181. */
  22182. copy(id: string): Geometry;
  22183. /**
  22184. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22185. * @return a JSON representation of the current geometry data (without the vertices data)
  22186. */
  22187. serialize(): any;
  22188. private toNumberArray;
  22189. /**
  22190. * Serialize all vertices data into a JSON oject
  22191. * @returns a JSON representation of the current geometry data
  22192. */
  22193. serializeVerticeData(): any;
  22194. /**
  22195. * Extracts a clone of a mesh geometry
  22196. * @param mesh defines the source mesh
  22197. * @param id defines the unique ID of the new geometry object
  22198. * @returns the new geometry object
  22199. */
  22200. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22201. /**
  22202. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22203. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22204. * Be aware Math.random() could cause collisions, but:
  22205. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  22206. * @returns a string containing a new GUID
  22207. */
  22208. static RandomId(): string;
  22209. /** @hidden */
  22210. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22211. private static _CleanMatricesWeights;
  22212. /**
  22213. * Create a new geometry from persisted data (Using .babylon file format)
  22214. * @param parsedVertexData defines the persisted data
  22215. * @param scene defines the hosting scene
  22216. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22217. * @returns the new geometry object
  22218. */
  22219. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22220. }
  22221. }
  22222. declare module BABYLON {
  22223. /**
  22224. * Define an interface for all classes that will get and set the data on vertices
  22225. */
  22226. export interface IGetSetVerticesData {
  22227. /**
  22228. * Gets a boolean indicating if specific vertex data is present
  22229. * @param kind defines the vertex data kind to use
  22230. * @returns true is data kind is present
  22231. */
  22232. isVerticesDataPresent(kind: string): boolean;
  22233. /**
  22234. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22235. * @param kind defines the data kind (Position, normal, etc...)
  22236. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22237. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22238. * @returns a float array containing vertex data
  22239. */
  22240. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22241. /**
  22242. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22243. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  22244. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22245. * @returns the indices array or an empty array if the mesh has no geometry
  22246. */
  22247. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22248. /**
  22249. * Set specific vertex data
  22250. * @param kind defines the data kind (Position, normal, etc...)
  22251. * @param data defines the vertex data to use
  22252. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22253. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22254. */
  22255. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22256. /**
  22257. * Update a specific associated vertex buffer
  22258. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22259. * - VertexBuffer.PositionKind
  22260. * - VertexBuffer.UVKind
  22261. * - VertexBuffer.UV2Kind
  22262. * - VertexBuffer.UV3Kind
  22263. * - VertexBuffer.UV4Kind
  22264. * - VertexBuffer.UV5Kind
  22265. * - VertexBuffer.UV6Kind
  22266. * - VertexBuffer.ColorKind
  22267. * - VertexBuffer.MatricesIndicesKind
  22268. * - VertexBuffer.MatricesIndicesExtraKind
  22269. * - VertexBuffer.MatricesWeightsKind
  22270. * - VertexBuffer.MatricesWeightsExtraKind
  22271. * @param data defines the data source
  22272. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22273. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  22274. */
  22275. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22276. /**
  22277. * Creates a new index buffer
  22278. * @param indices defines the indices to store in the index buffer
  22279. * @param totalVertices defines the total number of vertices (could be null)
  22280. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22281. */
  22282. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22283. }
  22284. /**
  22285. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22286. */
  22287. export class VertexData {
  22288. /**
  22289. * Mesh side orientation : usually the external or front surface
  22290. */
  22291. static readonly FRONTSIDE: number;
  22292. /**
  22293. * Mesh side orientation : usually the internal or back surface
  22294. */
  22295. static readonly BACKSIDE: number;
  22296. /**
  22297. * Mesh side orientation : both internal and external or front and back surfaces
  22298. */
  22299. static readonly DOUBLESIDE: number;
  22300. /**
  22301. * Mesh side orientation : by default, `FRONTSIDE`
  22302. */
  22303. static readonly DEFAULTSIDE: number;
  22304. /**
  22305. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22306. */
  22307. positions: Nullable<FloatArray>;
  22308. /**
  22309. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22310. */
  22311. normals: Nullable<FloatArray>;
  22312. /**
  22313. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22314. */
  22315. tangents: Nullable<FloatArray>;
  22316. /**
  22317. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22318. */
  22319. uvs: Nullable<FloatArray>;
  22320. /**
  22321. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22322. */
  22323. uvs2: Nullable<FloatArray>;
  22324. /**
  22325. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22326. */
  22327. uvs3: Nullable<FloatArray>;
  22328. /**
  22329. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22330. */
  22331. uvs4: Nullable<FloatArray>;
  22332. /**
  22333. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22334. */
  22335. uvs5: Nullable<FloatArray>;
  22336. /**
  22337. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22338. */
  22339. uvs6: Nullable<FloatArray>;
  22340. /**
  22341. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22342. */
  22343. colors: Nullable<FloatArray>;
  22344. /**
  22345. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  22346. */
  22347. matricesIndices: Nullable<FloatArray>;
  22348. /**
  22349. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22350. */
  22351. matricesWeights: Nullable<FloatArray>;
  22352. /**
  22353. * An array extending the number of possible indices
  22354. */
  22355. matricesIndicesExtra: Nullable<FloatArray>;
  22356. /**
  22357. * An array extending the number of possible weights when the number of indices is extended
  22358. */
  22359. matricesWeightsExtra: Nullable<FloatArray>;
  22360. /**
  22361. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22362. */
  22363. indices: Nullable<IndicesArray>;
  22364. /**
  22365. * Uses the passed data array to set the set the values for the specified kind of data
  22366. * @param data a linear array of floating numbers
  22367. * @param kind the type of data that is being set, eg positions, colors etc
  22368. */
  22369. set(data: FloatArray, kind: string): void;
  22370. /**
  22371. * Associates the vertexData to the passed Mesh.
  22372. * Sets it as updatable or not (default `false`)
  22373. * @param mesh the mesh the vertexData is applied to
  22374. * @param updatable when used and having the value true allows new data to update the vertexData
  22375. * @returns the VertexData
  22376. */
  22377. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22378. /**
  22379. * Associates the vertexData to the passed Geometry.
  22380. * Sets it as updatable or not (default `false`)
  22381. * @param geometry the geometry the vertexData is applied to
  22382. * @param updatable when used and having the value true allows new data to update the vertexData
  22383. * @returns VertexData
  22384. */
  22385. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22386. /**
  22387. * Updates the associated mesh
  22388. * @param mesh the mesh to be updated
  22389. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22390. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22391. * @returns VertexData
  22392. */
  22393. updateMesh(mesh: Mesh): VertexData;
  22394. /**
  22395. * Updates the associated geometry
  22396. * @param geometry the geometry to be updated
  22397. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22398. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22399. * @returns VertexData.
  22400. */
  22401. updateGeometry(geometry: Geometry): VertexData;
  22402. private _applyTo;
  22403. private _update;
  22404. /**
  22405. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22406. * @param matrix the transforming matrix
  22407. * @returns the VertexData
  22408. */
  22409. transform(matrix: Matrix): VertexData;
  22410. /**
  22411. * Merges the passed VertexData into the current one
  22412. * @param other the VertexData to be merged into the current one
  22413. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22414. * @returns the modified VertexData
  22415. */
  22416. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22417. private _mergeElement;
  22418. private _validate;
  22419. /**
  22420. * Serializes the VertexData
  22421. * @returns a serialized object
  22422. */
  22423. serialize(): any;
  22424. /**
  22425. * Extracts the vertexData from a mesh
  22426. * @param mesh the mesh from which to extract the VertexData
  22427. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22428. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22429. * @returns the object VertexData associated to the passed mesh
  22430. */
  22431. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22432. /**
  22433. * Extracts the vertexData from the geometry
  22434. * @param geometry the geometry from which to extract the VertexData
  22435. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22436. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22437. * @returns the object VertexData associated to the passed mesh
  22438. */
  22439. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22440. private static _ExtractFrom;
  22441. /**
  22442. * Creates the VertexData for a Ribbon
  22443. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22444. * * pathArray array of paths, each of which an array of successive Vector3
  22445. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22446. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22447. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  22448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22449. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22450. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22451. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22452. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22453. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22454. * @returns the VertexData of the ribbon
  22455. */
  22456. static CreateRibbon(options: {
  22457. pathArray: Vector3[][];
  22458. closeArray?: boolean;
  22459. closePath?: boolean;
  22460. offset?: number;
  22461. sideOrientation?: number;
  22462. frontUVs?: Vector4;
  22463. backUVs?: Vector4;
  22464. invertUV?: boolean;
  22465. uvs?: Vector2[];
  22466. colors?: Color4[];
  22467. }): VertexData;
  22468. /**
  22469. * Creates the VertexData for a box
  22470. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22471. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22472. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22473. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22474. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22475. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22476. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22477. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22478. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22479. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22480. * @returns the VertexData of the box
  22481. */
  22482. static CreateBox(options: {
  22483. size?: number;
  22484. width?: number;
  22485. height?: number;
  22486. depth?: number;
  22487. faceUV?: Vector4[];
  22488. faceColors?: Color4[];
  22489. sideOrientation?: number;
  22490. frontUVs?: Vector4;
  22491. backUVs?: Vector4;
  22492. }): VertexData;
  22493. /**
  22494. * Creates the VertexData for a tiled box
  22495. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22496. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22497. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22498. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22499. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22500. * @returns the VertexData of the box
  22501. */
  22502. static CreateTiledBox(options: {
  22503. pattern?: number;
  22504. width?: number;
  22505. height?: number;
  22506. depth?: number;
  22507. tileSize?: number;
  22508. tileWidth?: number;
  22509. tileHeight?: number;
  22510. alignHorizontal?: number;
  22511. alignVertical?: number;
  22512. faceUV?: Vector4[];
  22513. faceColors?: Color4[];
  22514. sideOrientation?: number;
  22515. }): VertexData;
  22516. /**
  22517. * Creates the VertexData for a tiled plane
  22518. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22519. * * pattern a limited pattern arrangement depending on the number
  22520. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22521. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22522. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22524. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22525. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22526. * @returns the VertexData of the tiled plane
  22527. */
  22528. static CreateTiledPlane(options: {
  22529. pattern?: number;
  22530. tileSize?: number;
  22531. tileWidth?: number;
  22532. tileHeight?: number;
  22533. size?: number;
  22534. width?: number;
  22535. height?: number;
  22536. alignHorizontal?: number;
  22537. alignVertical?: number;
  22538. sideOrientation?: number;
  22539. frontUVs?: Vector4;
  22540. backUVs?: Vector4;
  22541. }): VertexData;
  22542. /**
  22543. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22544. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22545. * * segments sets the number of horizontal strips optional, default 32
  22546. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22547. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22548. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22549. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22550. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  22551. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  22552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22553. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22554. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22555. * @returns the VertexData of the ellipsoid
  22556. */
  22557. static CreateSphere(options: {
  22558. segments?: number;
  22559. diameter?: number;
  22560. diameterX?: number;
  22561. diameterY?: number;
  22562. diameterZ?: number;
  22563. arc?: number;
  22564. slice?: number;
  22565. sideOrientation?: number;
  22566. frontUVs?: Vector4;
  22567. backUVs?: Vector4;
  22568. }): VertexData;
  22569. /**
  22570. * Creates the VertexData for a cylinder, cone or prism
  22571. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22572. * * height sets the height (y direction) of the cylinder, optional, default 2
  22573. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22574. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22575. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22576. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22577. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22578. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  22579. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22580. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22581. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22582. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22583. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22584. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22585. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22586. * @returns the VertexData of the cylinder, cone or prism
  22587. */
  22588. static CreateCylinder(options: {
  22589. height?: number;
  22590. diameterTop?: number;
  22591. diameterBottom?: number;
  22592. diameter?: number;
  22593. tessellation?: number;
  22594. subdivisions?: number;
  22595. arc?: number;
  22596. faceColors?: Color4[];
  22597. faceUV?: Vector4[];
  22598. hasRings?: boolean;
  22599. enclose?: boolean;
  22600. sideOrientation?: number;
  22601. frontUVs?: Vector4;
  22602. backUVs?: Vector4;
  22603. }): VertexData;
  22604. /**
  22605. * Creates the VertexData for a torus
  22606. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22607. * * diameter the diameter of the torus, optional default 1
  22608. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22609. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22610. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22611. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22612. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22613. * @returns the VertexData of the torus
  22614. */
  22615. static CreateTorus(options: {
  22616. diameter?: number;
  22617. thickness?: number;
  22618. tessellation?: number;
  22619. sideOrientation?: number;
  22620. frontUVs?: Vector4;
  22621. backUVs?: Vector4;
  22622. }): VertexData;
  22623. /**
  22624. * Creates the VertexData of the LineSystem
  22625. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22626. * - lines an array of lines, each line being an array of successive Vector3
  22627. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22628. * @returns the VertexData of the LineSystem
  22629. */
  22630. static CreateLineSystem(options: {
  22631. lines: Vector3[][];
  22632. colors?: Nullable<Color4[][]>;
  22633. }): VertexData;
  22634. /**
  22635. * Create the VertexData for a DashedLines
  22636. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22637. * - points an array successive Vector3
  22638. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22639. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22640. * - dashNb the intended total number of dashes, optional, default 200
  22641. * @returns the VertexData for the DashedLines
  22642. */
  22643. static CreateDashedLines(options: {
  22644. points: Vector3[];
  22645. dashSize?: number;
  22646. gapSize?: number;
  22647. dashNb?: number;
  22648. }): VertexData;
  22649. /**
  22650. * Creates the VertexData for a Ground
  22651. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22652. * - width the width (x direction) of the ground, optional, default 1
  22653. * - height the height (z direction) of the ground, optional, default 1
  22654. * - subdivisions the number of subdivisions per side, optional, default 1
  22655. * @returns the VertexData of the Ground
  22656. */
  22657. static CreateGround(options: {
  22658. width?: number;
  22659. height?: number;
  22660. subdivisions?: number;
  22661. subdivisionsX?: number;
  22662. subdivisionsY?: number;
  22663. }): VertexData;
  22664. /**
  22665. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22666. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22667. * * xmin the ground minimum X coordinate, optional, default -1
  22668. * * zmin the ground minimum Z coordinate, optional, default -1
  22669. * * xmax the ground maximum X coordinate, optional, default 1
  22670. * * zmax the ground maximum Z coordinate, optional, default 1
  22671. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  22672. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  22673. * @returns the VertexData of the TiledGround
  22674. */
  22675. static CreateTiledGround(options: {
  22676. xmin: number;
  22677. zmin: number;
  22678. xmax: number;
  22679. zmax: number;
  22680. subdivisions?: {
  22681. w: number;
  22682. h: number;
  22683. };
  22684. precision?: {
  22685. w: number;
  22686. h: number;
  22687. };
  22688. }): VertexData;
  22689. /**
  22690. * Creates the VertexData of the Ground designed from a heightmap
  22691. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22692. * * width the width (x direction) of the ground
  22693. * * height the height (z direction) of the ground
  22694. * * subdivisions the number of subdivisions per side
  22695. * * minHeight the minimum altitude on the ground, optional, default 0
  22696. * * maxHeight the maximum altitude on the ground, optional default 1
  22697. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22698. * * buffer the array holding the image color data
  22699. * * bufferWidth the width of image
  22700. * * bufferHeight the height of image
  22701. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22702. * @returns the VertexData of the Ground designed from a heightmap
  22703. */
  22704. static CreateGroundFromHeightMap(options: {
  22705. width: number;
  22706. height: number;
  22707. subdivisions: number;
  22708. minHeight: number;
  22709. maxHeight: number;
  22710. colorFilter: Color3;
  22711. buffer: Uint8Array;
  22712. bufferWidth: number;
  22713. bufferHeight: number;
  22714. alphaFilter: number;
  22715. }): VertexData;
  22716. /**
  22717. * Creates the VertexData for a Plane
  22718. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22719. * * size sets the width and height of the plane to the value of size, optional default 1
  22720. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22721. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22722. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22723. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22724. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22725. * @returns the VertexData of the box
  22726. */
  22727. static CreatePlane(options: {
  22728. size?: number;
  22729. width?: number;
  22730. height?: number;
  22731. sideOrientation?: number;
  22732. frontUVs?: Vector4;
  22733. backUVs?: Vector4;
  22734. }): VertexData;
  22735. /**
  22736. * Creates the VertexData of the Disc or regular Polygon
  22737. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22738. * * radius the radius of the disc, optional default 0.5
  22739. * * tessellation the number of polygon sides, optional, default 64
  22740. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  22741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22742. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22743. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22744. * @returns the VertexData of the box
  22745. */
  22746. static CreateDisc(options: {
  22747. radius?: number;
  22748. tessellation?: number;
  22749. arc?: number;
  22750. sideOrientation?: number;
  22751. frontUVs?: Vector4;
  22752. backUVs?: Vector4;
  22753. }): VertexData;
  22754. /**
  22755. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22756. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22757. * @param polygon a mesh built from polygonTriangulation.build()
  22758. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22759. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22760. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22761. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22762. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22763. * @returns the VertexData of the Polygon
  22764. */
  22765. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22766. /**
  22767. * Creates the VertexData of the IcoSphere
  22768. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22769. * * radius the radius of the IcoSphere, optional default 1
  22770. * * radiusX allows stretching in the x direction, optional, default radius
  22771. * * radiusY allows stretching in the y direction, optional, default radius
  22772. * * radiusZ allows stretching in the z direction, optional, default radius
  22773. * * flat when true creates a flat shaded mesh, optional, default true
  22774. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22775. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22776. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22777. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22778. * @returns the VertexData of the IcoSphere
  22779. */
  22780. static CreateIcoSphere(options: {
  22781. radius?: number;
  22782. radiusX?: number;
  22783. radiusY?: number;
  22784. radiusZ?: number;
  22785. flat?: boolean;
  22786. subdivisions?: number;
  22787. sideOrientation?: number;
  22788. frontUVs?: Vector4;
  22789. backUVs?: Vector4;
  22790. }): VertexData;
  22791. /**
  22792. * Creates the VertexData for a Polyhedron
  22793. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22794. * * type provided types are:
  22795. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22796. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  22797. * * size the size of the IcoSphere, optional default 1
  22798. * * sizeX allows stretching in the x direction, optional, default size
  22799. * * sizeY allows stretching in the y direction, optional, default size
  22800. * * sizeZ allows stretching in the z direction, optional, default size
  22801. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  22802. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22803. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22804. * * flat when true creates a flat shaded mesh, optional, default true
  22805. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22806. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22807. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22808. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22809. * @returns the VertexData of the Polyhedron
  22810. */
  22811. static CreatePolyhedron(options: {
  22812. type?: number;
  22813. size?: number;
  22814. sizeX?: number;
  22815. sizeY?: number;
  22816. sizeZ?: number;
  22817. custom?: any;
  22818. faceUV?: Vector4[];
  22819. faceColors?: Color4[];
  22820. flat?: boolean;
  22821. sideOrientation?: number;
  22822. frontUVs?: Vector4;
  22823. backUVs?: Vector4;
  22824. }): VertexData;
  22825. /**
  22826. * Creates the VertexData for a TorusKnot
  22827. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22828. * * radius the radius of the torus knot, optional, default 2
  22829. * * tube the thickness of the tube, optional, default 0.5
  22830. * * radialSegments the number of sides on each tube segments, optional, default 32
  22831. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22832. * * p the number of windings around the z axis, optional, default 2
  22833. * * q the number of windings around the x axis, optional, default 3
  22834. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22835. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22836. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22837. * @returns the VertexData of the Torus Knot
  22838. */
  22839. static CreateTorusKnot(options: {
  22840. radius?: number;
  22841. tube?: number;
  22842. radialSegments?: number;
  22843. tubularSegments?: number;
  22844. p?: number;
  22845. q?: number;
  22846. sideOrientation?: number;
  22847. frontUVs?: Vector4;
  22848. backUVs?: Vector4;
  22849. }): VertexData;
  22850. /**
  22851. * Compute normals for given positions and indices
  22852. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22853. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22854. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22855. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22856. * * facetNormals : optional array of facet normals (vector3)
  22857. * * facetPositions : optional array of facet positions (vector3)
  22858. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22859. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22860. * * bInfo : optional bounding info, required for facetPartitioning computation
  22861. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22862. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22863. * * useRightHandedSystem: optional boolean to for right handed system computation
  22864. * * depthSort : optional boolean to enable the facet depth sort computation
  22865. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22866. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22867. */
  22868. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22869. facetNormals?: any;
  22870. facetPositions?: any;
  22871. facetPartitioning?: any;
  22872. ratio?: number;
  22873. bInfo?: any;
  22874. bbSize?: Vector3;
  22875. subDiv?: any;
  22876. useRightHandedSystem?: boolean;
  22877. depthSort?: boolean;
  22878. distanceTo?: Vector3;
  22879. depthSortedFacets?: any;
  22880. }): void;
  22881. /** @hidden */
  22882. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22883. /**
  22884. * Applies VertexData created from the imported parameters to the geometry
  22885. * @param parsedVertexData the parsed data from an imported file
  22886. * @param geometry the geometry to apply the VertexData to
  22887. */
  22888. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22889. }
  22890. }
  22891. declare module BABYLON {
  22892. /**
  22893. * Defines a target to use with MorphTargetManager
  22894. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22895. */
  22896. export class MorphTarget implements IAnimatable {
  22897. /** defines the name of the target */
  22898. name: string;
  22899. /**
  22900. * Gets or sets the list of animations
  22901. */
  22902. animations: Animation[];
  22903. private _scene;
  22904. private _positions;
  22905. private _normals;
  22906. private _tangents;
  22907. private _uvs;
  22908. private _influence;
  22909. private _uniqueId;
  22910. /**
  22911. * Observable raised when the influence changes
  22912. */
  22913. onInfluenceChanged: Observable<boolean>;
  22914. /** @hidden */
  22915. _onDataLayoutChanged: Observable<void>;
  22916. /**
  22917. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22918. */
  22919. get influence(): number;
  22920. set influence(influence: number);
  22921. /**
  22922. * Gets or sets the id of the morph Target
  22923. */
  22924. id: string;
  22925. private _animationPropertiesOverride;
  22926. /**
  22927. * Gets or sets the animation properties override
  22928. */
  22929. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22930. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22931. /**
  22932. * Creates a new MorphTarget
  22933. * @param name defines the name of the target
  22934. * @param influence defines the influence to use
  22935. * @param scene defines the scene the morphtarget belongs to
  22936. */
  22937. constructor(
  22938. /** defines the name of the target */
  22939. name: string, influence?: number, scene?: Nullable<Scene>);
  22940. /**
  22941. * Gets the unique ID of this manager
  22942. */
  22943. get uniqueId(): number;
  22944. /**
  22945. * Gets a boolean defining if the target contains position data
  22946. */
  22947. get hasPositions(): boolean;
  22948. /**
  22949. * Gets a boolean defining if the target contains normal data
  22950. */
  22951. get hasNormals(): boolean;
  22952. /**
  22953. * Gets a boolean defining if the target contains tangent data
  22954. */
  22955. get hasTangents(): boolean;
  22956. /**
  22957. * Gets a boolean defining if the target contains texture coordinates data
  22958. */
  22959. get hasUVs(): boolean;
  22960. /**
  22961. * Affects position data to this target
  22962. * @param data defines the position data to use
  22963. */
  22964. setPositions(data: Nullable<FloatArray>): void;
  22965. /**
  22966. * Gets the position data stored in this target
  22967. * @returns a FloatArray containing the position data (or null if not present)
  22968. */
  22969. getPositions(): Nullable<FloatArray>;
  22970. /**
  22971. * Affects normal data to this target
  22972. * @param data defines the normal data to use
  22973. */
  22974. setNormals(data: Nullable<FloatArray>): void;
  22975. /**
  22976. * Gets the normal data stored in this target
  22977. * @returns a FloatArray containing the normal data (or null if not present)
  22978. */
  22979. getNormals(): Nullable<FloatArray>;
  22980. /**
  22981. * Affects tangent data to this target
  22982. * @param data defines the tangent data to use
  22983. */
  22984. setTangents(data: Nullable<FloatArray>): void;
  22985. /**
  22986. * Gets the tangent data stored in this target
  22987. * @returns a FloatArray containing the tangent data (or null if not present)
  22988. */
  22989. getTangents(): Nullable<FloatArray>;
  22990. /**
  22991. * Affects texture coordinates data to this target
  22992. * @param data defines the texture coordinates data to use
  22993. */
  22994. setUVs(data: Nullable<FloatArray>): void;
  22995. /**
  22996. * Gets the texture coordinates data stored in this target
  22997. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22998. */
  22999. getUVs(): Nullable<FloatArray>;
  23000. /**
  23001. * Clone the current target
  23002. * @returns a new MorphTarget
  23003. */
  23004. clone(): MorphTarget;
  23005. /**
  23006. * Serializes the current target into a Serialization object
  23007. * @returns the serialized object
  23008. */
  23009. serialize(): any;
  23010. /**
  23011. * Returns the string "MorphTarget"
  23012. * @returns "MorphTarget"
  23013. */
  23014. getClassName(): string;
  23015. /**
  23016. * Creates a new target from serialized data
  23017. * @param serializationObject defines the serialized data to use
  23018. * @returns a new MorphTarget
  23019. */
  23020. static Parse(serializationObject: any): MorphTarget;
  23021. /**
  23022. * Creates a MorphTarget from mesh data
  23023. * @param mesh defines the source mesh
  23024. * @param name defines the name to use for the new target
  23025. * @param influence defines the influence to attach to the target
  23026. * @returns a new MorphTarget
  23027. */
  23028. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23029. }
  23030. }
  23031. declare module BABYLON {
  23032. /**
  23033. * This class is used to deform meshes using morphing between different targets
  23034. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23035. */
  23036. export class MorphTargetManager {
  23037. private _targets;
  23038. private _targetInfluenceChangedObservers;
  23039. private _targetDataLayoutChangedObservers;
  23040. private _activeTargets;
  23041. private _scene;
  23042. private _influences;
  23043. private _supportsNormals;
  23044. private _supportsTangents;
  23045. private _supportsUVs;
  23046. private _vertexCount;
  23047. private _uniqueId;
  23048. private _tempInfluences;
  23049. /**
  23050. * Gets or sets a boolean indicating if normals must be morphed
  23051. */
  23052. enableNormalMorphing: boolean;
  23053. /**
  23054. * Gets or sets a boolean indicating if tangents must be morphed
  23055. */
  23056. enableTangentMorphing: boolean;
  23057. /**
  23058. * Gets or sets a boolean indicating if UV must be morphed
  23059. */
  23060. enableUVMorphing: boolean;
  23061. /**
  23062. * Creates a new MorphTargetManager
  23063. * @param scene defines the current scene
  23064. */
  23065. constructor(scene?: Nullable<Scene>);
  23066. /**
  23067. * Gets the unique ID of this manager
  23068. */
  23069. get uniqueId(): number;
  23070. /**
  23071. * Gets the number of vertices handled by this manager
  23072. */
  23073. get vertexCount(): number;
  23074. /**
  23075. * Gets a boolean indicating if this manager supports morphing of normals
  23076. */
  23077. get supportsNormals(): boolean;
  23078. /**
  23079. * Gets a boolean indicating if this manager supports morphing of tangents
  23080. */
  23081. get supportsTangents(): boolean;
  23082. /**
  23083. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23084. */
  23085. get supportsUVs(): boolean;
  23086. /**
  23087. * Gets the number of targets stored in this manager
  23088. */
  23089. get numTargets(): number;
  23090. /**
  23091. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23092. */
  23093. get numInfluencers(): number;
  23094. /**
  23095. * Gets the list of influences (one per target)
  23096. */
  23097. get influences(): Float32Array;
  23098. /**
  23099. * Gets the active target at specified index. An active target is a target with an influence > 0
  23100. * @param index defines the index to check
  23101. * @returns the requested target
  23102. */
  23103. getActiveTarget(index: number): MorphTarget;
  23104. /**
  23105. * Gets the target at specified index
  23106. * @param index defines the index to check
  23107. * @returns the requested target
  23108. */
  23109. getTarget(index: number): MorphTarget;
  23110. /**
  23111. * Add a new target to this manager
  23112. * @param target defines the target to add
  23113. */
  23114. addTarget(target: MorphTarget): void;
  23115. /**
  23116. * Removes a target from the manager
  23117. * @param target defines the target to remove
  23118. */
  23119. removeTarget(target: MorphTarget): void;
  23120. /**
  23121. * Clone the current manager
  23122. * @returns a new MorphTargetManager
  23123. */
  23124. clone(): MorphTargetManager;
  23125. /**
  23126. * Serializes the current manager into a Serialization object
  23127. * @returns the serialized object
  23128. */
  23129. serialize(): any;
  23130. private _syncActiveTargets;
  23131. /**
  23132. * Syncrhonize the targets with all the meshes using this morph target manager
  23133. */
  23134. synchronize(): void;
  23135. /**
  23136. * Creates a new MorphTargetManager from serialized data
  23137. * @param serializationObject defines the serialized data
  23138. * @param scene defines the hosting scene
  23139. * @returns the new MorphTargetManager
  23140. */
  23141. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23142. }
  23143. }
  23144. declare module BABYLON {
  23145. /**
  23146. * Class used to represent a specific level of detail of a mesh
  23147. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23148. */
  23149. export class MeshLODLevel {
  23150. /** Defines the distance where this level should start being displayed */
  23151. distance: number;
  23152. /** Defines the mesh to use to render this level */
  23153. mesh: Nullable<Mesh>;
  23154. /**
  23155. * Creates a new LOD level
  23156. * @param distance defines the distance where this level should star being displayed
  23157. * @param mesh defines the mesh to use to render this level
  23158. */
  23159. constructor(
  23160. /** Defines the distance where this level should start being displayed */
  23161. distance: number,
  23162. /** Defines the mesh to use to render this level */
  23163. mesh: Nullable<Mesh>);
  23164. }
  23165. }
  23166. declare module BABYLON {
  23167. /**
  23168. * Mesh representing the gorund
  23169. */
  23170. export class GroundMesh extends Mesh {
  23171. /** If octree should be generated */
  23172. generateOctree: boolean;
  23173. private _heightQuads;
  23174. /** @hidden */
  23175. _subdivisionsX: number;
  23176. /** @hidden */
  23177. _subdivisionsY: number;
  23178. /** @hidden */
  23179. _width: number;
  23180. /** @hidden */
  23181. _height: number;
  23182. /** @hidden */
  23183. _minX: number;
  23184. /** @hidden */
  23185. _maxX: number;
  23186. /** @hidden */
  23187. _minZ: number;
  23188. /** @hidden */
  23189. _maxZ: number;
  23190. constructor(name: string, scene: Scene);
  23191. /**
  23192. * "GroundMesh"
  23193. * @returns "GroundMesh"
  23194. */
  23195. getClassName(): string;
  23196. /**
  23197. * The minimum of x and y subdivisions
  23198. */
  23199. get subdivisions(): number;
  23200. /**
  23201. * X subdivisions
  23202. */
  23203. get subdivisionsX(): number;
  23204. /**
  23205. * Y subdivisions
  23206. */
  23207. get subdivisionsY(): number;
  23208. /**
  23209. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23210. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23211. * @param chunksCount the number of subdivisions for x and y
  23212. * @param octreeBlocksSize (Default: 32)
  23213. */
  23214. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23215. /**
  23216. * Returns a height (y) value in the Worl system :
  23217. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23218. * @param x x coordinate
  23219. * @param z z coordinate
  23220. * @returns the ground y position if (x, z) are outside the ground surface.
  23221. */
  23222. getHeightAtCoordinates(x: number, z: number): number;
  23223. /**
  23224. * Returns a normalized vector (Vector3) orthogonal to the ground
  23225. * at the ground coordinates (x, z) expressed in the World system.
  23226. * @param x x coordinate
  23227. * @param z z coordinate
  23228. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23229. */
  23230. getNormalAtCoordinates(x: number, z: number): Vector3;
  23231. /**
  23232. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23233. * at the ground coordinates (x, z) expressed in the World system.
  23234. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23235. * @param x x coordinate
  23236. * @param z z coordinate
  23237. * @param ref vector to store the result
  23238. * @returns the GroundMesh.
  23239. */
  23240. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23241. /**
  23242. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23243. * if the ground has been updated.
  23244. * This can be used in the render loop.
  23245. * @returns the GroundMesh.
  23246. */
  23247. updateCoordinateHeights(): GroundMesh;
  23248. private _getFacetAt;
  23249. private _initHeightQuads;
  23250. private _computeHeightQuads;
  23251. /**
  23252. * Serializes this ground mesh
  23253. * @param serializationObject object to write serialization to
  23254. */
  23255. serialize(serializationObject: any): void;
  23256. /**
  23257. * Parses a serialized ground mesh
  23258. * @param parsedMesh the serialized mesh
  23259. * @param scene the scene to create the ground mesh in
  23260. * @returns the created ground mesh
  23261. */
  23262. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23263. }
  23264. }
  23265. declare module BABYLON {
  23266. /**
  23267. * Interface for Physics-Joint data
  23268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23269. */
  23270. export interface PhysicsJointData {
  23271. /**
  23272. * The main pivot of the joint
  23273. */
  23274. mainPivot?: Vector3;
  23275. /**
  23276. * The connected pivot of the joint
  23277. */
  23278. connectedPivot?: Vector3;
  23279. /**
  23280. * The main axis of the joint
  23281. */
  23282. mainAxis?: Vector3;
  23283. /**
  23284. * The connected axis of the joint
  23285. */
  23286. connectedAxis?: Vector3;
  23287. /**
  23288. * The collision of the joint
  23289. */
  23290. collision?: boolean;
  23291. /**
  23292. * Native Oimo/Cannon/Energy data
  23293. */
  23294. nativeParams?: any;
  23295. }
  23296. /**
  23297. * This is a holder class for the physics joint created by the physics plugin
  23298. * It holds a set of functions to control the underlying joint
  23299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23300. */
  23301. export class PhysicsJoint {
  23302. /**
  23303. * The type of the physics joint
  23304. */
  23305. type: number;
  23306. /**
  23307. * The data for the physics joint
  23308. */
  23309. jointData: PhysicsJointData;
  23310. private _physicsJoint;
  23311. protected _physicsPlugin: IPhysicsEnginePlugin;
  23312. /**
  23313. * Initializes the physics joint
  23314. * @param type The type of the physics joint
  23315. * @param jointData The data for the physics joint
  23316. */
  23317. constructor(
  23318. /**
  23319. * The type of the physics joint
  23320. */
  23321. type: number,
  23322. /**
  23323. * The data for the physics joint
  23324. */
  23325. jointData: PhysicsJointData);
  23326. /**
  23327. * Gets the physics joint
  23328. */
  23329. get physicsJoint(): any;
  23330. /**
  23331. * Sets the physics joint
  23332. */
  23333. set physicsJoint(newJoint: any);
  23334. /**
  23335. * Sets the physics plugin
  23336. */
  23337. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23338. /**
  23339. * Execute a function that is physics-plugin specific.
  23340. * @param {Function} func the function that will be executed.
  23341. * It accepts two parameters: the physics world and the physics joint
  23342. */
  23343. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23344. /**
  23345. * Distance-Joint type
  23346. */
  23347. static DistanceJoint: number;
  23348. /**
  23349. * Hinge-Joint type
  23350. */
  23351. static HingeJoint: number;
  23352. /**
  23353. * Ball-and-Socket joint type
  23354. */
  23355. static BallAndSocketJoint: number;
  23356. /**
  23357. * Wheel-Joint type
  23358. */
  23359. static WheelJoint: number;
  23360. /**
  23361. * Slider-Joint type
  23362. */
  23363. static SliderJoint: number;
  23364. /**
  23365. * Prismatic-Joint type
  23366. */
  23367. static PrismaticJoint: number;
  23368. /**
  23369. * Universal-Joint type
  23370. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23371. */
  23372. static UniversalJoint: number;
  23373. /**
  23374. * Hinge-Joint 2 type
  23375. */
  23376. static Hinge2Joint: number;
  23377. /**
  23378. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23379. */
  23380. static PointToPointJoint: number;
  23381. /**
  23382. * Spring-Joint type
  23383. */
  23384. static SpringJoint: number;
  23385. /**
  23386. * Lock-Joint type
  23387. */
  23388. static LockJoint: number;
  23389. }
  23390. /**
  23391. * A class representing a physics distance joint
  23392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23393. */
  23394. export class DistanceJoint extends PhysicsJoint {
  23395. /**
  23396. *
  23397. * @param jointData The data for the Distance-Joint
  23398. */
  23399. constructor(jointData: DistanceJointData);
  23400. /**
  23401. * Update the predefined distance.
  23402. * @param maxDistance The maximum preferred distance
  23403. * @param minDistance The minimum preferred distance
  23404. */
  23405. updateDistance(maxDistance: number, minDistance?: number): void;
  23406. }
  23407. /**
  23408. * Represents a Motor-Enabled Joint
  23409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23410. */
  23411. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23412. /**
  23413. * Initializes the Motor-Enabled Joint
  23414. * @param type The type of the joint
  23415. * @param jointData The physica joint data for the joint
  23416. */
  23417. constructor(type: number, jointData: PhysicsJointData);
  23418. /**
  23419. * Set the motor values.
  23420. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23421. * @param force the force to apply
  23422. * @param maxForce max force for this motor.
  23423. */
  23424. setMotor(force?: number, maxForce?: number): void;
  23425. /**
  23426. * Set the motor's limits.
  23427. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23428. * @param upperLimit The upper limit of the motor
  23429. * @param lowerLimit The lower limit of the motor
  23430. */
  23431. setLimit(upperLimit: number, lowerLimit?: number): void;
  23432. }
  23433. /**
  23434. * This class represents a single physics Hinge-Joint
  23435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23436. */
  23437. export class HingeJoint extends MotorEnabledJoint {
  23438. /**
  23439. * Initializes the Hinge-Joint
  23440. * @param jointData The joint data for the Hinge-Joint
  23441. */
  23442. constructor(jointData: PhysicsJointData);
  23443. /**
  23444. * Set the motor values.
  23445. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23446. * @param {number} force the force to apply
  23447. * @param {number} maxForce max force for this motor.
  23448. */
  23449. setMotor(force?: number, maxForce?: number): void;
  23450. /**
  23451. * Set the motor's limits.
  23452. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23453. * @param upperLimit The upper limit of the motor
  23454. * @param lowerLimit The lower limit of the motor
  23455. */
  23456. setLimit(upperLimit: number, lowerLimit?: number): void;
  23457. }
  23458. /**
  23459. * This class represents a dual hinge physics joint (same as wheel joint)
  23460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23461. */
  23462. export class Hinge2Joint extends MotorEnabledJoint {
  23463. /**
  23464. * Initializes the Hinge2-Joint
  23465. * @param jointData The joint data for the Hinge2-Joint
  23466. */
  23467. constructor(jointData: PhysicsJointData);
  23468. /**
  23469. * Set the motor values.
  23470. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23471. * @param {number} targetSpeed the speed the motor is to reach
  23472. * @param {number} maxForce max force for this motor.
  23473. * @param {motorIndex} the motor's index, 0 or 1.
  23474. */
  23475. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23476. /**
  23477. * Set the motor limits.
  23478. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23479. * @param {number} upperLimit the upper limit
  23480. * @param {number} lowerLimit lower limit
  23481. * @param {motorIndex} the motor's index, 0 or 1.
  23482. */
  23483. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23484. }
  23485. /**
  23486. * Interface for a motor enabled joint
  23487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23488. */
  23489. export interface IMotorEnabledJoint {
  23490. /**
  23491. * Physics joint
  23492. */
  23493. physicsJoint: any;
  23494. /**
  23495. * Sets the motor of the motor-enabled joint
  23496. * @param force The force of the motor
  23497. * @param maxForce The maximum force of the motor
  23498. * @param motorIndex The index of the motor
  23499. */
  23500. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23501. /**
  23502. * Sets the limit of the motor
  23503. * @param upperLimit The upper limit of the motor
  23504. * @param lowerLimit The lower limit of the motor
  23505. * @param motorIndex The index of the motor
  23506. */
  23507. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23508. }
  23509. /**
  23510. * Joint data for a Distance-Joint
  23511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23512. */
  23513. export interface DistanceJointData extends PhysicsJointData {
  23514. /**
  23515. * Max distance the 2 joint objects can be apart
  23516. */
  23517. maxDistance: number;
  23518. }
  23519. /**
  23520. * Joint data from a spring joint
  23521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23522. */
  23523. export interface SpringJointData extends PhysicsJointData {
  23524. /**
  23525. * Length of the spring
  23526. */
  23527. length: number;
  23528. /**
  23529. * Stiffness of the spring
  23530. */
  23531. stiffness: number;
  23532. /**
  23533. * Damping of the spring
  23534. */
  23535. damping: number;
  23536. /** this callback will be called when applying the force to the impostors. */
  23537. forceApplicationCallback: () => void;
  23538. }
  23539. }
  23540. declare module BABYLON {
  23541. /**
  23542. * Holds the data for the raycast result
  23543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23544. */
  23545. export class PhysicsRaycastResult {
  23546. private _hasHit;
  23547. private _hitDistance;
  23548. private _hitNormalWorld;
  23549. private _hitPointWorld;
  23550. private _rayFromWorld;
  23551. private _rayToWorld;
  23552. /**
  23553. * Gets if there was a hit
  23554. */
  23555. get hasHit(): boolean;
  23556. /**
  23557. * Gets the distance from the hit
  23558. */
  23559. get hitDistance(): number;
  23560. /**
  23561. * Gets the hit normal/direction in the world
  23562. */
  23563. get hitNormalWorld(): Vector3;
  23564. /**
  23565. * Gets the hit point in the world
  23566. */
  23567. get hitPointWorld(): Vector3;
  23568. /**
  23569. * Gets the ray "start point" of the ray in the world
  23570. */
  23571. get rayFromWorld(): Vector3;
  23572. /**
  23573. * Gets the ray "end point" of the ray in the world
  23574. */
  23575. get rayToWorld(): Vector3;
  23576. /**
  23577. * Sets the hit data (normal & point in world space)
  23578. * @param hitNormalWorld defines the normal in world space
  23579. * @param hitPointWorld defines the point in world space
  23580. */
  23581. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23582. /**
  23583. * Sets the distance from the start point to the hit point
  23584. * @param distance
  23585. */
  23586. setHitDistance(distance: number): void;
  23587. /**
  23588. * Calculates the distance manually
  23589. */
  23590. calculateHitDistance(): void;
  23591. /**
  23592. * Resets all the values to default
  23593. * @param from The from point on world space
  23594. * @param to The to point on world space
  23595. */
  23596. reset(from?: Vector3, to?: Vector3): void;
  23597. }
  23598. /**
  23599. * Interface for the size containing width and height
  23600. */
  23601. interface IXYZ {
  23602. /**
  23603. * X
  23604. */
  23605. x: number;
  23606. /**
  23607. * Y
  23608. */
  23609. y: number;
  23610. /**
  23611. * Z
  23612. */
  23613. z: number;
  23614. }
  23615. }
  23616. declare module BABYLON {
  23617. /**
  23618. * Interface used to describe a physics joint
  23619. */
  23620. export interface PhysicsImpostorJoint {
  23621. /** Defines the main impostor to which the joint is linked */
  23622. mainImpostor: PhysicsImpostor;
  23623. /** Defines the impostor that is connected to the main impostor using this joint */
  23624. connectedImpostor: PhysicsImpostor;
  23625. /** Defines the joint itself */
  23626. joint: PhysicsJoint;
  23627. }
  23628. /** @hidden */
  23629. export interface IPhysicsEnginePlugin {
  23630. world: any;
  23631. name: string;
  23632. setGravity(gravity: Vector3): void;
  23633. setTimeStep(timeStep: number): void;
  23634. getTimeStep(): number;
  23635. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23636. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23637. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23638. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23639. removePhysicsBody(impostor: PhysicsImpostor): void;
  23640. generateJoint(joint: PhysicsImpostorJoint): void;
  23641. removeJoint(joint: PhysicsImpostorJoint): void;
  23642. isSupported(): boolean;
  23643. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23644. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23645. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23646. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23647. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23648. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23649. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23650. getBodyMass(impostor: PhysicsImpostor): number;
  23651. getBodyFriction(impostor: PhysicsImpostor): number;
  23652. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23653. getBodyRestitution(impostor: PhysicsImpostor): number;
  23654. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23655. getBodyPressure?(impostor: PhysicsImpostor): number;
  23656. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23657. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23658. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23659. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23660. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23661. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23662. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23663. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23664. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23665. sleepBody(impostor: PhysicsImpostor): void;
  23666. wakeUpBody(impostor: PhysicsImpostor): void;
  23667. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23668. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23669. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23670. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23671. getRadius(impostor: PhysicsImpostor): number;
  23672. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23673. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23674. dispose(): void;
  23675. }
  23676. /**
  23677. * Interface used to define a physics engine
  23678. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23679. */
  23680. export interface IPhysicsEngine {
  23681. /**
  23682. * Gets the gravity vector used by the simulation
  23683. */
  23684. gravity: Vector3;
  23685. /**
  23686. * Sets the gravity vector used by the simulation
  23687. * @param gravity defines the gravity vector to use
  23688. */
  23689. setGravity(gravity: Vector3): void;
  23690. /**
  23691. * Set the time step of the physics engine.
  23692. * Default is 1/60.
  23693. * To slow it down, enter 1/600 for example.
  23694. * To speed it up, 1/30
  23695. * @param newTimeStep the new timestep to apply to this world.
  23696. */
  23697. setTimeStep(newTimeStep: number): void;
  23698. /**
  23699. * Get the time step of the physics engine.
  23700. * @returns the current time step
  23701. */
  23702. getTimeStep(): number;
  23703. /**
  23704. * Set the sub time step of the physics engine.
  23705. * Default is 0 meaning there is no sub steps
  23706. * To increase physics resolution precision, set a small value (like 1 ms)
  23707. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23708. */
  23709. setSubTimeStep(subTimeStep: number): void;
  23710. /**
  23711. * Get the sub time step of the physics engine.
  23712. * @returns the current sub time step
  23713. */
  23714. getSubTimeStep(): number;
  23715. /**
  23716. * Release all resources
  23717. */
  23718. dispose(): void;
  23719. /**
  23720. * Gets the name of the current physics plugin
  23721. * @returns the name of the plugin
  23722. */
  23723. getPhysicsPluginName(): string;
  23724. /**
  23725. * Adding a new impostor for the impostor tracking.
  23726. * This will be done by the impostor itself.
  23727. * @param impostor the impostor to add
  23728. */
  23729. addImpostor(impostor: PhysicsImpostor): void;
  23730. /**
  23731. * Remove an impostor from the engine.
  23732. * This impostor and its mesh will not longer be updated by the physics engine.
  23733. * @param impostor the impostor to remove
  23734. */
  23735. removeImpostor(impostor: PhysicsImpostor): void;
  23736. /**
  23737. * Add a joint to the physics engine
  23738. * @param mainImpostor defines the main impostor to which the joint is added.
  23739. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23740. * @param joint defines the joint that will connect both impostors.
  23741. */
  23742. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23743. /**
  23744. * Removes a joint from the simulation
  23745. * @param mainImpostor defines the impostor used with the joint
  23746. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23747. * @param joint defines the joint to remove
  23748. */
  23749. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23750. /**
  23751. * Gets the current plugin used to run the simulation
  23752. * @returns current plugin
  23753. */
  23754. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23755. /**
  23756. * Gets the list of physic impostors
  23757. * @returns an array of PhysicsImpostor
  23758. */
  23759. getImpostors(): Array<PhysicsImpostor>;
  23760. /**
  23761. * Gets the impostor for a physics enabled object
  23762. * @param object defines the object impersonated by the impostor
  23763. * @returns the PhysicsImpostor or null if not found
  23764. */
  23765. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23766. /**
  23767. * Gets the impostor for a physics body object
  23768. * @param body defines physics body used by the impostor
  23769. * @returns the PhysicsImpostor or null if not found
  23770. */
  23771. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23772. /**
  23773. * Does a raycast in the physics world
  23774. * @param from when should the ray start?
  23775. * @param to when should the ray end?
  23776. * @returns PhysicsRaycastResult
  23777. */
  23778. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23779. /**
  23780. * Called by the scene. No need to call it.
  23781. * @param delta defines the timespam between frames
  23782. */
  23783. _step(delta: number): void;
  23784. }
  23785. }
  23786. declare module BABYLON {
  23787. /**
  23788. * The interface for the physics imposter parameters
  23789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23790. */
  23791. export interface PhysicsImpostorParameters {
  23792. /**
  23793. * The mass of the physics imposter
  23794. */
  23795. mass: number;
  23796. /**
  23797. * The friction of the physics imposter
  23798. */
  23799. friction?: number;
  23800. /**
  23801. * The coefficient of restitution of the physics imposter
  23802. */
  23803. restitution?: number;
  23804. /**
  23805. * The native options of the physics imposter
  23806. */
  23807. nativeOptions?: any;
  23808. /**
  23809. * Specifies if the parent should be ignored
  23810. */
  23811. ignoreParent?: boolean;
  23812. /**
  23813. * Specifies if bi-directional transformations should be disabled
  23814. */
  23815. disableBidirectionalTransformation?: boolean;
  23816. /**
  23817. * The pressure inside the physics imposter, soft object only
  23818. */
  23819. pressure?: number;
  23820. /**
  23821. * The stiffness the physics imposter, soft object only
  23822. */
  23823. stiffness?: number;
  23824. /**
  23825. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23826. */
  23827. velocityIterations?: number;
  23828. /**
  23829. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23830. */
  23831. positionIterations?: number;
  23832. /**
  23833. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23834. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23835. * Add to fix multiple points
  23836. */
  23837. fixedPoints?: number;
  23838. /**
  23839. * The collision margin around a soft object
  23840. */
  23841. margin?: number;
  23842. /**
  23843. * The collision margin around a soft object
  23844. */
  23845. damping?: number;
  23846. /**
  23847. * The path for a rope based on an extrusion
  23848. */
  23849. path?: any;
  23850. /**
  23851. * The shape of an extrusion used for a rope based on an extrusion
  23852. */
  23853. shape?: any;
  23854. }
  23855. /**
  23856. * Interface for a physics-enabled object
  23857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23858. */
  23859. export interface IPhysicsEnabledObject {
  23860. /**
  23861. * The position of the physics-enabled object
  23862. */
  23863. position: Vector3;
  23864. /**
  23865. * The rotation of the physics-enabled object
  23866. */
  23867. rotationQuaternion: Nullable<Quaternion>;
  23868. /**
  23869. * The scale of the physics-enabled object
  23870. */
  23871. scaling: Vector3;
  23872. /**
  23873. * The rotation of the physics-enabled object
  23874. */
  23875. rotation?: Vector3;
  23876. /**
  23877. * The parent of the physics-enabled object
  23878. */
  23879. parent?: any;
  23880. /**
  23881. * The bounding info of the physics-enabled object
  23882. * @returns The bounding info of the physics-enabled object
  23883. */
  23884. getBoundingInfo(): BoundingInfo;
  23885. /**
  23886. * Computes the world matrix
  23887. * @param force Specifies if the world matrix should be computed by force
  23888. * @returns A world matrix
  23889. */
  23890. computeWorldMatrix(force: boolean): Matrix;
  23891. /**
  23892. * Gets the world matrix
  23893. * @returns A world matrix
  23894. */
  23895. getWorldMatrix?(): Matrix;
  23896. /**
  23897. * Gets the child meshes
  23898. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23899. * @returns An array of abstract meshes
  23900. */
  23901. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23902. /**
  23903. * Gets the vertex data
  23904. * @param kind The type of vertex data
  23905. * @returns A nullable array of numbers, or a float32 array
  23906. */
  23907. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23908. /**
  23909. * Gets the indices from the mesh
  23910. * @returns A nullable array of index arrays
  23911. */
  23912. getIndices?(): Nullable<IndicesArray>;
  23913. /**
  23914. * Gets the scene from the mesh
  23915. * @returns the indices array or null
  23916. */
  23917. getScene?(): Scene;
  23918. /**
  23919. * Gets the absolute position from the mesh
  23920. * @returns the absolute position
  23921. */
  23922. getAbsolutePosition(): Vector3;
  23923. /**
  23924. * Gets the absolute pivot point from the mesh
  23925. * @returns the absolute pivot point
  23926. */
  23927. getAbsolutePivotPoint(): Vector3;
  23928. /**
  23929. * Rotates the mesh
  23930. * @param axis The axis of rotation
  23931. * @param amount The amount of rotation
  23932. * @param space The space of the rotation
  23933. * @returns The rotation transform node
  23934. */
  23935. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23936. /**
  23937. * Translates the mesh
  23938. * @param axis The axis of translation
  23939. * @param distance The distance of translation
  23940. * @param space The space of the translation
  23941. * @returns The transform node
  23942. */
  23943. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23944. /**
  23945. * Sets the absolute position of the mesh
  23946. * @param absolutePosition The absolute position of the mesh
  23947. * @returns The transform node
  23948. */
  23949. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23950. /**
  23951. * Gets the class name of the mesh
  23952. * @returns The class name
  23953. */
  23954. getClassName(): string;
  23955. }
  23956. /**
  23957. * Represents a physics imposter
  23958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23959. */
  23960. export class PhysicsImpostor {
  23961. /**
  23962. * The physics-enabled object used as the physics imposter
  23963. */
  23964. object: IPhysicsEnabledObject;
  23965. /**
  23966. * The type of the physics imposter
  23967. */
  23968. type: number;
  23969. private _options;
  23970. private _scene?;
  23971. /**
  23972. * The default object size of the imposter
  23973. */
  23974. static DEFAULT_OBJECT_SIZE: Vector3;
  23975. /**
  23976. * The identity quaternion of the imposter
  23977. */
  23978. static IDENTITY_QUATERNION: Quaternion;
  23979. /** @hidden */
  23980. _pluginData: any;
  23981. private _physicsEngine;
  23982. private _physicsBody;
  23983. private _bodyUpdateRequired;
  23984. private _onBeforePhysicsStepCallbacks;
  23985. private _onAfterPhysicsStepCallbacks;
  23986. /** @hidden */
  23987. _onPhysicsCollideCallbacks: Array<{
  23988. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23989. otherImpostors: Array<PhysicsImpostor>;
  23990. }>;
  23991. private _deltaPosition;
  23992. private _deltaRotation;
  23993. private _deltaRotationConjugated;
  23994. /** @hidden */
  23995. _isFromLine: boolean;
  23996. private _parent;
  23997. private _isDisposed;
  23998. private static _tmpVecs;
  23999. private static _tmpQuat;
  24000. /**
  24001. * Specifies if the physics imposter is disposed
  24002. */
  24003. get isDisposed(): boolean;
  24004. /**
  24005. * Gets the mass of the physics imposter
  24006. */
  24007. get mass(): number;
  24008. set mass(value: number);
  24009. /**
  24010. * Gets the coefficient of friction
  24011. */
  24012. get friction(): number;
  24013. /**
  24014. * Sets the coefficient of friction
  24015. */
  24016. set friction(value: number);
  24017. /**
  24018. * Gets the coefficient of restitution
  24019. */
  24020. get restitution(): number;
  24021. /**
  24022. * Sets the coefficient of restitution
  24023. */
  24024. set restitution(value: number);
  24025. /**
  24026. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24027. */
  24028. get pressure(): number;
  24029. /**
  24030. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24031. */
  24032. set pressure(value: number);
  24033. /**
  24034. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24035. */
  24036. get stiffness(): number;
  24037. /**
  24038. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24039. */
  24040. set stiffness(value: number);
  24041. /**
  24042. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24043. */
  24044. get velocityIterations(): number;
  24045. /**
  24046. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24047. */
  24048. set velocityIterations(value: number);
  24049. /**
  24050. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24051. */
  24052. get positionIterations(): number;
  24053. /**
  24054. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24055. */
  24056. set positionIterations(value: number);
  24057. /**
  24058. * The unique id of the physics imposter
  24059. * set by the physics engine when adding this impostor to the array
  24060. */
  24061. uniqueId: number;
  24062. /**
  24063. * @hidden
  24064. */
  24065. soft: boolean;
  24066. /**
  24067. * @hidden
  24068. */
  24069. segments: number;
  24070. private _joints;
  24071. /**
  24072. * Initializes the physics imposter
  24073. * @param object The physics-enabled object used as the physics imposter
  24074. * @param type The type of the physics imposter
  24075. * @param _options The options for the physics imposter
  24076. * @param _scene The Babylon scene
  24077. */
  24078. constructor(
  24079. /**
  24080. * The physics-enabled object used as the physics imposter
  24081. */
  24082. object: IPhysicsEnabledObject,
  24083. /**
  24084. * The type of the physics imposter
  24085. */
  24086. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24087. /**
  24088. * This function will completly initialize this impostor.
  24089. * It will create a new body - but only if this mesh has no parent.
  24090. * If it has, this impostor will not be used other than to define the impostor
  24091. * of the child mesh.
  24092. * @hidden
  24093. */
  24094. _init(): void;
  24095. private _getPhysicsParent;
  24096. /**
  24097. * Should a new body be generated.
  24098. * @returns boolean specifying if body initialization is required
  24099. */
  24100. isBodyInitRequired(): boolean;
  24101. /**
  24102. * Sets the updated scaling
  24103. * @param updated Specifies if the scaling is updated
  24104. */
  24105. setScalingUpdated(): void;
  24106. /**
  24107. * Force a regeneration of this or the parent's impostor's body.
  24108. * Use under cautious - This will remove all joints already implemented.
  24109. */
  24110. forceUpdate(): void;
  24111. /**
  24112. * Gets the body that holds this impostor. Either its own, or its parent.
  24113. */
  24114. get physicsBody(): any;
  24115. /**
  24116. * Get the parent of the physics imposter
  24117. * @returns Physics imposter or null
  24118. */
  24119. get parent(): Nullable<PhysicsImpostor>;
  24120. /**
  24121. * Sets the parent of the physics imposter
  24122. */
  24123. set parent(value: Nullable<PhysicsImpostor>);
  24124. /**
  24125. * Set the physics body. Used mainly by the physics engine/plugin
  24126. */
  24127. set physicsBody(physicsBody: any);
  24128. /**
  24129. * Resets the update flags
  24130. */
  24131. resetUpdateFlags(): void;
  24132. /**
  24133. * Gets the object extend size
  24134. * @returns the object extend size
  24135. */
  24136. getObjectExtendSize(): Vector3;
  24137. /**
  24138. * Gets the object center
  24139. * @returns The object center
  24140. */
  24141. getObjectCenter(): Vector3;
  24142. /**
  24143. * Get a specific parameter from the options parameters
  24144. * @param paramName The object parameter name
  24145. * @returns The object parameter
  24146. */
  24147. getParam(paramName: string): any;
  24148. /**
  24149. * Sets a specific parameter in the options given to the physics plugin
  24150. * @param paramName The parameter name
  24151. * @param value The value of the parameter
  24152. */
  24153. setParam(paramName: string, value: number): void;
  24154. /**
  24155. * Specifically change the body's mass option. Won't recreate the physics body object
  24156. * @param mass The mass of the physics imposter
  24157. */
  24158. setMass(mass: number): void;
  24159. /**
  24160. * Gets the linear velocity
  24161. * @returns linear velocity or null
  24162. */
  24163. getLinearVelocity(): Nullable<Vector3>;
  24164. /**
  24165. * Sets the linear velocity
  24166. * @param velocity linear velocity or null
  24167. */
  24168. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24169. /**
  24170. * Gets the angular velocity
  24171. * @returns angular velocity or null
  24172. */
  24173. getAngularVelocity(): Nullable<Vector3>;
  24174. /**
  24175. * Sets the angular velocity
  24176. * @param velocity The velocity or null
  24177. */
  24178. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24179. /**
  24180. * Execute a function with the physics plugin native code
  24181. * Provide a function the will have two variables - the world object and the physics body object
  24182. * @param func The function to execute with the physics plugin native code
  24183. */
  24184. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24185. /**
  24186. * Register a function that will be executed before the physics world is stepping forward
  24187. * @param func The function to execute before the physics world is stepped forward
  24188. */
  24189. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24190. /**
  24191. * Unregister a function that will be executed before the physics world is stepping forward
  24192. * @param func The function to execute before the physics world is stepped forward
  24193. */
  24194. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24195. /**
  24196. * Register a function that will be executed after the physics step
  24197. * @param func The function to execute after physics step
  24198. */
  24199. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24200. /**
  24201. * Unregisters a function that will be executed after the physics step
  24202. * @param func The function to execute after physics step
  24203. */
  24204. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24205. /**
  24206. * register a function that will be executed when this impostor collides against a different body
  24207. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24208. * @param func Callback that is executed on collision
  24209. */
  24210. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24211. /**
  24212. * Unregisters the physics imposter on contact
  24213. * @param collideAgainst The physics object to collide against
  24214. * @param func Callback to execute on collision
  24215. */
  24216. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24217. private _tmpQuat;
  24218. private _tmpQuat2;
  24219. /**
  24220. * Get the parent rotation
  24221. * @returns The parent rotation
  24222. */
  24223. getParentsRotation(): Quaternion;
  24224. /**
  24225. * this function is executed by the physics engine.
  24226. */
  24227. beforeStep: () => void;
  24228. /**
  24229. * this function is executed by the physics engine
  24230. */
  24231. afterStep: () => void;
  24232. /**
  24233. * Legacy collision detection event support
  24234. */
  24235. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24236. /**
  24237. * event and body object due to cannon's event-based architecture.
  24238. */
  24239. onCollide: (e: {
  24240. body: any;
  24241. }) => void;
  24242. /**
  24243. * Apply a force
  24244. * @param force The force to apply
  24245. * @param contactPoint The contact point for the force
  24246. * @returns The physics imposter
  24247. */
  24248. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24249. /**
  24250. * Apply an impulse
  24251. * @param force The impulse force
  24252. * @param contactPoint The contact point for the impulse force
  24253. * @returns The physics imposter
  24254. */
  24255. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24256. /**
  24257. * A help function to create a joint
  24258. * @param otherImpostor A physics imposter used to create a joint
  24259. * @param jointType The type of joint
  24260. * @param jointData The data for the joint
  24261. * @returns The physics imposter
  24262. */
  24263. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24264. /**
  24265. * Add a joint to this impostor with a different impostor
  24266. * @param otherImpostor A physics imposter used to add a joint
  24267. * @param joint The joint to add
  24268. * @returns The physics imposter
  24269. */
  24270. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24271. /**
  24272. * Add an anchor to a cloth impostor
  24273. * @param otherImpostor rigid impostor to anchor to
  24274. * @param width ratio across width from 0 to 1
  24275. * @param height ratio up height from 0 to 1
  24276. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24277. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24278. * @returns impostor the soft imposter
  24279. */
  24280. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24281. /**
  24282. * Add a hook to a rope impostor
  24283. * @param otherImpostor rigid impostor to anchor to
  24284. * @param length ratio across rope from 0 to 1
  24285. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24286. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24287. * @returns impostor the rope imposter
  24288. */
  24289. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24290. /**
  24291. * Will keep this body still, in a sleep mode.
  24292. * @returns the physics imposter
  24293. */
  24294. sleep(): PhysicsImpostor;
  24295. /**
  24296. * Wake the body up.
  24297. * @returns The physics imposter
  24298. */
  24299. wakeUp(): PhysicsImpostor;
  24300. /**
  24301. * Clones the physics imposter
  24302. * @param newObject The physics imposter clones to this physics-enabled object
  24303. * @returns A nullable physics imposter
  24304. */
  24305. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24306. /**
  24307. * Disposes the physics imposter
  24308. */
  24309. dispose(): void;
  24310. /**
  24311. * Sets the delta position
  24312. * @param position The delta position amount
  24313. */
  24314. setDeltaPosition(position: Vector3): void;
  24315. /**
  24316. * Sets the delta rotation
  24317. * @param rotation The delta rotation amount
  24318. */
  24319. setDeltaRotation(rotation: Quaternion): void;
  24320. /**
  24321. * Gets the box size of the physics imposter and stores the result in the input parameter
  24322. * @param result Stores the box size
  24323. * @returns The physics imposter
  24324. */
  24325. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24326. /**
  24327. * Gets the radius of the physics imposter
  24328. * @returns Radius of the physics imposter
  24329. */
  24330. getRadius(): number;
  24331. /**
  24332. * Sync a bone with this impostor
  24333. * @param bone The bone to sync to the impostor.
  24334. * @param boneMesh The mesh that the bone is influencing.
  24335. * @param jointPivot The pivot of the joint / bone in local space.
  24336. * @param distToJoint Optional distance from the impostor to the joint.
  24337. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24338. */
  24339. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24340. /**
  24341. * Sync impostor to a bone
  24342. * @param bone The bone that the impostor will be synced to.
  24343. * @param boneMesh The mesh that the bone is influencing.
  24344. * @param jointPivot The pivot of the joint / bone in local space.
  24345. * @param distToJoint Optional distance from the impostor to the joint.
  24346. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24347. * @param boneAxis Optional vector3 axis the bone is aligned with
  24348. */
  24349. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24350. /**
  24351. * No-Imposter type
  24352. */
  24353. static NoImpostor: number;
  24354. /**
  24355. * Sphere-Imposter type
  24356. */
  24357. static SphereImpostor: number;
  24358. /**
  24359. * Box-Imposter type
  24360. */
  24361. static BoxImpostor: number;
  24362. /**
  24363. * Plane-Imposter type
  24364. */
  24365. static PlaneImpostor: number;
  24366. /**
  24367. * Mesh-imposter type
  24368. */
  24369. static MeshImpostor: number;
  24370. /**
  24371. * Capsule-Impostor type (Ammo.js plugin only)
  24372. */
  24373. static CapsuleImpostor: number;
  24374. /**
  24375. * Cylinder-Imposter type
  24376. */
  24377. static CylinderImpostor: number;
  24378. /**
  24379. * Particle-Imposter type
  24380. */
  24381. static ParticleImpostor: number;
  24382. /**
  24383. * Heightmap-Imposter type
  24384. */
  24385. static HeightmapImpostor: number;
  24386. /**
  24387. * ConvexHull-Impostor type (Ammo.js plugin only)
  24388. */
  24389. static ConvexHullImpostor: number;
  24390. /**
  24391. * Custom-Imposter type (Ammo.js plugin only)
  24392. */
  24393. static CustomImpostor: number;
  24394. /**
  24395. * Rope-Imposter type
  24396. */
  24397. static RopeImpostor: number;
  24398. /**
  24399. * Cloth-Imposter type
  24400. */
  24401. static ClothImpostor: number;
  24402. /**
  24403. * Softbody-Imposter type
  24404. */
  24405. static SoftbodyImpostor: number;
  24406. }
  24407. }
  24408. declare module BABYLON {
  24409. /**
  24410. * @hidden
  24411. **/
  24412. export class _CreationDataStorage {
  24413. closePath?: boolean;
  24414. closeArray?: boolean;
  24415. idx: number[];
  24416. dashSize: number;
  24417. gapSize: number;
  24418. path3D: Path3D;
  24419. pathArray: Vector3[][];
  24420. arc: number;
  24421. radius: number;
  24422. cap: number;
  24423. tessellation: number;
  24424. }
  24425. /**
  24426. * @hidden
  24427. **/
  24428. class _InstanceDataStorage {
  24429. visibleInstances: any;
  24430. batchCache: _InstancesBatch;
  24431. instancesBufferSize: number;
  24432. instancesBuffer: Nullable<Buffer>;
  24433. instancesData: Float32Array;
  24434. overridenInstanceCount: number;
  24435. isFrozen: boolean;
  24436. previousBatch: Nullable<_InstancesBatch>;
  24437. hardwareInstancedRendering: boolean;
  24438. sideOrientation: number;
  24439. manualUpdate: boolean;
  24440. }
  24441. /**
  24442. * @hidden
  24443. **/
  24444. export class _InstancesBatch {
  24445. mustReturn: boolean;
  24446. visibleInstances: Nullable<InstancedMesh[]>[];
  24447. renderSelf: boolean[];
  24448. hardwareInstancedRendering: boolean[];
  24449. }
  24450. /**
  24451. * Class used to represent renderable models
  24452. */
  24453. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24454. /**
  24455. * Mesh side orientation : usually the external or front surface
  24456. */
  24457. static readonly FRONTSIDE: number;
  24458. /**
  24459. * Mesh side orientation : usually the internal or back surface
  24460. */
  24461. static readonly BACKSIDE: number;
  24462. /**
  24463. * Mesh side orientation : both internal and external or front and back surfaces
  24464. */
  24465. static readonly DOUBLESIDE: number;
  24466. /**
  24467. * Mesh side orientation : by default, `FRONTSIDE`
  24468. */
  24469. static readonly DEFAULTSIDE: number;
  24470. /**
  24471. * Mesh cap setting : no cap
  24472. */
  24473. static readonly NO_CAP: number;
  24474. /**
  24475. * Mesh cap setting : one cap at the beginning of the mesh
  24476. */
  24477. static readonly CAP_START: number;
  24478. /**
  24479. * Mesh cap setting : one cap at the end of the mesh
  24480. */
  24481. static readonly CAP_END: number;
  24482. /**
  24483. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24484. */
  24485. static readonly CAP_ALL: number;
  24486. /**
  24487. * Mesh pattern setting : no flip or rotate
  24488. */
  24489. static readonly NO_FLIP: number;
  24490. /**
  24491. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24492. */
  24493. static readonly FLIP_TILE: number;
  24494. /**
  24495. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24496. */
  24497. static readonly ROTATE_TILE: number;
  24498. /**
  24499. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24500. */
  24501. static readonly FLIP_ROW: number;
  24502. /**
  24503. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24504. */
  24505. static readonly ROTATE_ROW: number;
  24506. /**
  24507. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24508. */
  24509. static readonly FLIP_N_ROTATE_TILE: number;
  24510. /**
  24511. * Mesh pattern setting : rotate pattern and rotate
  24512. */
  24513. static readonly FLIP_N_ROTATE_ROW: number;
  24514. /**
  24515. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24516. */
  24517. static readonly CENTER: number;
  24518. /**
  24519. * Mesh tile positioning : part tiles on left
  24520. */
  24521. static readonly LEFT: number;
  24522. /**
  24523. * Mesh tile positioning : part tiles on right
  24524. */
  24525. static readonly RIGHT: number;
  24526. /**
  24527. * Mesh tile positioning : part tiles on top
  24528. */
  24529. static readonly TOP: number;
  24530. /**
  24531. * Mesh tile positioning : part tiles on bottom
  24532. */
  24533. static readonly BOTTOM: number;
  24534. /**
  24535. * Gets the default side orientation.
  24536. * @param orientation the orientation to value to attempt to get
  24537. * @returns the default orientation
  24538. * @hidden
  24539. */
  24540. static _GetDefaultSideOrientation(orientation?: number): number;
  24541. private _internalMeshDataInfo;
  24542. /**
  24543. * An event triggered before rendering the mesh
  24544. */
  24545. get onBeforeRenderObservable(): Observable<Mesh>;
  24546. /**
  24547. * An event triggered before binding the mesh
  24548. */
  24549. get onBeforeBindObservable(): Observable<Mesh>;
  24550. /**
  24551. * An event triggered after rendering the mesh
  24552. */
  24553. get onAfterRenderObservable(): Observable<Mesh>;
  24554. /**
  24555. * An event triggered before drawing the mesh
  24556. */
  24557. get onBeforeDrawObservable(): Observable<Mesh>;
  24558. private _onBeforeDrawObserver;
  24559. /**
  24560. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24561. */
  24562. set onBeforeDraw(callback: () => void);
  24563. get hasInstances(): boolean;
  24564. /**
  24565. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24566. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24567. */
  24568. delayLoadState: number;
  24569. /**
  24570. * Gets the list of instances created from this mesh
  24571. * it is not supposed to be modified manually.
  24572. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24573. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24574. */
  24575. instances: InstancedMesh[];
  24576. /**
  24577. * Gets the file containing delay loading data for this mesh
  24578. */
  24579. delayLoadingFile: string;
  24580. /** @hidden */
  24581. _binaryInfo: any;
  24582. /**
  24583. * User defined function used to change how LOD level selection is done
  24584. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24585. */
  24586. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24587. /**
  24588. * Gets or sets the morph target manager
  24589. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24590. */
  24591. get morphTargetManager(): Nullable<MorphTargetManager>;
  24592. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24593. /** @hidden */
  24594. _creationDataStorage: Nullable<_CreationDataStorage>;
  24595. /** @hidden */
  24596. _geometry: Nullable<Geometry>;
  24597. /** @hidden */
  24598. _delayInfo: Array<string>;
  24599. /** @hidden */
  24600. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24601. /** @hidden */
  24602. _instanceDataStorage: _InstanceDataStorage;
  24603. private _effectiveMaterial;
  24604. /** @hidden */
  24605. _shouldGenerateFlatShading: boolean;
  24606. /** @hidden */
  24607. _originalBuilderSideOrientation: number;
  24608. /**
  24609. * Use this property to change the original side orientation defined at construction time
  24610. */
  24611. overrideMaterialSideOrientation: Nullable<number>;
  24612. /**
  24613. * Gets the source mesh (the one used to clone this one from)
  24614. */
  24615. get source(): Nullable<Mesh>;
  24616. /**
  24617. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24618. */
  24619. get isUnIndexed(): boolean;
  24620. set isUnIndexed(value: boolean);
  24621. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24622. get worldMatrixInstancedBuffer(): Float32Array;
  24623. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24624. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24625. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24626. /**
  24627. * @constructor
  24628. * @param name The value used by scene.getMeshByName() to do a lookup.
  24629. * @param scene The scene to add this mesh to.
  24630. * @param parent The parent of this mesh, if it has one
  24631. * @param source An optional Mesh from which geometry is shared, cloned.
  24632. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24633. * When false, achieved by calling a clone(), also passing False.
  24634. * This will make creation of children, recursive.
  24635. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24636. */
  24637. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24638. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24639. doNotInstantiate: boolean;
  24640. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24641. /**
  24642. * Gets the class name
  24643. * @returns the string "Mesh".
  24644. */
  24645. getClassName(): string;
  24646. /** @hidden */
  24647. get _isMesh(): boolean;
  24648. /**
  24649. * Returns a description of this mesh
  24650. * @param fullDetails define if full details about this mesh must be used
  24651. * @returns a descriptive string representing this mesh
  24652. */
  24653. toString(fullDetails?: boolean): string;
  24654. /** @hidden */
  24655. _unBindEffect(): void;
  24656. /**
  24657. * Gets a boolean indicating if this mesh has LOD
  24658. */
  24659. get hasLODLevels(): boolean;
  24660. /**
  24661. * Gets the list of MeshLODLevel associated with the current mesh
  24662. * @returns an array of MeshLODLevel
  24663. */
  24664. getLODLevels(): MeshLODLevel[];
  24665. private _sortLODLevels;
  24666. /**
  24667. * Add a mesh as LOD level triggered at the given distance.
  24668. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24669. * @param distance The distance from the center of the object to show this level
  24670. * @param mesh The mesh to be added as LOD level (can be null)
  24671. * @return This mesh (for chaining)
  24672. */
  24673. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24674. /**
  24675. * Returns the LOD level mesh at the passed distance or null if not found.
  24676. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24677. * @param distance The distance from the center of the object to show this level
  24678. * @returns a Mesh or `null`
  24679. */
  24680. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24681. /**
  24682. * Remove a mesh from the LOD array
  24683. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24684. * @param mesh defines the mesh to be removed
  24685. * @return This mesh (for chaining)
  24686. */
  24687. removeLODLevel(mesh: Mesh): Mesh;
  24688. /**
  24689. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24690. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24691. * @param camera defines the camera to use to compute distance
  24692. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24693. * @return This mesh (for chaining)
  24694. */
  24695. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24696. /**
  24697. * Gets the mesh internal Geometry object
  24698. */
  24699. get geometry(): Nullable<Geometry>;
  24700. /**
  24701. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24702. * @returns the total number of vertices
  24703. */
  24704. getTotalVertices(): number;
  24705. /**
  24706. * Returns the content of an associated vertex buffer
  24707. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24708. * - VertexBuffer.PositionKind
  24709. * - VertexBuffer.UVKind
  24710. * - VertexBuffer.UV2Kind
  24711. * - VertexBuffer.UV3Kind
  24712. * - VertexBuffer.UV4Kind
  24713. * - VertexBuffer.UV5Kind
  24714. * - VertexBuffer.UV6Kind
  24715. * - VertexBuffer.ColorKind
  24716. * - VertexBuffer.MatricesIndicesKind
  24717. * - VertexBuffer.MatricesIndicesExtraKind
  24718. * - VertexBuffer.MatricesWeightsKind
  24719. * - VertexBuffer.MatricesWeightsExtraKind
  24720. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  24721. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24722. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24723. */
  24724. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24725. /**
  24726. * Returns the mesh VertexBuffer object from the requested `kind`
  24727. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24728. * - VertexBuffer.PositionKind
  24729. * - VertexBuffer.NormalKind
  24730. * - VertexBuffer.UVKind
  24731. * - VertexBuffer.UV2Kind
  24732. * - VertexBuffer.UV3Kind
  24733. * - VertexBuffer.UV4Kind
  24734. * - VertexBuffer.UV5Kind
  24735. * - VertexBuffer.UV6Kind
  24736. * - VertexBuffer.ColorKind
  24737. * - VertexBuffer.MatricesIndicesKind
  24738. * - VertexBuffer.MatricesIndicesExtraKind
  24739. * - VertexBuffer.MatricesWeightsKind
  24740. * - VertexBuffer.MatricesWeightsExtraKind
  24741. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24742. */
  24743. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24744. /**
  24745. * Tests if a specific vertex buffer is associated with this mesh
  24746. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24747. * - VertexBuffer.PositionKind
  24748. * - VertexBuffer.NormalKind
  24749. * - VertexBuffer.UVKind
  24750. * - VertexBuffer.UV2Kind
  24751. * - VertexBuffer.UV3Kind
  24752. * - VertexBuffer.UV4Kind
  24753. * - VertexBuffer.UV5Kind
  24754. * - VertexBuffer.UV6Kind
  24755. * - VertexBuffer.ColorKind
  24756. * - VertexBuffer.MatricesIndicesKind
  24757. * - VertexBuffer.MatricesIndicesExtraKind
  24758. * - VertexBuffer.MatricesWeightsKind
  24759. * - VertexBuffer.MatricesWeightsExtraKind
  24760. * @returns a boolean
  24761. */
  24762. isVerticesDataPresent(kind: string): boolean;
  24763. /**
  24764. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24765. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24766. * - VertexBuffer.PositionKind
  24767. * - VertexBuffer.UVKind
  24768. * - VertexBuffer.UV2Kind
  24769. * - VertexBuffer.UV3Kind
  24770. * - VertexBuffer.UV4Kind
  24771. * - VertexBuffer.UV5Kind
  24772. * - VertexBuffer.UV6Kind
  24773. * - VertexBuffer.ColorKind
  24774. * - VertexBuffer.MatricesIndicesKind
  24775. * - VertexBuffer.MatricesIndicesExtraKind
  24776. * - VertexBuffer.MatricesWeightsKind
  24777. * - VertexBuffer.MatricesWeightsExtraKind
  24778. * @returns a boolean
  24779. */
  24780. isVertexBufferUpdatable(kind: string): boolean;
  24781. /**
  24782. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24783. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24784. * - VertexBuffer.PositionKind
  24785. * - VertexBuffer.NormalKind
  24786. * - VertexBuffer.UVKind
  24787. * - VertexBuffer.UV2Kind
  24788. * - VertexBuffer.UV3Kind
  24789. * - VertexBuffer.UV4Kind
  24790. * - VertexBuffer.UV5Kind
  24791. * - VertexBuffer.UV6Kind
  24792. * - VertexBuffer.ColorKind
  24793. * - VertexBuffer.MatricesIndicesKind
  24794. * - VertexBuffer.MatricesIndicesExtraKind
  24795. * - VertexBuffer.MatricesWeightsKind
  24796. * - VertexBuffer.MatricesWeightsExtraKind
  24797. * @returns an array of strings
  24798. */
  24799. getVerticesDataKinds(): string[];
  24800. /**
  24801. * Returns a positive integer : the total number of indices in this mesh geometry.
  24802. * @returns the numner of indices or zero if the mesh has no geometry.
  24803. */
  24804. getTotalIndices(): number;
  24805. /**
  24806. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24807. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  24808. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24809. * @returns the indices array or an empty array if the mesh has no geometry
  24810. */
  24811. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24812. get isBlocked(): boolean;
  24813. /**
  24814. * Determine if the current mesh is ready to be rendered
  24815. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24816. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24817. * @returns true if all associated assets are ready (material, textures, shaders)
  24818. */
  24819. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24820. /**
  24821. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  24822. */
  24823. get areNormalsFrozen(): boolean;
  24824. /**
  24825. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24826. * @returns the current mesh
  24827. */
  24828. freezeNormals(): Mesh;
  24829. /**
  24830. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  24831. * @returns the current mesh
  24832. */
  24833. unfreezeNormals(): Mesh;
  24834. /**
  24835. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24836. */
  24837. set overridenInstanceCount(count: number);
  24838. /** @hidden */
  24839. _preActivate(): Mesh;
  24840. /** @hidden */
  24841. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24842. /** @hidden */
  24843. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24844. /**
  24845. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24846. * This means the mesh underlying bounding box and sphere are recomputed.
  24847. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24848. * @returns the current mesh
  24849. */
  24850. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24851. /** @hidden */
  24852. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24853. /**
  24854. * This function will subdivide the mesh into multiple submeshes
  24855. * @param count defines the expected number of submeshes
  24856. */
  24857. subdivide(count: number): void;
  24858. /**
  24859. * Copy a FloatArray into a specific associated vertex buffer
  24860. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24861. * - VertexBuffer.PositionKind
  24862. * - VertexBuffer.UVKind
  24863. * - VertexBuffer.UV2Kind
  24864. * - VertexBuffer.UV3Kind
  24865. * - VertexBuffer.UV4Kind
  24866. * - VertexBuffer.UV5Kind
  24867. * - VertexBuffer.UV6Kind
  24868. * - VertexBuffer.ColorKind
  24869. * - VertexBuffer.MatricesIndicesKind
  24870. * - VertexBuffer.MatricesIndicesExtraKind
  24871. * - VertexBuffer.MatricesWeightsKind
  24872. * - VertexBuffer.MatricesWeightsExtraKind
  24873. * @param data defines the data source
  24874. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24875. * @param stride defines the data stride size (can be null)
  24876. * @returns the current mesh
  24877. */
  24878. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24879. /**
  24880. * Delete a vertex buffer associated with this mesh
  24881. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24882. * - VertexBuffer.PositionKind
  24883. * - VertexBuffer.UVKind
  24884. * - VertexBuffer.UV2Kind
  24885. * - VertexBuffer.UV3Kind
  24886. * - VertexBuffer.UV4Kind
  24887. * - VertexBuffer.UV5Kind
  24888. * - VertexBuffer.UV6Kind
  24889. * - VertexBuffer.ColorKind
  24890. * - VertexBuffer.MatricesIndicesKind
  24891. * - VertexBuffer.MatricesIndicesExtraKind
  24892. * - VertexBuffer.MatricesWeightsKind
  24893. * - VertexBuffer.MatricesWeightsExtraKind
  24894. */
  24895. removeVerticesData(kind: string): void;
  24896. /**
  24897. * Flags an associated vertex buffer as updatable
  24898. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24899. * - VertexBuffer.PositionKind
  24900. * - VertexBuffer.UVKind
  24901. * - VertexBuffer.UV2Kind
  24902. * - VertexBuffer.UV3Kind
  24903. * - VertexBuffer.UV4Kind
  24904. * - VertexBuffer.UV5Kind
  24905. * - VertexBuffer.UV6Kind
  24906. * - VertexBuffer.ColorKind
  24907. * - VertexBuffer.MatricesIndicesKind
  24908. * - VertexBuffer.MatricesIndicesExtraKind
  24909. * - VertexBuffer.MatricesWeightsKind
  24910. * - VertexBuffer.MatricesWeightsExtraKind
  24911. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24912. */
  24913. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24914. /**
  24915. * Sets the mesh global Vertex Buffer
  24916. * @param buffer defines the buffer to use
  24917. * @returns the current mesh
  24918. */
  24919. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24920. /**
  24921. * Update a specific associated vertex buffer
  24922. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24923. * - VertexBuffer.PositionKind
  24924. * - VertexBuffer.UVKind
  24925. * - VertexBuffer.UV2Kind
  24926. * - VertexBuffer.UV3Kind
  24927. * - VertexBuffer.UV4Kind
  24928. * - VertexBuffer.UV5Kind
  24929. * - VertexBuffer.UV6Kind
  24930. * - VertexBuffer.ColorKind
  24931. * - VertexBuffer.MatricesIndicesKind
  24932. * - VertexBuffer.MatricesIndicesExtraKind
  24933. * - VertexBuffer.MatricesWeightsKind
  24934. * - VertexBuffer.MatricesWeightsExtraKind
  24935. * @param data defines the data source
  24936. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24937. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  24938. * @returns the current mesh
  24939. */
  24940. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24941. /**
  24942. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24943. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24944. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24945. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24946. * @returns the current mesh
  24947. */
  24948. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24949. /**
  24950. * Creates a un-shared specific occurence of the geometry for the mesh.
  24951. * @returns the current mesh
  24952. */
  24953. makeGeometryUnique(): Mesh;
  24954. /**
  24955. * Set the index buffer of this mesh
  24956. * @param indices defines the source data
  24957. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24958. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24959. * @returns the current mesh
  24960. */
  24961. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24962. /**
  24963. * Update the current index buffer
  24964. * @param indices defines the source data
  24965. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24966. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24967. * @returns the current mesh
  24968. */
  24969. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24970. /**
  24971. * Invert the geometry to move from a right handed system to a left handed one.
  24972. * @returns the current mesh
  24973. */
  24974. toLeftHanded(): Mesh;
  24975. /** @hidden */
  24976. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24977. /** @hidden */
  24978. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24979. /**
  24980. * Registers for this mesh a javascript function called just before the rendering process
  24981. * @param func defines the function to call before rendering this mesh
  24982. * @returns the current mesh
  24983. */
  24984. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24985. /**
  24986. * Disposes a previously registered javascript function called before the rendering
  24987. * @param func defines the function to remove
  24988. * @returns the current mesh
  24989. */
  24990. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24991. /**
  24992. * Registers for this mesh a javascript function called just after the rendering is complete
  24993. * @param func defines the function to call after rendering this mesh
  24994. * @returns the current mesh
  24995. */
  24996. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24997. /**
  24998. * Disposes a previously registered javascript function called after the rendering.
  24999. * @param func defines the function to remove
  25000. * @returns the current mesh
  25001. */
  25002. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25003. /** @hidden */
  25004. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25005. /** @hidden */
  25006. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25007. /** @hidden */
  25008. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25009. /** @hidden */
  25010. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25011. /** @hidden */
  25012. _rebuild(): void;
  25013. /** @hidden */
  25014. _freeze(): void;
  25015. /** @hidden */
  25016. _unFreeze(): void;
  25017. /**
  25018. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  25019. * @param subMesh defines the subMesh to render
  25020. * @param enableAlphaMode defines if alpha mode can be changed
  25021. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25022. * @returns the current mesh
  25023. */
  25024. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25025. private _onBeforeDraw;
  25026. /**
  25027. * Renormalize the mesh and patch it up if there are no weights
  25028. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25029. * However in the case of zero weights then we set just a single influence to 1.
  25030. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25031. */
  25032. cleanMatrixWeights(): void;
  25033. private normalizeSkinFourWeights;
  25034. private normalizeSkinWeightsAndExtra;
  25035. /**
  25036. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25037. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25038. * the user know there was an issue with importing the mesh
  25039. * @returns a validation object with skinned, valid and report string
  25040. */
  25041. validateSkinning(): {
  25042. skinned: boolean;
  25043. valid: boolean;
  25044. report: string;
  25045. };
  25046. /** @hidden */
  25047. _checkDelayState(): Mesh;
  25048. private _queueLoad;
  25049. /**
  25050. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25051. * A mesh is in the frustum if its bounding box intersects the frustum
  25052. * @param frustumPlanes defines the frustum to test
  25053. * @returns true if the mesh is in the frustum planes
  25054. */
  25055. isInFrustum(frustumPlanes: Plane[]): boolean;
  25056. /**
  25057. * Sets the mesh material by the material or multiMaterial `id` property
  25058. * @param id is a string identifying the material or the multiMaterial
  25059. * @returns the current mesh
  25060. */
  25061. setMaterialByID(id: string): Mesh;
  25062. /**
  25063. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25064. * @returns an array of IAnimatable
  25065. */
  25066. getAnimatables(): IAnimatable[];
  25067. /**
  25068. * Modifies the mesh geometry according to the passed transformation matrix.
  25069. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25070. * The mesh normals are modified using the same transformation.
  25071. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25072. * @param transform defines the transform matrix to use
  25073. * @see http://doc.babylonjs.com/resources/baking_transformations
  25074. * @returns the current mesh
  25075. */
  25076. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25077. /**
  25078. * Modifies the mesh geometry according to its own current World Matrix.
  25079. * The mesh World Matrix is then reset.
  25080. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25081. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25082. * @see http://doc.babylonjs.com/resources/baking_transformations
  25083. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25084. * @returns the current mesh
  25085. */
  25086. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25087. /** @hidden */
  25088. get _positions(): Nullable<Vector3[]>;
  25089. /** @hidden */
  25090. _resetPointsArrayCache(): Mesh;
  25091. /** @hidden */
  25092. _generatePointsArray(): boolean;
  25093. /**
  25094. * Returns a new Mesh object generated from the current mesh properties.
  25095. * This method must not get confused with createInstance()
  25096. * @param name is a string, the name given to the new mesh
  25097. * @param newParent can be any Node object (default `null`)
  25098. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25099. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25100. * @returns a new mesh
  25101. */
  25102. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25103. /**
  25104. * Releases resources associated with this mesh.
  25105. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25106. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25107. */
  25108. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25109. /** @hidden */
  25110. _disposeInstanceSpecificData(): void;
  25111. /**
  25112. * Modifies the mesh geometry according to a displacement map.
  25113. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  25114. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25115. * @param url is a string, the URL from the image file is to be downloaded.
  25116. * @param minHeight is the lower limit of the displacement.
  25117. * @param maxHeight is the upper limit of the displacement.
  25118. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  25119. * @param uvOffset is an optional vector2 used to offset UV.
  25120. * @param uvScale is an optional vector2 used to scale UV.
  25121. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  25122. * @returns the Mesh.
  25123. */
  25124. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25125. /**
  25126. * Modifies the mesh geometry according to a displacementMap buffer.
  25127. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  25128. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25129. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25130. * @param heightMapWidth is the width of the buffer image.
  25131. * @param heightMapHeight is the height of the buffer image.
  25132. * @param minHeight is the lower limit of the displacement.
  25133. * @param maxHeight is the upper limit of the displacement.
  25134. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  25135. * @param uvOffset is an optional vector2 used to offset UV.
  25136. * @param uvScale is an optional vector2 used to scale UV.
  25137. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  25138. * @returns the Mesh.
  25139. */
  25140. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25141. /**
  25142. * Modify the mesh to get a flat shading rendering.
  25143. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25144. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25145. * @returns current mesh
  25146. */
  25147. convertToFlatShadedMesh(): Mesh;
  25148. /**
  25149. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25150. * In other words, more vertices, no more indices and a single bigger VBO.
  25151. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25152. * @returns current mesh
  25153. */
  25154. convertToUnIndexedMesh(): Mesh;
  25155. /**
  25156. * Inverses facet orientations.
  25157. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25158. * @param flipNormals will also inverts the normals
  25159. * @returns current mesh
  25160. */
  25161. flipFaces(flipNormals?: boolean): Mesh;
  25162. /**
  25163. * Increase the number of facets and hence vertices in a mesh
  25164. * Vertex normals are interpolated from existing vertex normals
  25165. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25166. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25167. */
  25168. increaseVertices(numberPerEdge: number): void;
  25169. /**
  25170. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25171. * This will undo any application of covertToFlatShadedMesh
  25172. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25173. */
  25174. forceSharedVertices(): void;
  25175. /** @hidden */
  25176. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25177. /** @hidden */
  25178. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25179. /**
  25180. * Creates a new InstancedMesh object from the mesh model.
  25181. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25182. * @param name defines the name of the new instance
  25183. * @returns a new InstancedMesh
  25184. */
  25185. createInstance(name: string): InstancedMesh;
  25186. /**
  25187. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25188. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25189. * @returns the current mesh
  25190. */
  25191. synchronizeInstances(): Mesh;
  25192. /**
  25193. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25194. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25195. * This should be used together with the simplification to avoid disappearing triangles.
  25196. * @param successCallback an optional success callback to be called after the optimization finished.
  25197. * @returns the current mesh
  25198. */
  25199. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25200. /**
  25201. * Serialize current mesh
  25202. * @param serializationObject defines the object which will receive the serialization data
  25203. */
  25204. serialize(serializationObject: any): void;
  25205. /** @hidden */
  25206. _syncGeometryWithMorphTargetManager(): void;
  25207. /** @hidden */
  25208. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25209. /**
  25210. * Returns a new Mesh object parsed from the source provided.
  25211. * @param parsedMesh is the source
  25212. * @param scene defines the hosting scene
  25213. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25214. * @returns a new Mesh
  25215. */
  25216. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25217. /**
  25218. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25219. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25220. * @param name defines the name of the mesh to create
  25221. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25222. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25223. * @param closePath creates a seam between the first and the last points of each path of the path array
  25224. * @param offset is taken in account only if the `pathArray` is containing a single path
  25225. * @param scene defines the hosting scene
  25226. * @param updatable defines if the mesh must be flagged as updatable
  25227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25228. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  25229. * @returns a new Mesh
  25230. */
  25231. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25232. /**
  25233. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25234. * @param name defines the name of the mesh to create
  25235. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25236. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25237. * @param scene defines the hosting scene
  25238. * @param updatable defines if the mesh must be flagged as updatable
  25239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25240. * @returns a new Mesh
  25241. */
  25242. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25243. /**
  25244. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25245. * @param name defines the name of the mesh to create
  25246. * @param size sets the size (float) of each box side (default 1)
  25247. * @param scene defines the hosting scene
  25248. * @param updatable defines if the mesh must be flagged as updatable
  25249. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25250. * @returns a new Mesh
  25251. */
  25252. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25253. /**
  25254. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25255. * @param name defines the name of the mesh to create
  25256. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25257. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25258. * @param scene defines the hosting scene
  25259. * @param updatable defines if the mesh must be flagged as updatable
  25260. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25261. * @returns a new Mesh
  25262. */
  25263. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25264. /**
  25265. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25266. * @param name defines the name of the mesh to create
  25267. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25268. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25269. * @param scene defines the hosting scene
  25270. * @returns a new Mesh
  25271. */
  25272. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25273. /**
  25274. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25275. * @param name defines the name of the mesh to create
  25276. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25277. * @param diameterTop set the top cap diameter (floats, default 1)
  25278. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25279. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25280. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25281. * @param scene defines the hosting scene
  25282. * @param updatable defines if the mesh must be flagged as updatable
  25283. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25284. * @returns a new Mesh
  25285. */
  25286. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25287. /**
  25288. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25289. * @param name defines the name of the mesh to create
  25290. * @param diameter sets the diameter size (float) of the torus (default 1)
  25291. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25292. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25293. * @param scene defines the hosting scene
  25294. * @param updatable defines if the mesh must be flagged as updatable
  25295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25296. * @returns a new Mesh
  25297. */
  25298. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25299. /**
  25300. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25301. * @param name defines the name of the mesh to create
  25302. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25303. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25304. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25305. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25306. * @param p the number of windings on X axis (positive integers, default 2)
  25307. * @param q the number of windings on Y axis (positive integers, default 3)
  25308. * @param scene defines the hosting scene
  25309. * @param updatable defines if the mesh must be flagged as updatable
  25310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25311. * @returns a new Mesh
  25312. */
  25313. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25314. /**
  25315. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25316. * @param name defines the name of the mesh to create
  25317. * @param points is an array successive Vector3
  25318. * @param scene defines the hosting scene
  25319. * @param updatable defines if the mesh must be flagged as updatable
  25320. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  25321. * @returns a new Mesh
  25322. */
  25323. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25324. /**
  25325. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25326. * @param name defines the name of the mesh to create
  25327. * @param points is an array successive Vector3
  25328. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25329. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25330. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25331. * @param scene defines the hosting scene
  25332. * @param updatable defines if the mesh must be flagged as updatable
  25333. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  25334. * @returns a new Mesh
  25335. */
  25336. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25337. /**
  25338. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25339. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25340. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  25341. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25342. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25343. * Remember you can only change the shape positions, not their number when updating a polygon.
  25344. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25345. * @param name defines the name of the mesh to create
  25346. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25347. * @param scene defines the hosting scene
  25348. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25349. * @param updatable defines if the mesh must be flagged as updatable
  25350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25351. * @param earcutInjection can be used to inject your own earcut reference
  25352. * @returns a new Mesh
  25353. */
  25354. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25355. /**
  25356. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25357. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25358. * @param name defines the name of the mesh to create
  25359. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25360. * @param depth defines the height of extrusion
  25361. * @param scene defines the hosting scene
  25362. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25363. * @param updatable defines if the mesh must be flagged as updatable
  25364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25365. * @param earcutInjection can be used to inject your own earcut reference
  25366. * @returns a new Mesh
  25367. */
  25368. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25369. /**
  25370. * Creates an extruded shape mesh.
  25371. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  25372. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25373. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25374. * @param name defines the name of the mesh to create
  25375. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25376. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25377. * @param scale is the value to scale the shape
  25378. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  25379. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25380. * @param scene defines the hosting scene
  25381. * @param updatable defines if the mesh must be flagged as updatable
  25382. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25383. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  25384. * @returns a new Mesh
  25385. */
  25386. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25387. /**
  25388. * Creates an custom extruded shape mesh.
  25389. * The custom extrusion is a parametric shape.
  25390. * It has no predefined shape. Its final shape will depend on the input parameters.
  25391. * Please consider using the same method from the MeshBuilder class instead
  25392. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25393. * @param name defines the name of the mesh to create
  25394. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25395. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25396. * @param scaleFunction is a custom Javascript function called on each path point
  25397. * @param rotationFunction is a custom Javascript function called on each path point
  25398. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25399. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25400. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25401. * @param scene defines the hosting scene
  25402. * @param updatable defines if the mesh must be flagged as updatable
  25403. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25404. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  25405. * @returns a new Mesh
  25406. */
  25407. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25408. /**
  25409. * Creates lathe mesh.
  25410. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25411. * Please consider using the same method from the MeshBuilder class instead
  25412. * @param name defines the name of the mesh to create
  25413. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  25414. * @param radius is the radius value of the lathe
  25415. * @param tessellation is the side number of the lathe.
  25416. * @param scene defines the hosting scene
  25417. * @param updatable defines if the mesh must be flagged as updatable
  25418. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25419. * @returns a new Mesh
  25420. */
  25421. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25422. /**
  25423. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25424. * @param name defines the name of the mesh to create
  25425. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25426. * @param scene defines the hosting scene
  25427. * @param updatable defines if the mesh must be flagged as updatable
  25428. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25429. * @returns a new Mesh
  25430. */
  25431. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25432. /**
  25433. * Creates a ground mesh.
  25434. * Please consider using the same method from the MeshBuilder class instead
  25435. * @param name defines the name of the mesh to create
  25436. * @param width set the width of the ground
  25437. * @param height set the height of the ground
  25438. * @param subdivisions sets the number of subdivisions per side
  25439. * @param scene defines the hosting scene
  25440. * @param updatable defines if the mesh must be flagged as updatable
  25441. * @returns a new Mesh
  25442. */
  25443. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25444. /**
  25445. * Creates a tiled ground mesh.
  25446. * Please consider using the same method from the MeshBuilder class instead
  25447. * @param name defines the name of the mesh to create
  25448. * @param xmin set the ground minimum X coordinate
  25449. * @param zmin set the ground minimum Y coordinate
  25450. * @param xmax set the ground maximum X coordinate
  25451. * @param zmax set the ground maximum Z coordinate
  25452. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  25453. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  25454. * @param scene defines the hosting scene
  25455. * @param updatable defines if the mesh must be flagged as updatable
  25456. * @returns a new Mesh
  25457. */
  25458. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25459. w: number;
  25460. h: number;
  25461. }, precision: {
  25462. w: number;
  25463. h: number;
  25464. }, scene: Scene, updatable?: boolean): Mesh;
  25465. /**
  25466. * Creates a ground mesh from a height map.
  25467. * Please consider using the same method from the MeshBuilder class instead
  25468. * @see http://doc.babylonjs.com/babylon101/height_map
  25469. * @param name defines the name of the mesh to create
  25470. * @param url sets the URL of the height map image resource
  25471. * @param width set the ground width size
  25472. * @param height set the ground height size
  25473. * @param subdivisions sets the number of subdivision per side
  25474. * @param minHeight is the minimum altitude on the ground
  25475. * @param maxHeight is the maximum altitude on the ground
  25476. * @param scene defines the hosting scene
  25477. * @param updatable defines if the mesh must be flagged as updatable
  25478. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25479. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25480. * @returns a new Mesh
  25481. */
  25482. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  25483. /**
  25484. * Creates a tube mesh.
  25485. * The tube is a parametric shape.
  25486. * It has no predefined shape. Its final shape will depend on the input parameters.
  25487. * Please consider using the same method from the MeshBuilder class instead
  25488. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25489. * @param name defines the name of the mesh to create
  25490. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25491. * @param radius sets the tube radius size
  25492. * @param tessellation is the number of sides on the tubular surface
  25493. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  25494. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25495. * @param scene defines the hosting scene
  25496. * @param updatable defines if the mesh must be flagged as updatable
  25497. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25498. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  25499. * @returns a new Mesh
  25500. */
  25501. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25502. (i: number, distance: number): number;
  25503. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25504. /**
  25505. * Creates a polyhedron mesh.
  25506. * Please consider using the same method from the MeshBuilder class instead.
  25507. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  25508. * * The parameter `size` (positive float, default 1) sets the polygon size
  25509. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25510. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  25511. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  25512. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  25513. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  25514. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  25515. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25518. * @param name defines the name of the mesh to create
  25519. * @param options defines the options used to create the mesh
  25520. * @param scene defines the hosting scene
  25521. * @returns a new Mesh
  25522. */
  25523. static CreatePolyhedron(name: string, options: {
  25524. type?: number;
  25525. size?: number;
  25526. sizeX?: number;
  25527. sizeY?: number;
  25528. sizeZ?: number;
  25529. custom?: any;
  25530. faceUV?: Vector4[];
  25531. faceColors?: Color4[];
  25532. updatable?: boolean;
  25533. sideOrientation?: number;
  25534. }, scene: Scene): Mesh;
  25535. /**
  25536. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25537. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25538. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  25539. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25540. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  25541. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25544. * @param name defines the name of the mesh
  25545. * @param options defines the options used to create the mesh
  25546. * @param scene defines the hosting scene
  25547. * @returns a new Mesh
  25548. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25549. */
  25550. static CreateIcoSphere(name: string, options: {
  25551. radius?: number;
  25552. flat?: boolean;
  25553. subdivisions?: number;
  25554. sideOrientation?: number;
  25555. updatable?: boolean;
  25556. }, scene: Scene): Mesh;
  25557. /**
  25558. * Creates a decal mesh.
  25559. * Please consider using the same method from the MeshBuilder class instead.
  25560. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25561. * @param name defines the name of the mesh
  25562. * @param sourceMesh defines the mesh receiving the decal
  25563. * @param position sets the position of the decal in world coordinates
  25564. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25565. * @param size sets the decal scaling
  25566. * @param angle sets the angle to rotate the decal
  25567. * @returns a new Mesh
  25568. */
  25569. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25570. /**
  25571. * Prepare internal position array for software CPU skinning
  25572. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25573. */
  25574. setPositionsForCPUSkinning(): Float32Array;
  25575. /**
  25576. * Prepare internal normal array for software CPU skinning
  25577. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25578. */
  25579. setNormalsForCPUSkinning(): Float32Array;
  25580. /**
  25581. * Updates the vertex buffer by applying transformation from the bones
  25582. * @param skeleton defines the skeleton to apply to current mesh
  25583. * @returns the current mesh
  25584. */
  25585. applySkeleton(skeleton: Skeleton): Mesh;
  25586. /**
  25587. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  25588. * @param meshes defines the list of meshes to scan
  25589. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25590. */
  25591. static MinMax(meshes: AbstractMesh[]): {
  25592. min: Vector3;
  25593. max: Vector3;
  25594. };
  25595. /**
  25596. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25597. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25598. * @returns a vector3
  25599. */
  25600. static Center(meshesOrMinMaxVector: {
  25601. min: Vector3;
  25602. max: Vector3;
  25603. } | AbstractMesh[]): Vector3;
  25604. /**
  25605. * Merge the array of meshes into a single mesh for performance reasons.
  25606. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25607. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25608. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25609. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25610. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25611. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25612. * @returns a new mesh
  25613. */
  25614. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25615. /** @hidden */
  25616. addInstance(instance: InstancedMesh): void;
  25617. /** @hidden */
  25618. removeInstance(instance: InstancedMesh): void;
  25619. }
  25620. }
  25621. declare module BABYLON {
  25622. /**
  25623. * This is the base class of all the camera used in the application.
  25624. * @see http://doc.babylonjs.com/features/cameras
  25625. */
  25626. export class Camera extends Node {
  25627. /** @hidden */
  25628. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25629. /**
  25630. * This is the default projection mode used by the cameras.
  25631. * It helps recreating a feeling of perspective and better appreciate depth.
  25632. * This is the best way to simulate real life cameras.
  25633. */
  25634. static readonly PERSPECTIVE_CAMERA: number;
  25635. /**
  25636. * This helps creating camera with an orthographic mode.
  25637. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  25638. */
  25639. static readonly ORTHOGRAPHIC_CAMERA: number;
  25640. /**
  25641. * This is the default FOV mode for perspective cameras.
  25642. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25643. */
  25644. static readonly FOVMODE_VERTICAL_FIXED: number;
  25645. /**
  25646. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25647. */
  25648. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25649. /**
  25650. * This specifies ther is no need for a camera rig.
  25651. * Basically only one eye is rendered corresponding to the camera.
  25652. */
  25653. static readonly RIG_MODE_NONE: number;
  25654. /**
  25655. * Simulates a camera Rig with one blue eye and one red eye.
  25656. * This can be use with 3d blue and red glasses.
  25657. */
  25658. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25659. /**
  25660. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25661. */
  25662. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25663. /**
  25664. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25665. */
  25666. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25667. /**
  25668. * Defines that both eyes of the camera will be rendered over under each other.
  25669. */
  25670. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25671. /**
  25672. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25673. */
  25674. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25675. /**
  25676. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25677. */
  25678. static readonly RIG_MODE_VR: number;
  25679. /**
  25680. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25681. */
  25682. static readonly RIG_MODE_WEBVR: number;
  25683. /**
  25684. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25685. */
  25686. static readonly RIG_MODE_CUSTOM: number;
  25687. /**
  25688. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25689. */
  25690. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25691. /**
  25692. * Define the input manager associated with the camera.
  25693. */
  25694. inputs: CameraInputsManager<Camera>;
  25695. /** @hidden */
  25696. _position: Vector3;
  25697. /**
  25698. * Define the current local position of the camera in the scene
  25699. */
  25700. get position(): Vector3;
  25701. set position(newPosition: Vector3);
  25702. /**
  25703. * The vector the camera should consider as up.
  25704. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25705. */
  25706. upVector: Vector3;
  25707. /**
  25708. * Define the current limit on the left side for an orthographic camera
  25709. * In scene unit
  25710. */
  25711. orthoLeft: Nullable<number>;
  25712. /**
  25713. * Define the current limit on the right side for an orthographic camera
  25714. * In scene unit
  25715. */
  25716. orthoRight: Nullable<number>;
  25717. /**
  25718. * Define the current limit on the bottom side for an orthographic camera
  25719. * In scene unit
  25720. */
  25721. orthoBottom: Nullable<number>;
  25722. /**
  25723. * Define the current limit on the top side for an orthographic camera
  25724. * In scene unit
  25725. */
  25726. orthoTop: Nullable<number>;
  25727. /**
  25728. * Field Of View is set in Radians. (default is 0.8)
  25729. */
  25730. fov: number;
  25731. /**
  25732. * Define the minimum distance the camera can see from.
  25733. * This is important to note that the depth buffer are not infinite and the closer it starts
  25734. * the more your scene might encounter depth fighting issue.
  25735. */
  25736. minZ: number;
  25737. /**
  25738. * Define the maximum distance the camera can see to.
  25739. * This is important to note that the depth buffer are not infinite and the further it end
  25740. * the more your scene might encounter depth fighting issue.
  25741. */
  25742. maxZ: number;
  25743. /**
  25744. * Define the default inertia of the camera.
  25745. * This helps giving a smooth feeling to the camera movement.
  25746. */
  25747. inertia: number;
  25748. /**
  25749. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25750. */
  25751. mode: number;
  25752. /**
  25753. * Define whether the camera is intermediate.
  25754. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25755. */
  25756. isIntermediate: boolean;
  25757. /**
  25758. * Define the viewport of the camera.
  25759. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25760. */
  25761. viewport: Viewport;
  25762. /**
  25763. * Restricts the camera to viewing objects with the same layerMask.
  25764. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25765. */
  25766. layerMask: number;
  25767. /**
  25768. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25769. */
  25770. fovMode: number;
  25771. /**
  25772. * Rig mode of the camera.
  25773. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25774. * This is normally controlled byt the camera themselves as internal use.
  25775. */
  25776. cameraRigMode: number;
  25777. /**
  25778. * Defines the distance between both "eyes" in case of a RIG
  25779. */
  25780. interaxialDistance: number;
  25781. /**
  25782. * Defines if stereoscopic rendering is done side by side or over under.
  25783. */
  25784. isStereoscopicSideBySide: boolean;
  25785. /**
  25786. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  25787. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25788. * else in the scene. (Eg. security camera)
  25789. *
  25790. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25791. */
  25792. customRenderTargets: RenderTargetTexture[];
  25793. /**
  25794. * When set, the camera will render to this render target instead of the default canvas
  25795. *
  25796. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25797. */
  25798. outputRenderTarget: Nullable<RenderTargetTexture>;
  25799. /**
  25800. * Observable triggered when the camera view matrix has changed.
  25801. */
  25802. onViewMatrixChangedObservable: Observable<Camera>;
  25803. /**
  25804. * Observable triggered when the camera Projection matrix has changed.
  25805. */
  25806. onProjectionMatrixChangedObservable: Observable<Camera>;
  25807. /**
  25808. * Observable triggered when the inputs have been processed.
  25809. */
  25810. onAfterCheckInputsObservable: Observable<Camera>;
  25811. /**
  25812. * Observable triggered when reset has been called and applied to the camera.
  25813. */
  25814. onRestoreStateObservable: Observable<Camera>;
  25815. /**
  25816. * Is this camera a part of a rig system?
  25817. */
  25818. isRigCamera: boolean;
  25819. /**
  25820. * If isRigCamera set to true this will be set with the parent camera.
  25821. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25822. */
  25823. rigParent?: Camera;
  25824. /** @hidden */
  25825. _cameraRigParams: any;
  25826. /** @hidden */
  25827. _rigCameras: Camera[];
  25828. /** @hidden */
  25829. _rigPostProcess: Nullable<PostProcess>;
  25830. protected _webvrViewMatrix: Matrix;
  25831. /** @hidden */
  25832. _skipRendering: boolean;
  25833. /** @hidden */
  25834. _projectionMatrix: Matrix;
  25835. /** @hidden */
  25836. _postProcesses: Nullable<PostProcess>[];
  25837. /** @hidden */
  25838. _activeMeshes: SmartArray<AbstractMesh>;
  25839. protected _globalPosition: Vector3;
  25840. /** @hidden */
  25841. _computedViewMatrix: Matrix;
  25842. private _doNotComputeProjectionMatrix;
  25843. private _transformMatrix;
  25844. private _frustumPlanes;
  25845. private _refreshFrustumPlanes;
  25846. private _storedFov;
  25847. private _stateStored;
  25848. /**
  25849. * Instantiates a new camera object.
  25850. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25851. * @see http://doc.babylonjs.com/features/cameras
  25852. * @param name Defines the name of the camera in the scene
  25853. * @param position Defines the position of the camera
  25854. * @param scene Defines the scene the camera belongs too
  25855. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25856. */
  25857. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25858. /**
  25859. * Store current camera state (fov, position, etc..)
  25860. * @returns the camera
  25861. */
  25862. storeState(): Camera;
  25863. /**
  25864. * Restores the camera state values if it has been stored. You must call storeState() first
  25865. */
  25866. protected _restoreStateValues(): boolean;
  25867. /**
  25868. * Restored camera state. You must call storeState() first.
  25869. * @returns true if restored and false otherwise
  25870. */
  25871. restoreState(): boolean;
  25872. /**
  25873. * Gets the class name of the camera.
  25874. * @returns the class name
  25875. */
  25876. getClassName(): string;
  25877. /** @hidden */
  25878. readonly _isCamera: boolean;
  25879. /**
  25880. * Gets a string representation of the camera useful for debug purpose.
  25881. * @param fullDetails Defines that a more verboe level of logging is required
  25882. * @returns the string representation
  25883. */
  25884. toString(fullDetails?: boolean): string;
  25885. /**
  25886. * Gets the current world space position of the camera.
  25887. */
  25888. get globalPosition(): Vector3;
  25889. /**
  25890. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25891. * @returns the active meshe list
  25892. */
  25893. getActiveMeshes(): SmartArray<AbstractMesh>;
  25894. /**
  25895. * Check whether a mesh is part of the current active mesh list of the camera
  25896. * @param mesh Defines the mesh to check
  25897. * @returns true if active, false otherwise
  25898. */
  25899. isActiveMesh(mesh: Mesh): boolean;
  25900. /**
  25901. * Is this camera ready to be used/rendered
  25902. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25903. * @return true if the camera is ready
  25904. */
  25905. isReady(completeCheck?: boolean): boolean;
  25906. /** @hidden */
  25907. _initCache(): void;
  25908. /** @hidden */
  25909. _updateCache(ignoreParentClass?: boolean): void;
  25910. /** @hidden */
  25911. _isSynchronized(): boolean;
  25912. /** @hidden */
  25913. _isSynchronizedViewMatrix(): boolean;
  25914. /** @hidden */
  25915. _isSynchronizedProjectionMatrix(): boolean;
  25916. /**
  25917. * Attach the input controls to a specific dom element to get the input from.
  25918. * @param element Defines the element the controls should be listened from
  25919. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25920. */
  25921. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25922. /**
  25923. * Detach the current controls from the specified dom element.
  25924. * @param element Defines the element to stop listening the inputs from
  25925. */
  25926. detachControl(element: HTMLElement): void;
  25927. /**
  25928. * Update the camera state according to the different inputs gathered during the frame.
  25929. */
  25930. update(): void;
  25931. /** @hidden */
  25932. _checkInputs(): void;
  25933. /** @hidden */
  25934. get rigCameras(): Camera[];
  25935. /**
  25936. * Gets the post process used by the rig cameras
  25937. */
  25938. get rigPostProcess(): Nullable<PostProcess>;
  25939. /**
  25940. * Internal, gets the first post proces.
  25941. * @returns the first post process to be run on this camera.
  25942. */
  25943. _getFirstPostProcess(): Nullable<PostProcess>;
  25944. private _cascadePostProcessesToRigCams;
  25945. /**
  25946. * Attach a post process to the camera.
  25947. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25948. * @param postProcess The post process to attach to the camera
  25949. * @param insertAt The position of the post process in case several of them are in use in the scene
  25950. * @returns the position the post process has been inserted at
  25951. */
  25952. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25953. /**
  25954. * Detach a post process to the camera.
  25955. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25956. * @param postProcess The post process to detach from the camera
  25957. */
  25958. detachPostProcess(postProcess: PostProcess): void;
  25959. /**
  25960. * Gets the current world matrix of the camera
  25961. */
  25962. getWorldMatrix(): Matrix;
  25963. /** @hidden */
  25964. _getViewMatrix(): Matrix;
  25965. /**
  25966. * Gets the current view matrix of the camera.
  25967. * @param force forces the camera to recompute the matrix without looking at the cached state
  25968. * @returns the view matrix
  25969. */
  25970. getViewMatrix(force?: boolean): Matrix;
  25971. /**
  25972. * Freeze the projection matrix.
  25973. * It will prevent the cache check of the camera projection compute and can speed up perf
  25974. * if no parameter of the camera are meant to change
  25975. * @param projection Defines manually a projection if necessary
  25976. */
  25977. freezeProjectionMatrix(projection?: Matrix): void;
  25978. /**
  25979. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25980. */
  25981. unfreezeProjectionMatrix(): void;
  25982. /**
  25983. * Gets the current projection matrix of the camera.
  25984. * @param force forces the camera to recompute the matrix without looking at the cached state
  25985. * @returns the projection matrix
  25986. */
  25987. getProjectionMatrix(force?: boolean): Matrix;
  25988. /**
  25989. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25990. * @returns a Matrix
  25991. */
  25992. getTransformationMatrix(): Matrix;
  25993. private _updateFrustumPlanes;
  25994. /**
  25995. * Checks if a cullable object (mesh...) is in the camera frustum
  25996. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25997. * @param target The object to check
  25998. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25999. * @returns true if the object is in frustum otherwise false
  26000. */
  26001. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26002. /**
  26003. * Checks if a cullable object (mesh...) is in the camera frustum
  26004. * Unlike isInFrustum this cheks the full bounding box
  26005. * @param target The object to check
  26006. * @returns true if the object is in frustum otherwise false
  26007. */
  26008. isCompletelyInFrustum(target: ICullable): boolean;
  26009. /**
  26010. * Gets a ray in the forward direction from the camera.
  26011. * @param length Defines the length of the ray to create
  26012. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26013. * @param origin Defines the start point of the ray which defaults to the camera position
  26014. * @returns the forward ray
  26015. */
  26016. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26017. /**
  26018. * Releases resources associated with this node.
  26019. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26020. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26021. */
  26022. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26023. /** @hidden */
  26024. _isLeftCamera: boolean;
  26025. /**
  26026. * Gets the left camera of a rig setup in case of Rigged Camera
  26027. */
  26028. get isLeftCamera(): boolean;
  26029. /** @hidden */
  26030. _isRightCamera: boolean;
  26031. /**
  26032. * Gets the right camera of a rig setup in case of Rigged Camera
  26033. */
  26034. get isRightCamera(): boolean;
  26035. /**
  26036. * Gets the left camera of a rig setup in case of Rigged Camera
  26037. */
  26038. get leftCamera(): Nullable<FreeCamera>;
  26039. /**
  26040. * Gets the right camera of a rig setup in case of Rigged Camera
  26041. */
  26042. get rightCamera(): Nullable<FreeCamera>;
  26043. /**
  26044. * Gets the left camera target of a rig setup in case of Rigged Camera
  26045. * @returns the target position
  26046. */
  26047. getLeftTarget(): Nullable<Vector3>;
  26048. /**
  26049. * Gets the right camera target of a rig setup in case of Rigged Camera
  26050. * @returns the target position
  26051. */
  26052. getRightTarget(): Nullable<Vector3>;
  26053. /**
  26054. * @hidden
  26055. */
  26056. setCameraRigMode(mode: number, rigParams: any): void;
  26057. /** @hidden */
  26058. static _setStereoscopicRigMode(camera: Camera): void;
  26059. /** @hidden */
  26060. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26061. /** @hidden */
  26062. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26063. /** @hidden */
  26064. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26065. /** @hidden */
  26066. _getVRProjectionMatrix(): Matrix;
  26067. protected _updateCameraRotationMatrix(): void;
  26068. protected _updateWebVRCameraRotationMatrix(): void;
  26069. /**
  26070. * This function MUST be overwritten by the different WebVR cameras available.
  26071. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26072. * @hidden
  26073. */
  26074. _getWebVRProjectionMatrix(): Matrix;
  26075. /**
  26076. * This function MUST be overwritten by the different WebVR cameras available.
  26077. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26078. * @hidden
  26079. */
  26080. _getWebVRViewMatrix(): Matrix;
  26081. /** @hidden */
  26082. setCameraRigParameter(name: string, value: any): void;
  26083. /**
  26084. * needs to be overridden by children so sub has required properties to be copied
  26085. * @hidden
  26086. */
  26087. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26088. /**
  26089. * May need to be overridden by children
  26090. * @hidden
  26091. */
  26092. _updateRigCameras(): void;
  26093. /** @hidden */
  26094. _setupInputs(): void;
  26095. /**
  26096. * Serialiaze the camera setup to a json represention
  26097. * @returns the JSON representation
  26098. */
  26099. serialize(): any;
  26100. /**
  26101. * Clones the current camera.
  26102. * @param name The cloned camera name
  26103. * @returns the cloned camera
  26104. */
  26105. clone(name: string): Camera;
  26106. /**
  26107. * Gets the direction of the camera relative to a given local axis.
  26108. * @param localAxis Defines the reference axis to provide a relative direction.
  26109. * @return the direction
  26110. */
  26111. getDirection(localAxis: Vector3): Vector3;
  26112. /**
  26113. * Returns the current camera absolute rotation
  26114. */
  26115. get absoluteRotation(): Quaternion;
  26116. /**
  26117. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26118. * @param localAxis Defines the reference axis to provide a relative direction.
  26119. * @param result Defines the vector to store the result in
  26120. */
  26121. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26122. /**
  26123. * Gets a camera constructor for a given camera type
  26124. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26125. * @param name The name of the camera the result will be able to instantiate
  26126. * @param scene The scene the result will construct the camera in
  26127. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26128. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26129. * @returns a factory method to construc the camera
  26130. */
  26131. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26132. /**
  26133. * Compute the world matrix of the camera.
  26134. * @returns the camera world matrix
  26135. */
  26136. computeWorldMatrix(): Matrix;
  26137. /**
  26138. * Parse a JSON and creates the camera from the parsed information
  26139. * @param parsedCamera The JSON to parse
  26140. * @param scene The scene to instantiate the camera in
  26141. * @returns the newly constructed camera
  26142. */
  26143. static Parse(parsedCamera: any, scene: Scene): Camera;
  26144. }
  26145. }
  26146. declare module BABYLON {
  26147. /**
  26148. * Class containing static functions to help procedurally build meshes
  26149. */
  26150. export class DiscBuilder {
  26151. /**
  26152. * Creates a plane polygonal mesh. By default, this is a disc
  26153. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26154. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  26155. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  26156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26159. * @param name defines the name of the mesh
  26160. * @param options defines the options used to create the mesh
  26161. * @param scene defines the hosting scene
  26162. * @returns the plane polygonal mesh
  26163. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26164. */
  26165. static CreateDisc(name: string, options: {
  26166. radius?: number;
  26167. tessellation?: number;
  26168. arc?: number;
  26169. updatable?: boolean;
  26170. sideOrientation?: number;
  26171. frontUVs?: Vector4;
  26172. backUVs?: Vector4;
  26173. }, scene?: Nullable<Scene>): Mesh;
  26174. }
  26175. }
  26176. declare module BABYLON {
  26177. /**
  26178. * Options to be used when creating a FresnelParameters.
  26179. */
  26180. export type IFresnelParametersCreationOptions = {
  26181. /**
  26182. * Define the color used on edges (grazing angle)
  26183. */
  26184. leftColor?: Color3;
  26185. /**
  26186. * Define the color used on center
  26187. */
  26188. rightColor?: Color3;
  26189. /**
  26190. * Define bias applied to computed fresnel term
  26191. */
  26192. bias?: number;
  26193. /**
  26194. * Defined the power exponent applied to fresnel term
  26195. */
  26196. power?: number;
  26197. /**
  26198. * Define if the fresnel effect is enable or not.
  26199. */
  26200. isEnabled?: boolean;
  26201. };
  26202. /**
  26203. * Serialized format for FresnelParameters.
  26204. */
  26205. export type IFresnelParametersSerialized = {
  26206. /**
  26207. * Define the color used on edges (grazing angle) [as an array]
  26208. */
  26209. leftColor: number[];
  26210. /**
  26211. * Define the color used on center [as an array]
  26212. */
  26213. rightColor: number[];
  26214. /**
  26215. * Define bias applied to computed fresnel term
  26216. */
  26217. bias: number;
  26218. /**
  26219. * Defined the power exponent applied to fresnel term
  26220. */
  26221. power?: number;
  26222. /**
  26223. * Define if the fresnel effect is enable or not.
  26224. */
  26225. isEnabled: boolean;
  26226. };
  26227. /**
  26228. * This represents all the required information to add a fresnel effect on a material:
  26229. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26230. */
  26231. export class FresnelParameters {
  26232. private _isEnabled;
  26233. /**
  26234. * Define if the fresnel effect is enable or not.
  26235. */
  26236. get isEnabled(): boolean;
  26237. set isEnabled(value: boolean);
  26238. /**
  26239. * Define the color used on edges (grazing angle)
  26240. */
  26241. leftColor: Color3;
  26242. /**
  26243. * Define the color used on center
  26244. */
  26245. rightColor: Color3;
  26246. /**
  26247. * Define bias applied to computed fresnel term
  26248. */
  26249. bias: number;
  26250. /**
  26251. * Defined the power exponent applied to fresnel term
  26252. */
  26253. power: number;
  26254. /**
  26255. * Creates a new FresnelParameters object.
  26256. *
  26257. * @param options provide your own settings to optionally to override defaults
  26258. */
  26259. constructor(options?: IFresnelParametersCreationOptions);
  26260. /**
  26261. * Clones the current fresnel and its valuues
  26262. * @returns a clone fresnel configuration
  26263. */
  26264. clone(): FresnelParameters;
  26265. /**
  26266. * Determines equality between FresnelParameters objects
  26267. * @param otherFresnelParameters defines the second operand
  26268. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26269. */
  26270. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26271. /**
  26272. * Serializes the current fresnel parameters to a JSON representation.
  26273. * @return the JSON serialization
  26274. */
  26275. serialize(): IFresnelParametersSerialized;
  26276. /**
  26277. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26278. * @param parsedFresnelParameters Define the JSON representation
  26279. * @returns the parsed parameters
  26280. */
  26281. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26282. }
  26283. }
  26284. declare module BABYLON {
  26285. /**
  26286. * Base class of materials working in push mode in babylon JS
  26287. * @hidden
  26288. */
  26289. export class PushMaterial extends Material {
  26290. protected _activeEffect: Effect;
  26291. protected _normalMatrix: Matrix;
  26292. /**
  26293. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26294. * This means that the material can keep using a previous shader while a new one is being compiled.
  26295. * This is mostly used when shader parallel compilation is supported (true by default)
  26296. */
  26297. allowShaderHotSwapping: boolean;
  26298. constructor(name: string, scene: Scene);
  26299. getEffect(): Effect;
  26300. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26301. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26302. /**
  26303. * Binds the given world matrix to the active effect
  26304. *
  26305. * @param world the matrix to bind
  26306. */
  26307. bindOnlyWorldMatrix(world: Matrix): void;
  26308. /**
  26309. * Binds the given normal matrix to the active effect
  26310. *
  26311. * @param normalMatrix the matrix to bind
  26312. */
  26313. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26314. bind(world: Matrix, mesh?: Mesh): void;
  26315. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26316. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26317. }
  26318. }
  26319. declare module BABYLON {
  26320. /**
  26321. * This groups all the flags used to control the materials channel.
  26322. */
  26323. export class MaterialFlags {
  26324. private static _DiffuseTextureEnabled;
  26325. /**
  26326. * Are diffuse textures enabled in the application.
  26327. */
  26328. static get DiffuseTextureEnabled(): boolean;
  26329. static set DiffuseTextureEnabled(value: boolean);
  26330. private static _AmbientTextureEnabled;
  26331. /**
  26332. * Are ambient textures enabled in the application.
  26333. */
  26334. static get AmbientTextureEnabled(): boolean;
  26335. static set AmbientTextureEnabled(value: boolean);
  26336. private static _OpacityTextureEnabled;
  26337. /**
  26338. * Are opacity textures enabled in the application.
  26339. */
  26340. static get OpacityTextureEnabled(): boolean;
  26341. static set OpacityTextureEnabled(value: boolean);
  26342. private static _ReflectionTextureEnabled;
  26343. /**
  26344. * Are reflection textures enabled in the application.
  26345. */
  26346. static get ReflectionTextureEnabled(): boolean;
  26347. static set ReflectionTextureEnabled(value: boolean);
  26348. private static _EmissiveTextureEnabled;
  26349. /**
  26350. * Are emissive textures enabled in the application.
  26351. */
  26352. static get EmissiveTextureEnabled(): boolean;
  26353. static set EmissiveTextureEnabled(value: boolean);
  26354. private static _SpecularTextureEnabled;
  26355. /**
  26356. * Are specular textures enabled in the application.
  26357. */
  26358. static get SpecularTextureEnabled(): boolean;
  26359. static set SpecularTextureEnabled(value: boolean);
  26360. private static _BumpTextureEnabled;
  26361. /**
  26362. * Are bump textures enabled in the application.
  26363. */
  26364. static get BumpTextureEnabled(): boolean;
  26365. static set BumpTextureEnabled(value: boolean);
  26366. private static _LightmapTextureEnabled;
  26367. /**
  26368. * Are lightmap textures enabled in the application.
  26369. */
  26370. static get LightmapTextureEnabled(): boolean;
  26371. static set LightmapTextureEnabled(value: boolean);
  26372. private static _RefractionTextureEnabled;
  26373. /**
  26374. * Are refraction textures enabled in the application.
  26375. */
  26376. static get RefractionTextureEnabled(): boolean;
  26377. static set RefractionTextureEnabled(value: boolean);
  26378. private static _ColorGradingTextureEnabled;
  26379. /**
  26380. * Are color grading textures enabled in the application.
  26381. */
  26382. static get ColorGradingTextureEnabled(): boolean;
  26383. static set ColorGradingTextureEnabled(value: boolean);
  26384. private static _FresnelEnabled;
  26385. /**
  26386. * Are fresnels enabled in the application.
  26387. */
  26388. static get FresnelEnabled(): boolean;
  26389. static set FresnelEnabled(value: boolean);
  26390. private static _ClearCoatTextureEnabled;
  26391. /**
  26392. * Are clear coat textures enabled in the application.
  26393. */
  26394. static get ClearCoatTextureEnabled(): boolean;
  26395. static set ClearCoatTextureEnabled(value: boolean);
  26396. private static _ClearCoatBumpTextureEnabled;
  26397. /**
  26398. * Are clear coat bump textures enabled in the application.
  26399. */
  26400. static get ClearCoatBumpTextureEnabled(): boolean;
  26401. static set ClearCoatBumpTextureEnabled(value: boolean);
  26402. private static _ClearCoatTintTextureEnabled;
  26403. /**
  26404. * Are clear coat tint textures enabled in the application.
  26405. */
  26406. static get ClearCoatTintTextureEnabled(): boolean;
  26407. static set ClearCoatTintTextureEnabled(value: boolean);
  26408. private static _SheenTextureEnabled;
  26409. /**
  26410. * Are sheen textures enabled in the application.
  26411. */
  26412. static get SheenTextureEnabled(): boolean;
  26413. static set SheenTextureEnabled(value: boolean);
  26414. private static _AnisotropicTextureEnabled;
  26415. /**
  26416. * Are anisotropic textures enabled in the application.
  26417. */
  26418. static get AnisotropicTextureEnabled(): boolean;
  26419. static set AnisotropicTextureEnabled(value: boolean);
  26420. private static _ThicknessTextureEnabled;
  26421. /**
  26422. * Are thickness textures enabled in the application.
  26423. */
  26424. static get ThicknessTextureEnabled(): boolean;
  26425. static set ThicknessTextureEnabled(value: boolean);
  26426. }
  26427. }
  26428. declare module BABYLON {
  26429. /** @hidden */
  26430. export var defaultFragmentDeclaration: {
  26431. name: string;
  26432. shader: string;
  26433. };
  26434. }
  26435. declare module BABYLON {
  26436. /** @hidden */
  26437. export var defaultUboDeclaration: {
  26438. name: string;
  26439. shader: string;
  26440. };
  26441. }
  26442. declare module BABYLON {
  26443. /** @hidden */
  26444. export var lightFragmentDeclaration: {
  26445. name: string;
  26446. shader: string;
  26447. };
  26448. }
  26449. declare module BABYLON {
  26450. /** @hidden */
  26451. export var lightUboDeclaration: {
  26452. name: string;
  26453. shader: string;
  26454. };
  26455. }
  26456. declare module BABYLON {
  26457. /** @hidden */
  26458. export var lightsFragmentFunctions: {
  26459. name: string;
  26460. shader: string;
  26461. };
  26462. }
  26463. declare module BABYLON {
  26464. /** @hidden */
  26465. export var shadowsFragmentFunctions: {
  26466. name: string;
  26467. shader: string;
  26468. };
  26469. }
  26470. declare module BABYLON {
  26471. /** @hidden */
  26472. export var fresnelFunction: {
  26473. name: string;
  26474. shader: string;
  26475. };
  26476. }
  26477. declare module BABYLON {
  26478. /** @hidden */
  26479. export var reflectionFunction: {
  26480. name: string;
  26481. shader: string;
  26482. };
  26483. }
  26484. declare module BABYLON {
  26485. /** @hidden */
  26486. export var bumpFragmentFunctions: {
  26487. name: string;
  26488. shader: string;
  26489. };
  26490. }
  26491. declare module BABYLON {
  26492. /** @hidden */
  26493. export var logDepthDeclaration: {
  26494. name: string;
  26495. shader: string;
  26496. };
  26497. }
  26498. declare module BABYLON {
  26499. /** @hidden */
  26500. export var bumpFragment: {
  26501. name: string;
  26502. shader: string;
  26503. };
  26504. }
  26505. declare module BABYLON {
  26506. /** @hidden */
  26507. export var depthPrePass: {
  26508. name: string;
  26509. shader: string;
  26510. };
  26511. }
  26512. declare module BABYLON {
  26513. /** @hidden */
  26514. export var lightFragment: {
  26515. name: string;
  26516. shader: string;
  26517. };
  26518. }
  26519. declare module BABYLON {
  26520. /** @hidden */
  26521. export var logDepthFragment: {
  26522. name: string;
  26523. shader: string;
  26524. };
  26525. }
  26526. declare module BABYLON {
  26527. /** @hidden */
  26528. export var defaultPixelShader: {
  26529. name: string;
  26530. shader: string;
  26531. };
  26532. }
  26533. declare module BABYLON {
  26534. /** @hidden */
  26535. export var defaultVertexDeclaration: {
  26536. name: string;
  26537. shader: string;
  26538. };
  26539. }
  26540. declare module BABYLON {
  26541. /** @hidden */
  26542. export var bumpVertexDeclaration: {
  26543. name: string;
  26544. shader: string;
  26545. };
  26546. }
  26547. declare module BABYLON {
  26548. /** @hidden */
  26549. export var bumpVertex: {
  26550. name: string;
  26551. shader: string;
  26552. };
  26553. }
  26554. declare module BABYLON {
  26555. /** @hidden */
  26556. export var fogVertex: {
  26557. name: string;
  26558. shader: string;
  26559. };
  26560. }
  26561. declare module BABYLON {
  26562. /** @hidden */
  26563. export var shadowsVertex: {
  26564. name: string;
  26565. shader: string;
  26566. };
  26567. }
  26568. declare module BABYLON {
  26569. /** @hidden */
  26570. export var pointCloudVertex: {
  26571. name: string;
  26572. shader: string;
  26573. };
  26574. }
  26575. declare module BABYLON {
  26576. /** @hidden */
  26577. export var logDepthVertex: {
  26578. name: string;
  26579. shader: string;
  26580. };
  26581. }
  26582. declare module BABYLON {
  26583. /** @hidden */
  26584. export var defaultVertexShader: {
  26585. name: string;
  26586. shader: string;
  26587. };
  26588. }
  26589. declare module BABYLON {
  26590. /** @hidden */
  26591. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26592. MAINUV1: boolean;
  26593. MAINUV2: boolean;
  26594. DIFFUSE: boolean;
  26595. DIFFUSEDIRECTUV: number;
  26596. AMBIENT: boolean;
  26597. AMBIENTDIRECTUV: number;
  26598. OPACITY: boolean;
  26599. OPACITYDIRECTUV: number;
  26600. OPACITYRGB: boolean;
  26601. REFLECTION: boolean;
  26602. EMISSIVE: boolean;
  26603. EMISSIVEDIRECTUV: number;
  26604. SPECULAR: boolean;
  26605. SPECULARDIRECTUV: number;
  26606. BUMP: boolean;
  26607. BUMPDIRECTUV: number;
  26608. PARALLAX: boolean;
  26609. PARALLAXOCCLUSION: boolean;
  26610. SPECULAROVERALPHA: boolean;
  26611. CLIPPLANE: boolean;
  26612. CLIPPLANE2: boolean;
  26613. CLIPPLANE3: boolean;
  26614. CLIPPLANE4: boolean;
  26615. CLIPPLANE5: boolean;
  26616. CLIPPLANE6: boolean;
  26617. ALPHATEST: boolean;
  26618. DEPTHPREPASS: boolean;
  26619. ALPHAFROMDIFFUSE: boolean;
  26620. POINTSIZE: boolean;
  26621. FOG: boolean;
  26622. SPECULARTERM: boolean;
  26623. DIFFUSEFRESNEL: boolean;
  26624. OPACITYFRESNEL: boolean;
  26625. REFLECTIONFRESNEL: boolean;
  26626. REFRACTIONFRESNEL: boolean;
  26627. EMISSIVEFRESNEL: boolean;
  26628. FRESNEL: boolean;
  26629. NORMAL: boolean;
  26630. UV1: boolean;
  26631. UV2: boolean;
  26632. VERTEXCOLOR: boolean;
  26633. VERTEXALPHA: boolean;
  26634. NUM_BONE_INFLUENCERS: number;
  26635. BonesPerMesh: number;
  26636. BONETEXTURE: boolean;
  26637. INSTANCES: boolean;
  26638. GLOSSINESS: boolean;
  26639. ROUGHNESS: boolean;
  26640. EMISSIVEASILLUMINATION: boolean;
  26641. LINKEMISSIVEWITHDIFFUSE: boolean;
  26642. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26643. LIGHTMAP: boolean;
  26644. LIGHTMAPDIRECTUV: number;
  26645. OBJECTSPACE_NORMALMAP: boolean;
  26646. USELIGHTMAPASSHADOWMAP: boolean;
  26647. REFLECTIONMAP_3D: boolean;
  26648. REFLECTIONMAP_SPHERICAL: boolean;
  26649. REFLECTIONMAP_PLANAR: boolean;
  26650. REFLECTIONMAP_CUBIC: boolean;
  26651. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26652. REFLECTIONMAP_PROJECTION: boolean;
  26653. REFLECTIONMAP_SKYBOX: boolean;
  26654. REFLECTIONMAP_EXPLICIT: boolean;
  26655. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26656. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26657. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26658. INVERTCUBICMAP: boolean;
  26659. LOGARITHMICDEPTH: boolean;
  26660. REFRACTION: boolean;
  26661. REFRACTIONMAP_3D: boolean;
  26662. REFLECTIONOVERALPHA: boolean;
  26663. TWOSIDEDLIGHTING: boolean;
  26664. SHADOWFLOAT: boolean;
  26665. MORPHTARGETS: boolean;
  26666. MORPHTARGETS_NORMAL: boolean;
  26667. MORPHTARGETS_TANGENT: boolean;
  26668. MORPHTARGETS_UV: boolean;
  26669. NUM_MORPH_INFLUENCERS: number;
  26670. NONUNIFORMSCALING: boolean;
  26671. PREMULTIPLYALPHA: boolean;
  26672. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26673. ALPHABLEND: boolean;
  26674. IMAGEPROCESSING: boolean;
  26675. VIGNETTE: boolean;
  26676. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26677. VIGNETTEBLENDMODEOPAQUE: boolean;
  26678. TONEMAPPING: boolean;
  26679. TONEMAPPING_ACES: boolean;
  26680. CONTRAST: boolean;
  26681. COLORCURVES: boolean;
  26682. COLORGRADING: boolean;
  26683. COLORGRADING3D: boolean;
  26684. SAMPLER3DGREENDEPTH: boolean;
  26685. SAMPLER3DBGRMAP: boolean;
  26686. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26687. MULTIVIEW: boolean;
  26688. /**
  26689. * If the reflection texture on this material is in linear color space
  26690. * @hidden
  26691. */
  26692. IS_REFLECTION_LINEAR: boolean;
  26693. /**
  26694. * If the refraction texture on this material is in linear color space
  26695. * @hidden
  26696. */
  26697. IS_REFRACTION_LINEAR: boolean;
  26698. EXPOSURE: boolean;
  26699. constructor();
  26700. setReflectionMode(modeToEnable: string): void;
  26701. }
  26702. /**
  26703. * This is the default material used in Babylon. It is the best trade off between quality
  26704. * and performances.
  26705. * @see http://doc.babylonjs.com/babylon101/materials
  26706. */
  26707. export class StandardMaterial extends PushMaterial {
  26708. private _diffuseTexture;
  26709. /**
  26710. * The basic texture of the material as viewed under a light.
  26711. */
  26712. diffuseTexture: Nullable<BaseTexture>;
  26713. private _ambientTexture;
  26714. /**
  26715. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26716. */
  26717. ambientTexture: Nullable<BaseTexture>;
  26718. private _opacityTexture;
  26719. /**
  26720. * Define the transparency of the material from a texture.
  26721. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26722. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26723. */
  26724. opacityTexture: Nullable<BaseTexture>;
  26725. private _reflectionTexture;
  26726. /**
  26727. * Define the texture used to display the reflection.
  26728. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26729. */
  26730. reflectionTexture: Nullable<BaseTexture>;
  26731. private _emissiveTexture;
  26732. /**
  26733. * Define texture of the material as if self lit.
  26734. * This will be mixed in the final result even in the absence of light.
  26735. */
  26736. emissiveTexture: Nullable<BaseTexture>;
  26737. private _specularTexture;
  26738. /**
  26739. * Define how the color and intensity of the highlight given by the light in the material.
  26740. */
  26741. specularTexture: Nullable<BaseTexture>;
  26742. private _bumpTexture;
  26743. /**
  26744. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26745. * 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.
  26746. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26747. */
  26748. bumpTexture: Nullable<BaseTexture>;
  26749. private _lightmapTexture;
  26750. /**
  26751. * Complex lighting can be computationally expensive to compute at runtime.
  26752. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26753. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26754. */
  26755. lightmapTexture: Nullable<BaseTexture>;
  26756. private _refractionTexture;
  26757. /**
  26758. * Define the texture used to display the refraction.
  26759. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26760. */
  26761. refractionTexture: Nullable<BaseTexture>;
  26762. /**
  26763. * The color of the material lit by the environmental background lighting.
  26764. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26765. */
  26766. ambientColor: Color3;
  26767. /**
  26768. * The basic color of the material as viewed under a light.
  26769. */
  26770. diffuseColor: Color3;
  26771. /**
  26772. * Define how the color and intensity of the highlight given by the light in the material.
  26773. */
  26774. specularColor: Color3;
  26775. /**
  26776. * Define the color of the material as if self lit.
  26777. * This will be mixed in the final result even in the absence of light.
  26778. */
  26779. emissiveColor: Color3;
  26780. /**
  26781. * Defines how sharp are the highlights in the material.
  26782. * The bigger the value the sharper giving a more glossy feeling to the result.
  26783. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26784. */
  26785. specularPower: number;
  26786. private _useAlphaFromDiffuseTexture;
  26787. /**
  26788. * Does the transparency come from the diffuse texture alpha channel.
  26789. */
  26790. useAlphaFromDiffuseTexture: boolean;
  26791. private _useEmissiveAsIllumination;
  26792. /**
  26793. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26794. */
  26795. useEmissiveAsIllumination: boolean;
  26796. private _linkEmissiveWithDiffuse;
  26797. /**
  26798. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26799. * the emissive level when the final color is close to one.
  26800. */
  26801. linkEmissiveWithDiffuse: boolean;
  26802. private _useSpecularOverAlpha;
  26803. /**
  26804. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26805. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26806. */
  26807. useSpecularOverAlpha: boolean;
  26808. private _useReflectionOverAlpha;
  26809. /**
  26810. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26811. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26812. */
  26813. useReflectionOverAlpha: boolean;
  26814. private _disableLighting;
  26815. /**
  26816. * Does lights from the scene impacts this material.
  26817. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26818. */
  26819. disableLighting: boolean;
  26820. private _useObjectSpaceNormalMap;
  26821. /**
  26822. * Allows using an object space normal map (instead of tangent space).
  26823. */
  26824. useObjectSpaceNormalMap: boolean;
  26825. private _useParallax;
  26826. /**
  26827. * Is parallax enabled or not.
  26828. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26829. */
  26830. useParallax: boolean;
  26831. private _useParallaxOcclusion;
  26832. /**
  26833. * Is parallax occlusion enabled or not.
  26834. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26835. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26836. */
  26837. useParallaxOcclusion: boolean;
  26838. /**
  26839. * 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.
  26840. */
  26841. parallaxScaleBias: number;
  26842. private _roughness;
  26843. /**
  26844. * Helps to define how blurry the reflections should appears in the material.
  26845. */
  26846. roughness: number;
  26847. /**
  26848. * In case of refraction, define the value of the index of refraction.
  26849. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26850. */
  26851. indexOfRefraction: number;
  26852. /**
  26853. * Invert the refraction texture alongside the y axis.
  26854. * It can be useful with procedural textures or probe for instance.
  26855. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26856. */
  26857. invertRefractionY: boolean;
  26858. /**
  26859. * Defines the alpha limits in alpha test mode.
  26860. */
  26861. alphaCutOff: number;
  26862. private _useLightmapAsShadowmap;
  26863. /**
  26864. * In case of light mapping, define whether the map contains light or shadow informations.
  26865. */
  26866. useLightmapAsShadowmap: boolean;
  26867. private _diffuseFresnelParameters;
  26868. /**
  26869. * Define the diffuse fresnel parameters of the material.
  26870. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26871. */
  26872. diffuseFresnelParameters: FresnelParameters;
  26873. private _opacityFresnelParameters;
  26874. /**
  26875. * Define the opacity fresnel parameters of the material.
  26876. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26877. */
  26878. opacityFresnelParameters: FresnelParameters;
  26879. private _reflectionFresnelParameters;
  26880. /**
  26881. * Define the reflection fresnel parameters of the material.
  26882. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26883. */
  26884. reflectionFresnelParameters: FresnelParameters;
  26885. private _refractionFresnelParameters;
  26886. /**
  26887. * Define the refraction fresnel parameters of the material.
  26888. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26889. */
  26890. refractionFresnelParameters: FresnelParameters;
  26891. private _emissiveFresnelParameters;
  26892. /**
  26893. * Define the emissive fresnel parameters of the material.
  26894. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26895. */
  26896. emissiveFresnelParameters: FresnelParameters;
  26897. private _useReflectionFresnelFromSpecular;
  26898. /**
  26899. * If true automatically deducts the fresnels values from the material specularity.
  26900. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26901. */
  26902. useReflectionFresnelFromSpecular: boolean;
  26903. private _useGlossinessFromSpecularMapAlpha;
  26904. /**
  26905. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26906. */
  26907. useGlossinessFromSpecularMapAlpha: boolean;
  26908. private _maxSimultaneousLights;
  26909. /**
  26910. * Defines the maximum number of lights that can be used in the material
  26911. */
  26912. maxSimultaneousLights: number;
  26913. private _invertNormalMapX;
  26914. /**
  26915. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26916. */
  26917. invertNormalMapX: boolean;
  26918. private _invertNormalMapY;
  26919. /**
  26920. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26921. */
  26922. invertNormalMapY: boolean;
  26923. private _twoSidedLighting;
  26924. /**
  26925. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26926. */
  26927. twoSidedLighting: boolean;
  26928. /**
  26929. * Default configuration related to image processing available in the standard Material.
  26930. */
  26931. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26932. /**
  26933. * Gets the image processing configuration used either in this material.
  26934. */
  26935. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26936. /**
  26937. * Sets the Default image processing configuration used either in the this material.
  26938. *
  26939. * If sets to null, the scene one is in use.
  26940. */
  26941. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26942. /**
  26943. * Keep track of the image processing observer to allow dispose and replace.
  26944. */
  26945. private _imageProcessingObserver;
  26946. /**
  26947. * Attaches a new image processing configuration to the Standard Material.
  26948. * @param configuration
  26949. */
  26950. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26951. /**
  26952. * Gets wether the color curves effect is enabled.
  26953. */
  26954. get cameraColorCurvesEnabled(): boolean;
  26955. /**
  26956. * Sets wether the color curves effect is enabled.
  26957. */
  26958. set cameraColorCurvesEnabled(value: boolean);
  26959. /**
  26960. * Gets wether the color grading effect is enabled.
  26961. */
  26962. get cameraColorGradingEnabled(): boolean;
  26963. /**
  26964. * Gets wether the color grading effect is enabled.
  26965. */
  26966. set cameraColorGradingEnabled(value: boolean);
  26967. /**
  26968. * Gets wether tonemapping is enabled or not.
  26969. */
  26970. get cameraToneMappingEnabled(): boolean;
  26971. /**
  26972. * Sets wether tonemapping is enabled or not
  26973. */
  26974. set cameraToneMappingEnabled(value: boolean);
  26975. /**
  26976. * The camera exposure used on this material.
  26977. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26978. * This corresponds to a photographic exposure.
  26979. */
  26980. get cameraExposure(): number;
  26981. /**
  26982. * The camera exposure used on this material.
  26983. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26984. * This corresponds to a photographic exposure.
  26985. */
  26986. set cameraExposure(value: number);
  26987. /**
  26988. * Gets The camera contrast used on this material.
  26989. */
  26990. get cameraContrast(): number;
  26991. /**
  26992. * Sets The camera contrast used on this material.
  26993. */
  26994. set cameraContrast(value: number);
  26995. /**
  26996. * Gets the Color Grading 2D Lookup Texture.
  26997. */
  26998. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26999. /**
  27000. * Sets the Color Grading 2D Lookup Texture.
  27001. */
  27002. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27003. /**
  27004. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27005. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27006. * 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;
  27007. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27008. */
  27009. get cameraColorCurves(): Nullable<ColorCurves>;
  27010. /**
  27011. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27012. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27013. * 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;
  27014. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27015. */
  27016. set cameraColorCurves(value: Nullable<ColorCurves>);
  27017. /**
  27018. * Custom callback helping to override the default shader used in the material.
  27019. */
  27020. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27021. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27022. protected _worldViewProjectionMatrix: Matrix;
  27023. protected _globalAmbientColor: Color3;
  27024. protected _useLogarithmicDepth: boolean;
  27025. protected _rebuildInParallel: boolean;
  27026. /**
  27027. * Instantiates a new standard material.
  27028. * This is the default material used in Babylon. It is the best trade off between quality
  27029. * and performances.
  27030. * @see http://doc.babylonjs.com/babylon101/materials
  27031. * @param name Define the name of the material in the scene
  27032. * @param scene Define the scene the material belong to
  27033. */
  27034. constructor(name: string, scene: Scene);
  27035. /**
  27036. * Gets a boolean indicating that current material needs to register RTT
  27037. */
  27038. get hasRenderTargetTextures(): boolean;
  27039. /**
  27040. * Gets the current class name of the material e.g. "StandardMaterial"
  27041. * Mainly use in serialization.
  27042. * @returns the class name
  27043. */
  27044. getClassName(): string;
  27045. /**
  27046. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27047. * You can try switching to logarithmic depth.
  27048. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27049. */
  27050. get useLogarithmicDepth(): boolean;
  27051. set useLogarithmicDepth(value: boolean);
  27052. /**
  27053. * Specifies if the material will require alpha blending
  27054. * @returns a boolean specifying if alpha blending is needed
  27055. */
  27056. needAlphaBlending(): boolean;
  27057. /**
  27058. * Specifies if this material should be rendered in alpha test mode
  27059. * @returns a boolean specifying if an alpha test is needed.
  27060. */
  27061. needAlphaTesting(): boolean;
  27062. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27063. /**
  27064. * Get the texture used for alpha test purpose.
  27065. * @returns the diffuse texture in case of the standard material.
  27066. */
  27067. getAlphaTestTexture(): Nullable<BaseTexture>;
  27068. /**
  27069. * Get if the submesh is ready to be used and all its information available.
  27070. * Child classes can use it to update shaders
  27071. * @param mesh defines the mesh to check
  27072. * @param subMesh defines which submesh to check
  27073. * @param useInstances specifies that instances should be used
  27074. * @returns a boolean indicating that the submesh is ready or not
  27075. */
  27076. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27077. /**
  27078. * Builds the material UBO layouts.
  27079. * Used internally during the effect preparation.
  27080. */
  27081. buildUniformLayout(): void;
  27082. /**
  27083. * Unbinds the material from the mesh
  27084. */
  27085. unbind(): void;
  27086. /**
  27087. * Binds the submesh to this material by preparing the effect and shader to draw
  27088. * @param world defines the world transformation matrix
  27089. * @param mesh defines the mesh containing the submesh
  27090. * @param subMesh defines the submesh to bind the material to
  27091. */
  27092. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27093. /**
  27094. * Get the list of animatables in the material.
  27095. * @returns the list of animatables object used in the material
  27096. */
  27097. getAnimatables(): IAnimatable[];
  27098. /**
  27099. * Gets the active textures from the material
  27100. * @returns an array of textures
  27101. */
  27102. getActiveTextures(): BaseTexture[];
  27103. /**
  27104. * Specifies if the material uses a texture
  27105. * @param texture defines the texture to check against the material
  27106. * @returns a boolean specifying if the material uses the texture
  27107. */
  27108. hasTexture(texture: BaseTexture): boolean;
  27109. /**
  27110. * Disposes the material
  27111. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27112. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27113. */
  27114. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27115. /**
  27116. * Makes a duplicate of the material, and gives it a new name
  27117. * @param name defines the new name for the duplicated material
  27118. * @returns the cloned material
  27119. */
  27120. clone(name: string): StandardMaterial;
  27121. /**
  27122. * Serializes this material in a JSON representation
  27123. * @returns the serialized material object
  27124. */
  27125. serialize(): any;
  27126. /**
  27127. * Creates a standard material from parsed material data
  27128. * @param source defines the JSON representation of the material
  27129. * @param scene defines the hosting scene
  27130. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27131. * @returns a new standard material
  27132. */
  27133. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27134. /**
  27135. * Are diffuse textures enabled in the application.
  27136. */
  27137. static get DiffuseTextureEnabled(): boolean;
  27138. static set DiffuseTextureEnabled(value: boolean);
  27139. /**
  27140. * Are ambient textures enabled in the application.
  27141. */
  27142. static get AmbientTextureEnabled(): boolean;
  27143. static set AmbientTextureEnabled(value: boolean);
  27144. /**
  27145. * Are opacity textures enabled in the application.
  27146. */
  27147. static get OpacityTextureEnabled(): boolean;
  27148. static set OpacityTextureEnabled(value: boolean);
  27149. /**
  27150. * Are reflection textures enabled in the application.
  27151. */
  27152. static get ReflectionTextureEnabled(): boolean;
  27153. static set ReflectionTextureEnabled(value: boolean);
  27154. /**
  27155. * Are emissive textures enabled in the application.
  27156. */
  27157. static get EmissiveTextureEnabled(): boolean;
  27158. static set EmissiveTextureEnabled(value: boolean);
  27159. /**
  27160. * Are specular textures enabled in the application.
  27161. */
  27162. static get SpecularTextureEnabled(): boolean;
  27163. static set SpecularTextureEnabled(value: boolean);
  27164. /**
  27165. * Are bump textures enabled in the application.
  27166. */
  27167. static get BumpTextureEnabled(): boolean;
  27168. static set BumpTextureEnabled(value: boolean);
  27169. /**
  27170. * Are lightmap textures enabled in the application.
  27171. */
  27172. static get LightmapTextureEnabled(): boolean;
  27173. static set LightmapTextureEnabled(value: boolean);
  27174. /**
  27175. * Are refraction textures enabled in the application.
  27176. */
  27177. static get RefractionTextureEnabled(): boolean;
  27178. static set RefractionTextureEnabled(value: boolean);
  27179. /**
  27180. * Are color grading textures enabled in the application.
  27181. */
  27182. static get ColorGradingTextureEnabled(): boolean;
  27183. static set ColorGradingTextureEnabled(value: boolean);
  27184. /**
  27185. * Are fresnels enabled in the application.
  27186. */
  27187. static get FresnelEnabled(): boolean;
  27188. static set FresnelEnabled(value: boolean);
  27189. }
  27190. }
  27191. declare module BABYLON {
  27192. /**
  27193. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27194. *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.
  27195. * The SPS is also a particle system. It provides some methods to manage the particles.
  27196. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27197. *
  27198. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27199. */
  27200. export class SolidParticleSystem implements IDisposable {
  27201. /**
  27202. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27203. * Example : var p = SPS.particles[i];
  27204. */
  27205. particles: SolidParticle[];
  27206. /**
  27207. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27208. */
  27209. nbParticles: number;
  27210. /**
  27211. * If the particles must ever face the camera (default false). Useful for planar particles.
  27212. */
  27213. billboard: boolean;
  27214. /**
  27215. * Recompute normals when adding a shape
  27216. */
  27217. recomputeNormals: boolean;
  27218. /**
  27219. * This a counter ofr your own usage. It's not set by any SPS functions.
  27220. */
  27221. counter: number;
  27222. /**
  27223. * The SPS name. This name is also given to the underlying mesh.
  27224. */
  27225. name: string;
  27226. /**
  27227. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27228. */
  27229. mesh: Mesh;
  27230. /**
  27231. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27232. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27233. */
  27234. vars: any;
  27235. /**
  27236. * This array is populated when the SPS is set as 'pickable'.
  27237. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27238. * Each element of this array is an object `{idx: int, faceId: int}`.
  27239. * `idx` is the picked particle index in the `SPS.particles` array
  27240. * `faceId` is the picked face index counted within this particle.
  27241. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27242. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27243. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27244. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27245. */
  27246. pickedParticles: {
  27247. idx: number;
  27248. faceId: number;
  27249. }[];
  27250. /**
  27251. * This array is populated when the SPS is set as 'pickable'
  27252. * Each key of this array is a submesh index.
  27253. * Each element of this array is a second array defined like this :
  27254. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27255. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27256. * `idx` is the picked particle index in the `SPS.particles` array
  27257. * `faceId` is the picked face index counted within this particle.
  27258. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27259. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27260. */
  27261. pickedBySubMesh: {
  27262. idx: number;
  27263. faceId: number;
  27264. }[][];
  27265. /**
  27266. * This array is populated when `enableDepthSort` is set to true.
  27267. * Each element of this array is an instance of the class DepthSortedParticle.
  27268. */
  27269. depthSortedParticles: DepthSortedParticle[];
  27270. /**
  27271. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27272. * @hidden
  27273. */
  27274. _bSphereOnly: boolean;
  27275. /**
  27276. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27277. * @hidden
  27278. */
  27279. _bSphereRadiusFactor: number;
  27280. private _scene;
  27281. private _positions;
  27282. private _indices;
  27283. private _normals;
  27284. private _colors;
  27285. private _uvs;
  27286. private _indices32;
  27287. private _positions32;
  27288. private _normals32;
  27289. private _fixedNormal32;
  27290. private _colors32;
  27291. private _uvs32;
  27292. private _index;
  27293. private _updatable;
  27294. private _pickable;
  27295. private _isVisibilityBoxLocked;
  27296. private _alwaysVisible;
  27297. private _depthSort;
  27298. private _expandable;
  27299. private _shapeCounter;
  27300. private _copy;
  27301. private _color;
  27302. private _computeParticleColor;
  27303. private _computeParticleTexture;
  27304. private _computeParticleRotation;
  27305. private _computeParticleVertex;
  27306. private _computeBoundingBox;
  27307. private _depthSortParticles;
  27308. private _camera;
  27309. private _mustUnrotateFixedNormals;
  27310. private _particlesIntersect;
  27311. private _needs32Bits;
  27312. private _isNotBuilt;
  27313. private _lastParticleId;
  27314. private _idxOfId;
  27315. private _multimaterialEnabled;
  27316. private _useModelMaterial;
  27317. private _indicesByMaterial;
  27318. private _materialIndexes;
  27319. private _depthSortFunction;
  27320. private _materialSortFunction;
  27321. private _materials;
  27322. private _multimaterial;
  27323. private _materialIndexesById;
  27324. private _defaultMaterial;
  27325. private _autoUpdateSubMeshes;
  27326. /**
  27327. * Creates a SPS (Solid Particle System) object.
  27328. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27329. * @param scene (Scene) is the scene in which the SPS is added.
  27330. * @param options defines the options of the sps e.g.
  27331. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27332. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27333. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27334. * * 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.
  27335. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27336. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27337. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27338. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27339. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27340. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27341. */
  27342. constructor(name: string, scene: Scene, options?: {
  27343. updatable?: boolean;
  27344. isPickable?: boolean;
  27345. enableDepthSort?: boolean;
  27346. particleIntersection?: boolean;
  27347. boundingSphereOnly?: boolean;
  27348. bSphereRadiusFactor?: number;
  27349. expandable?: boolean;
  27350. useModelMaterial?: boolean;
  27351. enableMultiMaterial?: boolean;
  27352. });
  27353. /**
  27354. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27355. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27356. * @returns the created mesh
  27357. */
  27358. buildMesh(): Mesh;
  27359. /**
  27360. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27361. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27362. * Thus the particles generated from `digest()` have their property `position` set yet.
  27363. * @param mesh ( Mesh ) is the mesh to be digested
  27364. * @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
  27365. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27366. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27367. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27368. * @returns the current SPS
  27369. */
  27370. digest(mesh: Mesh, options?: {
  27371. facetNb?: number;
  27372. number?: number;
  27373. delta?: number;
  27374. storage?: [];
  27375. }): SolidParticleSystem;
  27376. /**
  27377. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27378. * @hidden
  27379. */
  27380. private _unrotateFixedNormals;
  27381. /**
  27382. * Resets the temporary working copy particle
  27383. * @hidden
  27384. */
  27385. private _resetCopy;
  27386. /**
  27387. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27388. * @param p the current index in the positions array to be updated
  27389. * @param ind the current index in the indices array
  27390. * @param shape a Vector3 array, the shape geometry
  27391. * @param positions the positions array to be updated
  27392. * @param meshInd the shape indices array
  27393. * @param indices the indices array to be updated
  27394. * @param meshUV the shape uv array
  27395. * @param uvs the uv array to be updated
  27396. * @param meshCol the shape color array
  27397. * @param colors the color array to be updated
  27398. * @param meshNor the shape normals array
  27399. * @param normals the normals array to be updated
  27400. * @param idx the particle index
  27401. * @param idxInShape the particle index in its shape
  27402. * @param options the addShape() method passed options
  27403. * @model the particle model
  27404. * @hidden
  27405. */
  27406. private _meshBuilder;
  27407. /**
  27408. * Returns a shape Vector3 array from positions float array
  27409. * @param positions float array
  27410. * @returns a vector3 array
  27411. * @hidden
  27412. */
  27413. private _posToShape;
  27414. /**
  27415. * Returns a shapeUV array from a float uvs (array deep copy)
  27416. * @param uvs as a float array
  27417. * @returns a shapeUV array
  27418. * @hidden
  27419. */
  27420. private _uvsToShapeUV;
  27421. /**
  27422. * Adds a new particle object in the particles array
  27423. * @param idx particle index in particles array
  27424. * @param id particle id
  27425. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27426. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27427. * @param model particle ModelShape object
  27428. * @param shapeId model shape identifier
  27429. * @param idxInShape index of the particle in the current model
  27430. * @param bInfo model bounding info object
  27431. * @param storage target storage array, if any
  27432. * @hidden
  27433. */
  27434. private _addParticle;
  27435. /**
  27436. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27437. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27438. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27439. * @param nb (positive integer) the number of particles to be created from this model
  27440. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27441. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27442. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27443. * @returns the number of shapes in the system
  27444. */
  27445. addShape(mesh: Mesh, nb: number, options?: {
  27446. positionFunction?: any;
  27447. vertexFunction?: any;
  27448. storage?: [];
  27449. }): number;
  27450. /**
  27451. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27452. * @hidden
  27453. */
  27454. private _rebuildParticle;
  27455. /**
  27456. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27457. * @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.
  27458. * @returns the SPS.
  27459. */
  27460. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27461. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27462. * Returns an array with the removed particles.
  27463. * 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.
  27464. * The SPS can't be empty so at least one particle needs to remain in place.
  27465. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27466. * @param start index of the first particle to remove
  27467. * @param end index of the last particle to remove (included)
  27468. * @returns an array populated with the removed particles
  27469. */
  27470. removeParticles(start: number, end: number): SolidParticle[];
  27471. /**
  27472. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27473. * @param solidParticleArray an array populated with Solid Particles objects
  27474. * @returns the SPS
  27475. */
  27476. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27477. /**
  27478. * Creates a new particle and modifies the SPS mesh geometry :
  27479. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27480. * - calls _addParticle() to populate the particle array
  27481. * factorized code from addShape() and insertParticlesFromArray()
  27482. * @param idx particle index in the particles array
  27483. * @param i particle index in its shape
  27484. * @param modelShape particle ModelShape object
  27485. * @param shape shape vertex array
  27486. * @param meshInd shape indices array
  27487. * @param meshUV shape uv array
  27488. * @param meshCol shape color array
  27489. * @param meshNor shape normals array
  27490. * @param bbInfo shape bounding info
  27491. * @param storage target particle storage
  27492. * @options addShape() passed options
  27493. * @hidden
  27494. */
  27495. private _insertNewParticle;
  27496. /**
  27497. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27498. * This method calls `updateParticle()` for each particle of the SPS.
  27499. * For an animated SPS, it is usually called within the render loop.
  27500. * 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.
  27501. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27502. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27503. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27504. * @returns the SPS.
  27505. */
  27506. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27507. /**
  27508. * Disposes the SPS.
  27509. */
  27510. dispose(): void;
  27511. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27512. * idx is the particle index in the SPS
  27513. * faceId is the picked face index counted within this particle.
  27514. * Returns null if the pickInfo can't identify a picked particle.
  27515. * @param pickingInfo (PickingInfo object)
  27516. * @returns {idx: number, faceId: number} or null
  27517. */
  27518. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27519. idx: number;
  27520. faceId: number;
  27521. }>;
  27522. /**
  27523. * Returns a SolidParticle object from its identifier : particle.id
  27524. * @param id (integer) the particle Id
  27525. * @returns the searched particle or null if not found in the SPS.
  27526. */
  27527. getParticleById(id: number): Nullable<SolidParticle>;
  27528. /**
  27529. * Returns a new array populated with the particles having the passed shapeId.
  27530. * @param shapeId (integer) the shape identifier
  27531. * @returns a new solid particle array
  27532. */
  27533. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27534. /**
  27535. * Populates the passed array "ref" with the particles having the passed shapeId.
  27536. * @param shapeId the shape identifier
  27537. * @returns the SPS
  27538. * @param ref
  27539. */
  27540. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27541. /**
  27542. * Computes the required SubMeshes according the materials assigned to the particles.
  27543. * @returns the solid particle system.
  27544. * Does nothing if called before the SPS mesh is built.
  27545. */
  27546. computeSubMeshes(): SolidParticleSystem;
  27547. /**
  27548. * Sorts the solid particles by material when MultiMaterial is enabled.
  27549. * Updates the indices32 array.
  27550. * Updates the indicesByMaterial array.
  27551. * Updates the mesh indices array.
  27552. * @returns the SPS
  27553. * @hidden
  27554. */
  27555. private _sortParticlesByMaterial;
  27556. /**
  27557. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27558. * @hidden
  27559. */
  27560. private _setMaterialIndexesById;
  27561. /**
  27562. * Returns an array with unique values of Materials from the passed array
  27563. * @param array the material array to be checked and filtered
  27564. * @hidden
  27565. */
  27566. private _filterUniqueMaterialId;
  27567. /**
  27568. * Sets a new Standard Material as _defaultMaterial if not already set.
  27569. * @hidden
  27570. */
  27571. private _setDefaultMaterial;
  27572. /**
  27573. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27574. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27575. * @returns the SPS.
  27576. */
  27577. refreshVisibleSize(): SolidParticleSystem;
  27578. /**
  27579. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27580. * @param size the size (float) of the visibility box
  27581. * note : this doesn't lock the SPS mesh bounding box.
  27582. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27583. */
  27584. setVisibilityBox(size: number): void;
  27585. /**
  27586. * Gets whether the SPS as always visible or not
  27587. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27588. */
  27589. get isAlwaysVisible(): boolean;
  27590. /**
  27591. * Sets the SPS as always visible or not
  27592. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27593. */
  27594. set isAlwaysVisible(val: boolean);
  27595. /**
  27596. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27597. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27598. */
  27599. set isVisibilityBoxLocked(val: boolean);
  27600. /**
  27601. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27602. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27603. */
  27604. get isVisibilityBoxLocked(): boolean;
  27605. /**
  27606. * Tells to `setParticles()` to compute the particle rotations or not.
  27607. * Default value : true. The SPS is faster when it's set to false.
  27608. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27609. */
  27610. set computeParticleRotation(val: boolean);
  27611. /**
  27612. * Tells to `setParticles()` to compute the particle colors or not.
  27613. * Default value : true. The SPS is faster when it's set to false.
  27614. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27615. */
  27616. set computeParticleColor(val: boolean);
  27617. set computeParticleTexture(val: boolean);
  27618. /**
  27619. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27620. * Default value : false. The SPS is faster when it's set to false.
  27621. * Note : the particle custom vertex positions aren't stored values.
  27622. */
  27623. set computeParticleVertex(val: boolean);
  27624. /**
  27625. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27626. */
  27627. set computeBoundingBox(val: boolean);
  27628. /**
  27629. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27630. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27631. * Default : `true`
  27632. */
  27633. set depthSortParticles(val: boolean);
  27634. /**
  27635. * Gets if `setParticles()` computes the particle rotations or not.
  27636. * Default value : true. The SPS is faster when it's set to false.
  27637. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27638. */
  27639. get computeParticleRotation(): boolean;
  27640. /**
  27641. * Gets if `setParticles()` computes the particle colors or not.
  27642. * Default value : true. The SPS is faster when it's set to false.
  27643. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27644. */
  27645. get computeParticleColor(): boolean;
  27646. /**
  27647. * Gets if `setParticles()` computes the particle textures or not.
  27648. * Default value : true. The SPS is faster when it's set to false.
  27649. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27650. */
  27651. get computeParticleTexture(): boolean;
  27652. /**
  27653. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27654. * Default value : false. The SPS is faster when it's set to false.
  27655. * Note : the particle custom vertex positions aren't stored values.
  27656. */
  27657. get computeParticleVertex(): boolean;
  27658. /**
  27659. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27660. */
  27661. get computeBoundingBox(): boolean;
  27662. /**
  27663. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27664. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27665. * Default : `true`
  27666. */
  27667. get depthSortParticles(): boolean;
  27668. /**
  27669. * Gets if the SPS is created as expandable at construction time.
  27670. * Default : `false`
  27671. */
  27672. get expandable(): boolean;
  27673. /**
  27674. * Gets if the SPS supports the Multi Materials
  27675. */
  27676. get multimaterialEnabled(): boolean;
  27677. /**
  27678. * Gets if the SPS uses the model materials for its own multimaterial.
  27679. */
  27680. get useModelMaterial(): boolean;
  27681. /**
  27682. * The SPS used material array.
  27683. */
  27684. get materials(): Material[];
  27685. /**
  27686. * Sets the SPS MultiMaterial from the passed materials.
  27687. * Note : the passed array is internally copied and not used then by reference.
  27688. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27689. */
  27690. setMultiMaterial(materials: Material[]): void;
  27691. /**
  27692. * The SPS computed multimaterial object
  27693. */
  27694. get multimaterial(): MultiMaterial;
  27695. set multimaterial(mm: MultiMaterial);
  27696. /**
  27697. * If the subMeshes must be updated on the next call to setParticles()
  27698. */
  27699. get autoUpdateSubMeshes(): boolean;
  27700. set autoUpdateSubMeshes(val: boolean);
  27701. /**
  27702. * This function does nothing. It may be overwritten to set all the particle first values.
  27703. * The SPS doesn't call this function, you may have to call it by your own.
  27704. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27705. */
  27706. initParticles(): void;
  27707. /**
  27708. * This function does nothing. It may be overwritten to recycle a particle.
  27709. * The SPS doesn't call this function, you may have to call it by your own.
  27710. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27711. * @param particle The particle to recycle
  27712. * @returns the recycled particle
  27713. */
  27714. recycleParticle(particle: SolidParticle): SolidParticle;
  27715. /**
  27716. * Updates a particle : this function should be overwritten by the user.
  27717. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27718. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27719. * @example : just set a particle position or velocity and recycle conditions
  27720. * @param particle The particle to update
  27721. * @returns the updated particle
  27722. */
  27723. updateParticle(particle: SolidParticle): SolidParticle;
  27724. /**
  27725. * Updates a vertex of a particle : it can be overwritten by the user.
  27726. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27727. * @param particle the current particle
  27728. * @param vertex the current index of the current particle
  27729. * @param pt the index of the current vertex in the particle shape
  27730. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27731. * @example : just set a vertex particle position
  27732. * @returns the updated vertex
  27733. */
  27734. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27735. /**
  27736. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27737. * This does nothing and may be overwritten by the user.
  27738. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27739. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27740. * @param update the boolean update value actually passed to setParticles()
  27741. */
  27742. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27743. /**
  27744. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27745. * This will be passed three parameters.
  27746. * This does nothing and may be overwritten by the user.
  27747. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27748. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27749. * @param update the boolean update value actually passed to setParticles()
  27750. */
  27751. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27752. }
  27753. }
  27754. declare module BABYLON {
  27755. /**
  27756. * Represents one particle of a solid particle system.
  27757. */
  27758. export class SolidParticle {
  27759. /**
  27760. * particle global index
  27761. */
  27762. idx: number;
  27763. /**
  27764. * particle identifier
  27765. */
  27766. id: number;
  27767. /**
  27768. * The color of the particle
  27769. */
  27770. color: Nullable<Color4>;
  27771. /**
  27772. * The world space position of the particle.
  27773. */
  27774. position: Vector3;
  27775. /**
  27776. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27777. */
  27778. rotation: Vector3;
  27779. /**
  27780. * The world space rotation quaternion of the particle.
  27781. */
  27782. rotationQuaternion: Nullable<Quaternion>;
  27783. /**
  27784. * The scaling of the particle.
  27785. */
  27786. scaling: Vector3;
  27787. /**
  27788. * The uvs of the particle.
  27789. */
  27790. uvs: Vector4;
  27791. /**
  27792. * The current speed of the particle.
  27793. */
  27794. velocity: Vector3;
  27795. /**
  27796. * The pivot point in the particle local space.
  27797. */
  27798. pivot: Vector3;
  27799. /**
  27800. * Must the particle be translated from its pivot point in its local space ?
  27801. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27802. * Default : false
  27803. */
  27804. translateFromPivot: boolean;
  27805. /**
  27806. * Is the particle active or not ?
  27807. */
  27808. alive: boolean;
  27809. /**
  27810. * Is the particle visible or not ?
  27811. */
  27812. isVisible: boolean;
  27813. /**
  27814. * Index of this particle in the global "positions" array (Internal use)
  27815. * @hidden
  27816. */
  27817. _pos: number;
  27818. /**
  27819. * @hidden Index of this particle in the global "indices" array (Internal use)
  27820. */
  27821. _ind: number;
  27822. /**
  27823. * @hidden ModelShape of this particle (Internal use)
  27824. */
  27825. _model: ModelShape;
  27826. /**
  27827. * ModelShape id of this particle
  27828. */
  27829. shapeId: number;
  27830. /**
  27831. * Index of the particle in its shape id
  27832. */
  27833. idxInShape: number;
  27834. /**
  27835. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27836. */
  27837. _modelBoundingInfo: BoundingInfo;
  27838. /**
  27839. * @hidden Particle BoundingInfo object (Internal use)
  27840. */
  27841. _boundingInfo: BoundingInfo;
  27842. /**
  27843. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27844. */
  27845. _sps: SolidParticleSystem;
  27846. /**
  27847. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27848. */
  27849. _stillInvisible: boolean;
  27850. /**
  27851. * @hidden Last computed particle rotation matrix
  27852. */
  27853. _rotationMatrix: number[];
  27854. /**
  27855. * Parent particle Id, if any.
  27856. * Default null.
  27857. */
  27858. parentId: Nullable<number>;
  27859. /**
  27860. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27861. */
  27862. materialIndex: Nullable<number>;
  27863. /**
  27864. * Custom object or properties.
  27865. */
  27866. props: Nullable<any>;
  27867. /**
  27868. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27869. * The possible values are :
  27870. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27871. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27872. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27873. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27874. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27875. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27876. * */
  27877. cullingStrategy: number;
  27878. /**
  27879. * @hidden Internal global position in the SPS.
  27880. */
  27881. _globalPosition: Vector3;
  27882. /**
  27883. * Creates a Solid Particle object.
  27884. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27885. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27886. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27887. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27888. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27889. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27890. * @param shapeId (integer) is the model shape identifier in the SPS.
  27891. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27892. * @param sps defines the sps it is associated to
  27893. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27894. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27895. */
  27896. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27897. /**
  27898. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27899. * @param target the particle target
  27900. * @returns the current particle
  27901. */
  27902. copyToRef(target: SolidParticle): SolidParticle;
  27903. /**
  27904. * Legacy support, changed scale to scaling
  27905. */
  27906. get scale(): Vector3;
  27907. /**
  27908. * Legacy support, changed scale to scaling
  27909. */
  27910. set scale(scale: Vector3);
  27911. /**
  27912. * Legacy support, changed quaternion to rotationQuaternion
  27913. */
  27914. get quaternion(): Nullable<Quaternion>;
  27915. /**
  27916. * Legacy support, changed quaternion to rotationQuaternion
  27917. */
  27918. set quaternion(q: Nullable<Quaternion>);
  27919. /**
  27920. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27921. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27922. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27923. * @returns true if it intersects
  27924. */
  27925. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27926. /**
  27927. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27928. * A particle is in the frustum if its bounding box intersects the frustum
  27929. * @param frustumPlanes defines the frustum to test
  27930. * @returns true if the particle is in the frustum planes
  27931. */
  27932. isInFrustum(frustumPlanes: Plane[]): boolean;
  27933. /**
  27934. * get the rotation matrix of the particle
  27935. * @hidden
  27936. */
  27937. getRotationMatrix(m: Matrix): void;
  27938. }
  27939. /**
  27940. * Represents the shape of the model used by one particle of a solid particle system.
  27941. * SPS internal tool, don't use it manually.
  27942. */
  27943. export class ModelShape {
  27944. /**
  27945. * The shape id
  27946. * @hidden
  27947. */
  27948. shapeID: number;
  27949. /**
  27950. * flat array of model positions (internal use)
  27951. * @hidden
  27952. */
  27953. _shape: Vector3[];
  27954. /**
  27955. * flat array of model UVs (internal use)
  27956. * @hidden
  27957. */
  27958. _shapeUV: number[];
  27959. /**
  27960. * color array of the model
  27961. * @hidden
  27962. */
  27963. _shapeColors: number[];
  27964. /**
  27965. * indices array of the model
  27966. * @hidden
  27967. */
  27968. _indices: number[];
  27969. /**
  27970. * normals array of the model
  27971. * @hidden
  27972. */
  27973. _normals: number[];
  27974. /**
  27975. * length of the shape in the model indices array (internal use)
  27976. * @hidden
  27977. */
  27978. _indicesLength: number;
  27979. /**
  27980. * Custom position function (internal use)
  27981. * @hidden
  27982. */
  27983. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27984. /**
  27985. * Custom vertex function (internal use)
  27986. * @hidden
  27987. */
  27988. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27989. /**
  27990. * Model material (internal use)
  27991. * @hidden
  27992. */
  27993. _material: Nullable<Material>;
  27994. /**
  27995. * 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.
  27996. * SPS internal tool, don't use it manually.
  27997. * @hidden
  27998. */
  27999. 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>);
  28000. }
  28001. /**
  28002. * Represents a Depth Sorted Particle in the solid particle system.
  28003. * @hidden
  28004. */
  28005. export class DepthSortedParticle {
  28006. /**
  28007. * Particle index
  28008. */
  28009. idx: number;
  28010. /**
  28011. * Index of the particle in the "indices" array
  28012. */
  28013. ind: number;
  28014. /**
  28015. * Length of the particle shape in the "indices" array
  28016. */
  28017. indicesLength: number;
  28018. /**
  28019. * Squared distance from the particle to the camera
  28020. */
  28021. sqDistance: number;
  28022. /**
  28023. * Material index when used with MultiMaterials
  28024. */
  28025. materialIndex: number;
  28026. /**
  28027. * Creates a new sorted particle
  28028. * @param materialIndex
  28029. */
  28030. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28031. }
  28032. }
  28033. declare module BABYLON {
  28034. /**
  28035. * @hidden
  28036. */
  28037. export class _MeshCollisionData {
  28038. _checkCollisions: boolean;
  28039. _collisionMask: number;
  28040. _collisionGroup: number;
  28041. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28042. _collider: Nullable<Collider>;
  28043. _oldPositionForCollisions: Vector3;
  28044. _diffPositionForCollisions: Vector3;
  28045. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28046. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28047. }
  28048. }
  28049. declare module BABYLON {
  28050. /** @hidden */
  28051. class _FacetDataStorage {
  28052. facetPositions: Vector3[];
  28053. facetNormals: Vector3[];
  28054. facetPartitioning: number[][];
  28055. facetNb: number;
  28056. partitioningSubdivisions: number;
  28057. partitioningBBoxRatio: number;
  28058. facetDataEnabled: boolean;
  28059. facetParameters: any;
  28060. bbSize: Vector3;
  28061. subDiv: {
  28062. max: number;
  28063. X: number;
  28064. Y: number;
  28065. Z: number;
  28066. };
  28067. facetDepthSort: boolean;
  28068. facetDepthSortEnabled: boolean;
  28069. depthSortedIndices: IndicesArray;
  28070. depthSortedFacets: {
  28071. ind: number;
  28072. sqDistance: number;
  28073. }[];
  28074. facetDepthSortFunction: (f1: {
  28075. ind: number;
  28076. sqDistance: number;
  28077. }, f2: {
  28078. ind: number;
  28079. sqDistance: number;
  28080. }) => number;
  28081. facetDepthSortFrom: Vector3;
  28082. facetDepthSortOrigin: Vector3;
  28083. invertedMatrix: Matrix;
  28084. }
  28085. /**
  28086. * @hidden
  28087. **/
  28088. class _InternalAbstractMeshDataInfo {
  28089. _hasVertexAlpha: boolean;
  28090. _useVertexColors: boolean;
  28091. _numBoneInfluencers: number;
  28092. _applyFog: boolean;
  28093. _receiveShadows: boolean;
  28094. _facetData: _FacetDataStorage;
  28095. _visibility: number;
  28096. _skeleton: Nullable<Skeleton>;
  28097. _layerMask: number;
  28098. _computeBonesUsingShaders: boolean;
  28099. _isActive: boolean;
  28100. _onlyForInstances: boolean;
  28101. _isActiveIntermediate: boolean;
  28102. _onlyForInstancesIntermediate: boolean;
  28103. _actAsRegularMesh: boolean;
  28104. }
  28105. /**
  28106. * Class used to store all common mesh properties
  28107. */
  28108. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28109. /** No occlusion */
  28110. static OCCLUSION_TYPE_NONE: number;
  28111. /** Occlusion set to optimisitic */
  28112. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28113. /** Occlusion set to strict */
  28114. static OCCLUSION_TYPE_STRICT: number;
  28115. /** Use an accurante occlusion algorithm */
  28116. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28117. /** Use a conservative occlusion algorithm */
  28118. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28119. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28120. * Test order :
  28121. * Is the bounding sphere outside the frustum ?
  28122. * If not, are the bounding box vertices outside the frustum ?
  28123. * It not, then the cullable object is in the frustum.
  28124. */
  28125. static readonly CULLINGSTRATEGY_STANDARD: number;
  28126. /** Culling strategy : Bounding Sphere Only.
  28127. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28128. * It's also less accurate than the standard because some not visible objects can still be selected.
  28129. * Test : is the bounding sphere outside the frustum ?
  28130. * If not, then the cullable object is in the frustum.
  28131. */
  28132. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28133. /** Culling strategy : Optimistic Inclusion.
  28134. * This in an inclusion test first, then the standard exclusion test.
  28135. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28136. * 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.
  28137. * Anyway, it's as accurate as the standard strategy.
  28138. * Test :
  28139. * Is the cullable object bounding sphere center in the frustum ?
  28140. * If not, apply the default culling strategy.
  28141. */
  28142. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28143. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28144. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28145. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28146. * 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.
  28147. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28148. * Test :
  28149. * Is the cullable object bounding sphere center in the frustum ?
  28150. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28151. */
  28152. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28153. /**
  28154. * No billboard
  28155. */
  28156. static get BILLBOARDMODE_NONE(): number;
  28157. /** Billboard on X axis */
  28158. static get BILLBOARDMODE_X(): number;
  28159. /** Billboard on Y axis */
  28160. static get BILLBOARDMODE_Y(): number;
  28161. /** Billboard on Z axis */
  28162. static get BILLBOARDMODE_Z(): number;
  28163. /** Billboard on all axes */
  28164. static get BILLBOARDMODE_ALL(): number;
  28165. /** Billboard on using position instead of orientation */
  28166. static get BILLBOARDMODE_USE_POSITION(): number;
  28167. /** @hidden */
  28168. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28169. /**
  28170. * The culling strategy to use to check whether the mesh must be rendered or not.
  28171. * This value can be changed at any time and will be used on the next render mesh selection.
  28172. * The possible values are :
  28173. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28174. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28175. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28176. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28177. * Please read each static variable documentation to get details about the culling process.
  28178. * */
  28179. cullingStrategy: number;
  28180. /**
  28181. * Gets the number of facets in the mesh
  28182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28183. */
  28184. get facetNb(): number;
  28185. /**
  28186. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28188. */
  28189. get partitioningSubdivisions(): number;
  28190. set partitioningSubdivisions(nb: number);
  28191. /**
  28192. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28193. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28195. */
  28196. get partitioningBBoxRatio(): number;
  28197. set partitioningBBoxRatio(ratio: number);
  28198. /**
  28199. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28200. * Works only for updatable meshes.
  28201. * Doesn't work with multi-materials
  28202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28203. */
  28204. get mustDepthSortFacets(): boolean;
  28205. set mustDepthSortFacets(sort: boolean);
  28206. /**
  28207. * The location (Vector3) where the facet depth sort must be computed from.
  28208. * By default, the active camera position.
  28209. * Used only when facet depth sort is enabled
  28210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28211. */
  28212. get facetDepthSortFrom(): Vector3;
  28213. set facetDepthSortFrom(location: Vector3);
  28214. /**
  28215. * gets a boolean indicating if facetData is enabled
  28216. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28217. */
  28218. get isFacetDataEnabled(): boolean;
  28219. /** @hidden */
  28220. _updateNonUniformScalingState(value: boolean): boolean;
  28221. /**
  28222. * An event triggered when this mesh collides with another one
  28223. */
  28224. onCollideObservable: Observable<AbstractMesh>;
  28225. /** Set a function to call when this mesh collides with another one */
  28226. set onCollide(callback: () => void);
  28227. /**
  28228. * An event triggered when the collision's position changes
  28229. */
  28230. onCollisionPositionChangeObservable: Observable<Vector3>;
  28231. /** Set a function to call when the collision's position changes */
  28232. set onCollisionPositionChange(callback: () => void);
  28233. /**
  28234. * An event triggered when material is changed
  28235. */
  28236. onMaterialChangedObservable: Observable<AbstractMesh>;
  28237. /**
  28238. * Gets or sets the orientation for POV movement & rotation
  28239. */
  28240. definedFacingForward: boolean;
  28241. /** @hidden */
  28242. _occlusionQuery: Nullable<WebGLQuery>;
  28243. /** @hidden */
  28244. _renderingGroup: Nullable<RenderingGroup>;
  28245. /**
  28246. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28247. */
  28248. get visibility(): number;
  28249. /**
  28250. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28251. */
  28252. set visibility(value: number);
  28253. /** Gets or sets the alpha index used to sort transparent meshes
  28254. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28255. */
  28256. alphaIndex: number;
  28257. /**
  28258. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28259. */
  28260. isVisible: boolean;
  28261. /**
  28262. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28263. */
  28264. isPickable: boolean;
  28265. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28266. showSubMeshesBoundingBox: boolean;
  28267. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28268. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28269. */
  28270. isBlocker: boolean;
  28271. /**
  28272. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28273. */
  28274. enablePointerMoveEvents: boolean;
  28275. /**
  28276. * Specifies the rendering group id for this mesh (0 by default)
  28277. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28278. */
  28279. renderingGroupId: number;
  28280. private _material;
  28281. /** Gets or sets current material */
  28282. get material(): Nullable<Material>;
  28283. set material(value: Nullable<Material>);
  28284. /**
  28285. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28286. * @see http://doc.babylonjs.com/babylon101/shadows
  28287. */
  28288. get receiveShadows(): boolean;
  28289. set receiveShadows(value: boolean);
  28290. /** Defines color to use when rendering outline */
  28291. outlineColor: Color3;
  28292. /** Define width to use when rendering outline */
  28293. outlineWidth: number;
  28294. /** Defines color to use when rendering overlay */
  28295. overlayColor: Color3;
  28296. /** Defines alpha to use when rendering overlay */
  28297. overlayAlpha: number;
  28298. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28299. get hasVertexAlpha(): boolean;
  28300. set hasVertexAlpha(value: boolean);
  28301. /** 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) */
  28302. get useVertexColors(): boolean;
  28303. set useVertexColors(value: boolean);
  28304. /**
  28305. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28306. */
  28307. get computeBonesUsingShaders(): boolean;
  28308. set computeBonesUsingShaders(value: boolean);
  28309. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28310. get numBoneInfluencers(): number;
  28311. set numBoneInfluencers(value: number);
  28312. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28313. get applyFog(): boolean;
  28314. set applyFog(value: boolean);
  28315. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28316. useOctreeForRenderingSelection: boolean;
  28317. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28318. useOctreeForPicking: boolean;
  28319. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28320. useOctreeForCollisions: boolean;
  28321. /**
  28322. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28323. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28324. */
  28325. get layerMask(): number;
  28326. set layerMask(value: number);
  28327. /**
  28328. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28329. */
  28330. alwaysSelectAsActiveMesh: boolean;
  28331. /**
  28332. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28333. */
  28334. doNotSyncBoundingInfo: boolean;
  28335. /**
  28336. * Gets or sets the current action manager
  28337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28338. */
  28339. actionManager: Nullable<AbstractActionManager>;
  28340. private _meshCollisionData;
  28341. /**
  28342. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28343. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28344. */
  28345. ellipsoid: Vector3;
  28346. /**
  28347. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28349. */
  28350. ellipsoidOffset: Vector3;
  28351. /**
  28352. * Gets or sets a collision mask used to mask collisions (default is -1).
  28353. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28354. */
  28355. get collisionMask(): number;
  28356. set collisionMask(mask: number);
  28357. /**
  28358. * Gets or sets the current collision group mask (-1 by default).
  28359. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28360. */
  28361. get collisionGroup(): number;
  28362. set collisionGroup(mask: number);
  28363. /**
  28364. * Gets or sets current surrounding meshes (null by default).
  28365. *
  28366. * By default collision detection is tested against every mesh in the scene.
  28367. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28368. * meshes will be tested for the collision.
  28369. *
  28370. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28371. */
  28372. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28373. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28374. /**
  28375. * Defines edge width used when edgesRenderer is enabled
  28376. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28377. */
  28378. edgesWidth: number;
  28379. /**
  28380. * Defines edge color used when edgesRenderer is enabled
  28381. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28382. */
  28383. edgesColor: Color4;
  28384. /** @hidden */
  28385. _edgesRenderer: Nullable<IEdgesRenderer>;
  28386. /** @hidden */
  28387. _masterMesh: Nullable<AbstractMesh>;
  28388. /** @hidden */
  28389. _boundingInfo: Nullable<BoundingInfo>;
  28390. /** @hidden */
  28391. _renderId: number;
  28392. /**
  28393. * Gets or sets the list of subMeshes
  28394. * @see http://doc.babylonjs.com/how_to/multi_materials
  28395. */
  28396. subMeshes: SubMesh[];
  28397. /** @hidden */
  28398. _intersectionsInProgress: AbstractMesh[];
  28399. /** @hidden */
  28400. _unIndexed: boolean;
  28401. /** @hidden */
  28402. _lightSources: Light[];
  28403. /** Gets the list of lights affecting that mesh */
  28404. get lightSources(): Light[];
  28405. /** @hidden */
  28406. get _positions(): Nullable<Vector3[]>;
  28407. /** @hidden */
  28408. _waitingData: {
  28409. lods: Nullable<any>;
  28410. actions: Nullable<any>;
  28411. freezeWorldMatrix: Nullable<boolean>;
  28412. };
  28413. /** @hidden */
  28414. _bonesTransformMatrices: Nullable<Float32Array>;
  28415. /** @hidden */
  28416. _transformMatrixTexture: Nullable<RawTexture>;
  28417. /**
  28418. * Gets or sets a skeleton to apply skining transformations
  28419. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28420. */
  28421. set skeleton(value: Nullable<Skeleton>);
  28422. get skeleton(): Nullable<Skeleton>;
  28423. /**
  28424. * An event triggered when the mesh is rebuilt.
  28425. */
  28426. onRebuildObservable: Observable<AbstractMesh>;
  28427. /**
  28428. * Creates a new AbstractMesh
  28429. * @param name defines the name of the mesh
  28430. * @param scene defines the hosting scene
  28431. */
  28432. constructor(name: string, scene?: Nullable<Scene>);
  28433. /**
  28434. * Returns the string "AbstractMesh"
  28435. * @returns "AbstractMesh"
  28436. */
  28437. getClassName(): string;
  28438. /**
  28439. * Gets a string representation of the current mesh
  28440. * @param fullDetails defines a boolean indicating if full details must be included
  28441. * @returns a string representation of the current mesh
  28442. */
  28443. toString(fullDetails?: boolean): string;
  28444. /**
  28445. * @hidden
  28446. */
  28447. protected _getEffectiveParent(): Nullable<Node>;
  28448. /** @hidden */
  28449. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28450. /** @hidden */
  28451. _rebuild(): void;
  28452. /** @hidden */
  28453. _resyncLightSources(): void;
  28454. /** @hidden */
  28455. _resyncLightSource(light: Light): void;
  28456. /** @hidden */
  28457. _unBindEffect(): void;
  28458. /** @hidden */
  28459. _removeLightSource(light: Light, dispose: boolean): void;
  28460. private _markSubMeshesAsDirty;
  28461. /** @hidden */
  28462. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28463. /** @hidden */
  28464. _markSubMeshesAsAttributesDirty(): void;
  28465. /** @hidden */
  28466. _markSubMeshesAsMiscDirty(): void;
  28467. /**
  28468. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28469. */
  28470. get scaling(): Vector3;
  28471. set scaling(newScaling: Vector3);
  28472. /**
  28473. * Returns true if the mesh is blocked. Implemented by child classes
  28474. */
  28475. get isBlocked(): boolean;
  28476. /**
  28477. * Returns the mesh itself by default. Implemented by child classes
  28478. * @param camera defines the camera to use to pick the right LOD level
  28479. * @returns the currentAbstractMesh
  28480. */
  28481. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28482. /**
  28483. * Returns 0 by default. Implemented by child classes
  28484. * @returns an integer
  28485. */
  28486. getTotalVertices(): number;
  28487. /**
  28488. * Returns a positive integer : the total number of indices in this mesh geometry.
  28489. * @returns the numner of indices or zero if the mesh has no geometry.
  28490. */
  28491. getTotalIndices(): number;
  28492. /**
  28493. * Returns null by default. Implemented by child classes
  28494. * @returns null
  28495. */
  28496. getIndices(): Nullable<IndicesArray>;
  28497. /**
  28498. * Returns the array of the requested vertex data kind. Implemented by child classes
  28499. * @param kind defines the vertex data kind to use
  28500. * @returns null
  28501. */
  28502. getVerticesData(kind: string): Nullable<FloatArray>;
  28503. /**
  28504. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28505. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28506. * Note that a new underlying VertexBuffer object is created each call.
  28507. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28508. * @param kind defines vertex data kind:
  28509. * * VertexBuffer.PositionKind
  28510. * * VertexBuffer.UVKind
  28511. * * VertexBuffer.UV2Kind
  28512. * * VertexBuffer.UV3Kind
  28513. * * VertexBuffer.UV4Kind
  28514. * * VertexBuffer.UV5Kind
  28515. * * VertexBuffer.UV6Kind
  28516. * * VertexBuffer.ColorKind
  28517. * * VertexBuffer.MatricesIndicesKind
  28518. * * VertexBuffer.MatricesIndicesExtraKind
  28519. * * VertexBuffer.MatricesWeightsKind
  28520. * * VertexBuffer.MatricesWeightsExtraKind
  28521. * @param data defines the data source
  28522. * @param updatable defines if the data must be flagged as updatable (or static)
  28523. * @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
  28524. * @returns the current mesh
  28525. */
  28526. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28527. /**
  28528. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28529. * If the mesh has no geometry, it is simply returned as it is.
  28530. * @param kind defines vertex data kind:
  28531. * * VertexBuffer.PositionKind
  28532. * * VertexBuffer.UVKind
  28533. * * VertexBuffer.UV2Kind
  28534. * * VertexBuffer.UV3Kind
  28535. * * VertexBuffer.UV4Kind
  28536. * * VertexBuffer.UV5Kind
  28537. * * VertexBuffer.UV6Kind
  28538. * * VertexBuffer.ColorKind
  28539. * * VertexBuffer.MatricesIndicesKind
  28540. * * VertexBuffer.MatricesIndicesExtraKind
  28541. * * VertexBuffer.MatricesWeightsKind
  28542. * * VertexBuffer.MatricesWeightsExtraKind
  28543. * @param data defines the data source
  28544. * @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
  28545. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28546. * @returns the current mesh
  28547. */
  28548. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28549. /**
  28550. * Sets the mesh indices,
  28551. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28552. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28553. * @param totalVertices Defines the total number of vertices
  28554. * @returns the current mesh
  28555. */
  28556. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28557. /**
  28558. * Gets a boolean indicating if specific vertex data is present
  28559. * @param kind defines the vertex data kind to use
  28560. * @returns true is data kind is present
  28561. */
  28562. isVerticesDataPresent(kind: string): boolean;
  28563. /**
  28564. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28565. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28566. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28567. * @returns a BoundingInfo
  28568. */
  28569. getBoundingInfo(): BoundingInfo;
  28570. /**
  28571. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28572. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28573. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28574. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28575. * @returns the current mesh
  28576. */
  28577. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28578. /**
  28579. * Overwrite the current bounding info
  28580. * @param boundingInfo defines the new bounding info
  28581. * @returns the current mesh
  28582. */
  28583. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28584. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28585. get useBones(): boolean;
  28586. /** @hidden */
  28587. _preActivate(): void;
  28588. /** @hidden */
  28589. _preActivateForIntermediateRendering(renderId: number): void;
  28590. /** @hidden */
  28591. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28592. /** @hidden */
  28593. _postActivate(): void;
  28594. /** @hidden */
  28595. _freeze(): void;
  28596. /** @hidden */
  28597. _unFreeze(): void;
  28598. /**
  28599. * Gets the current world matrix
  28600. * @returns a Matrix
  28601. */
  28602. getWorldMatrix(): Matrix;
  28603. /** @hidden */
  28604. _getWorldMatrixDeterminant(): number;
  28605. /**
  28606. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28607. */
  28608. get isAnInstance(): boolean;
  28609. /**
  28610. * Gets a boolean indicating if this mesh has instances
  28611. */
  28612. get hasInstances(): boolean;
  28613. /**
  28614. * Perform relative position change from the point of view of behind the front of the mesh.
  28615. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28616. * Supports definition of mesh facing forward or backward
  28617. * @param amountRight defines the distance on the right axis
  28618. * @param amountUp defines the distance on the up axis
  28619. * @param amountForward defines the distance on the forward axis
  28620. * @returns the current mesh
  28621. */
  28622. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28623. /**
  28624. * Calculate relative position change from the point of view of behind the front of the mesh.
  28625. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28626. * Supports definition of mesh facing forward or backward
  28627. * @param amountRight defines the distance on the right axis
  28628. * @param amountUp defines the distance on the up axis
  28629. * @param amountForward defines the distance on the forward axis
  28630. * @returns the new displacement vector
  28631. */
  28632. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28633. /**
  28634. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28635. * Supports definition of mesh facing forward or backward
  28636. * @param flipBack defines the flip
  28637. * @param twirlClockwise defines the twirl
  28638. * @param tiltRight defines the tilt
  28639. * @returns the current mesh
  28640. */
  28641. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28642. /**
  28643. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28644. * Supports definition of mesh facing forward or backward.
  28645. * @param flipBack defines the flip
  28646. * @param twirlClockwise defines the twirl
  28647. * @param tiltRight defines the tilt
  28648. * @returns the new rotation vector
  28649. */
  28650. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28651. /**
  28652. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28653. * This means the mesh underlying bounding box and sphere are recomputed.
  28654. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28655. * @returns the current mesh
  28656. */
  28657. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28658. /** @hidden */
  28659. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28660. /** @hidden */
  28661. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28662. /** @hidden */
  28663. _updateBoundingInfo(): AbstractMesh;
  28664. /** @hidden */
  28665. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28666. /** @hidden */
  28667. protected _afterComputeWorldMatrix(): void;
  28668. /** @hidden */
  28669. get _effectiveMesh(): AbstractMesh;
  28670. /**
  28671. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28672. * A mesh is in the frustum if its bounding box intersects the frustum
  28673. * @param frustumPlanes defines the frustum to test
  28674. * @returns true if the mesh is in the frustum planes
  28675. */
  28676. isInFrustum(frustumPlanes: Plane[]): boolean;
  28677. /**
  28678. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28679. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28680. * @param frustumPlanes defines the frustum to test
  28681. * @returns true if the mesh is completely in the frustum planes
  28682. */
  28683. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28684. /**
  28685. * True if the mesh intersects another mesh or a SolidParticle object
  28686. * @param mesh defines a target mesh or SolidParticle to test
  28687. * @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)
  28688. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28689. * @returns true if there is an intersection
  28690. */
  28691. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28692. /**
  28693. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28694. * @param point defines the point to test
  28695. * @returns true if there is an intersection
  28696. */
  28697. intersectsPoint(point: Vector3): boolean;
  28698. /**
  28699. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28700. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28701. */
  28702. get checkCollisions(): boolean;
  28703. set checkCollisions(collisionEnabled: boolean);
  28704. /**
  28705. * Gets Collider object used to compute collisions (not physics)
  28706. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28707. */
  28708. get collider(): Nullable<Collider>;
  28709. /**
  28710. * Move the mesh using collision engine
  28711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28712. * @param displacement defines the requested displacement vector
  28713. * @returns the current mesh
  28714. */
  28715. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28716. private _onCollisionPositionChange;
  28717. /** @hidden */
  28718. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28719. /** @hidden */
  28720. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28721. /** @hidden */
  28722. _checkCollision(collider: Collider): AbstractMesh;
  28723. /** @hidden */
  28724. _generatePointsArray(): boolean;
  28725. /**
  28726. * Checks if the passed Ray intersects with the mesh
  28727. * @param ray defines the ray to use
  28728. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28729. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28730. * @returns the picking info
  28731. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28732. */
  28733. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28734. /**
  28735. * Clones the current mesh
  28736. * @param name defines the mesh name
  28737. * @param newParent defines the new mesh parent
  28738. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28739. * @returns the new mesh
  28740. */
  28741. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28742. /**
  28743. * Disposes all the submeshes of the current meshnp
  28744. * @returns the current mesh
  28745. */
  28746. releaseSubMeshes(): AbstractMesh;
  28747. /**
  28748. * Releases resources associated with this abstract mesh.
  28749. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28750. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28751. */
  28752. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28753. /**
  28754. * Adds the passed mesh as a child to the current mesh
  28755. * @param mesh defines the child mesh
  28756. * @returns the current mesh
  28757. */
  28758. addChild(mesh: AbstractMesh): AbstractMesh;
  28759. /**
  28760. * Removes the passed mesh from the current mesh children list
  28761. * @param mesh defines the child mesh
  28762. * @returns the current mesh
  28763. */
  28764. removeChild(mesh: AbstractMesh): AbstractMesh;
  28765. /** @hidden */
  28766. private _initFacetData;
  28767. /**
  28768. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28769. * This method can be called within the render loop.
  28770. * 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
  28771. * @returns the current mesh
  28772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28773. */
  28774. updateFacetData(): AbstractMesh;
  28775. /**
  28776. * Returns the facetLocalNormals array.
  28777. * The normals are expressed in the mesh local spac
  28778. * @returns an array of Vector3
  28779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28780. */
  28781. getFacetLocalNormals(): Vector3[];
  28782. /**
  28783. * Returns the facetLocalPositions array.
  28784. * The facet positions are expressed in the mesh local space
  28785. * @returns an array of Vector3
  28786. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28787. */
  28788. getFacetLocalPositions(): Vector3[];
  28789. /**
  28790. * Returns the facetLocalPartioning array
  28791. * @returns an array of array of numbers
  28792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28793. */
  28794. getFacetLocalPartitioning(): number[][];
  28795. /**
  28796. * Returns the i-th facet position in the world system.
  28797. * This method allocates a new Vector3 per call
  28798. * @param i defines the facet index
  28799. * @returns a new Vector3
  28800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28801. */
  28802. getFacetPosition(i: number): Vector3;
  28803. /**
  28804. * Sets the reference Vector3 with the i-th facet position in the world system
  28805. * @param i defines the facet index
  28806. * @param ref defines the target vector
  28807. * @returns the current mesh
  28808. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28809. */
  28810. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28811. /**
  28812. * Returns the i-th facet normal in the world system.
  28813. * This method allocates a new Vector3 per call
  28814. * @param i defines the facet index
  28815. * @returns a new Vector3
  28816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28817. */
  28818. getFacetNormal(i: number): Vector3;
  28819. /**
  28820. * Sets the reference Vector3 with the i-th facet normal in the world system
  28821. * @param i defines the facet index
  28822. * @param ref defines the target vector
  28823. * @returns the current mesh
  28824. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28825. */
  28826. getFacetNormalToRef(i: number, ref: Vector3): this;
  28827. /**
  28828. * 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)
  28829. * @param x defines x coordinate
  28830. * @param y defines y coordinate
  28831. * @param z defines z coordinate
  28832. * @returns the array of facet indexes
  28833. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28834. */
  28835. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28836. /**
  28837. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28838. * @param projected sets as the (x,y,z) world projection on the facet
  28839. * @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
  28840. * @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
  28841. * @param x defines x coordinate
  28842. * @param y defines y coordinate
  28843. * @param z defines z coordinate
  28844. * @returns the face index if found (or null instead)
  28845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28846. */
  28847. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28848. /**
  28849. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28850. * @param projected sets as the (x,y,z) local projection on the facet
  28851. * @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
  28852. * @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
  28853. * @param x defines x coordinate
  28854. * @param y defines y coordinate
  28855. * @param z defines z coordinate
  28856. * @returns the face index if found (or null instead)
  28857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28858. */
  28859. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28860. /**
  28861. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28862. * @returns the parameters
  28863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28864. */
  28865. getFacetDataParameters(): any;
  28866. /**
  28867. * Disables the feature FacetData and frees the related memory
  28868. * @returns the current mesh
  28869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28870. */
  28871. disableFacetData(): AbstractMesh;
  28872. /**
  28873. * Updates the AbstractMesh indices array
  28874. * @param indices defines the data source
  28875. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28876. * @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)
  28877. * @returns the current mesh
  28878. */
  28879. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28880. /**
  28881. * Creates new normals data for the mesh
  28882. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28883. * @returns the current mesh
  28884. */
  28885. createNormals(updatable: boolean): AbstractMesh;
  28886. /**
  28887. * Align the mesh with a normal
  28888. * @param normal defines the normal to use
  28889. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28890. * @returns the current mesh
  28891. */
  28892. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28893. /** @hidden */
  28894. _checkOcclusionQuery(): boolean;
  28895. /**
  28896. * Disables the mesh edge rendering mode
  28897. * @returns the currentAbstractMesh
  28898. */
  28899. disableEdgesRendering(): AbstractMesh;
  28900. /**
  28901. * Enables the edge rendering mode on the mesh.
  28902. * This mode makes the mesh edges visible
  28903. * @param epsilon defines the maximal distance between two angles to detect a face
  28904. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28905. * @returns the currentAbstractMesh
  28906. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28907. */
  28908. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28909. }
  28910. }
  28911. declare module BABYLON {
  28912. /**
  28913. * Interface used to define ActionEvent
  28914. */
  28915. export interface IActionEvent {
  28916. /** The mesh or sprite that triggered the action */
  28917. source: any;
  28918. /** The X mouse cursor position at the time of the event */
  28919. pointerX: number;
  28920. /** The Y mouse cursor position at the time of the event */
  28921. pointerY: number;
  28922. /** The mesh that is currently pointed at (can be null) */
  28923. meshUnderPointer: Nullable<AbstractMesh>;
  28924. /** the original (browser) event that triggered the ActionEvent */
  28925. sourceEvent?: any;
  28926. /** additional data for the event */
  28927. additionalData?: any;
  28928. }
  28929. /**
  28930. * ActionEvent is the event being sent when an action is triggered.
  28931. */
  28932. export class ActionEvent implements IActionEvent {
  28933. /** The mesh or sprite that triggered the action */
  28934. source: any;
  28935. /** The X mouse cursor position at the time of the event */
  28936. pointerX: number;
  28937. /** The Y mouse cursor position at the time of the event */
  28938. pointerY: number;
  28939. /** The mesh that is currently pointed at (can be null) */
  28940. meshUnderPointer: Nullable<AbstractMesh>;
  28941. /** the original (browser) event that triggered the ActionEvent */
  28942. sourceEvent?: any;
  28943. /** additional data for the event */
  28944. additionalData?: any;
  28945. /**
  28946. * Creates a new ActionEvent
  28947. * @param source The mesh or sprite that triggered the action
  28948. * @param pointerX The X mouse cursor position at the time of the event
  28949. * @param pointerY The Y mouse cursor position at the time of the event
  28950. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28951. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28952. * @param additionalData additional data for the event
  28953. */
  28954. constructor(
  28955. /** The mesh or sprite that triggered the action */
  28956. source: any,
  28957. /** The X mouse cursor position at the time of the event */
  28958. pointerX: number,
  28959. /** The Y mouse cursor position at the time of the event */
  28960. pointerY: number,
  28961. /** The mesh that is currently pointed at (can be null) */
  28962. meshUnderPointer: Nullable<AbstractMesh>,
  28963. /** the original (browser) event that triggered the ActionEvent */
  28964. sourceEvent?: any,
  28965. /** additional data for the event */
  28966. additionalData?: any);
  28967. /**
  28968. * Helper function to auto-create an ActionEvent from a source mesh.
  28969. * @param source The source mesh that triggered the event
  28970. * @param evt The original (browser) event
  28971. * @param additionalData additional data for the event
  28972. * @returns the new ActionEvent
  28973. */
  28974. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28975. /**
  28976. * Helper function to auto-create an ActionEvent from a source sprite
  28977. * @param source The source sprite that triggered the event
  28978. * @param scene Scene associated with the sprite
  28979. * @param evt The original (browser) event
  28980. * @param additionalData additional data for the event
  28981. * @returns the new ActionEvent
  28982. */
  28983. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28984. /**
  28985. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28986. * @param scene the scene where the event occurred
  28987. * @param evt The original (browser) event
  28988. * @returns the new ActionEvent
  28989. */
  28990. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28991. /**
  28992. * Helper function to auto-create an ActionEvent from a primitive
  28993. * @param prim defines the target primitive
  28994. * @param pointerPos defines the pointer position
  28995. * @param evt The original (browser) event
  28996. * @param additionalData additional data for the event
  28997. * @returns the new ActionEvent
  28998. */
  28999. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29000. }
  29001. }
  29002. declare module BABYLON {
  29003. /**
  29004. * Abstract class used to decouple action Manager from scene and meshes.
  29005. * Do not instantiate.
  29006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29007. */
  29008. export abstract class AbstractActionManager implements IDisposable {
  29009. /** Gets the list of active triggers */
  29010. static Triggers: {
  29011. [key: string]: number;
  29012. };
  29013. /** Gets the cursor to use when hovering items */
  29014. hoverCursor: string;
  29015. /** Gets the list of actions */
  29016. actions: IAction[];
  29017. /**
  29018. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29019. */
  29020. isRecursive: boolean;
  29021. /**
  29022. * Releases all associated resources
  29023. */
  29024. abstract dispose(): void;
  29025. /**
  29026. * Does this action manager has pointer triggers
  29027. */
  29028. abstract get hasPointerTriggers(): boolean;
  29029. /**
  29030. * Does this action manager has pick triggers
  29031. */
  29032. abstract get hasPickTriggers(): boolean;
  29033. /**
  29034. * Process a specific trigger
  29035. * @param trigger defines the trigger to process
  29036. * @param evt defines the event details to be processed
  29037. */
  29038. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29039. /**
  29040. * Does this action manager handles actions of any of the given triggers
  29041. * @param triggers defines the triggers to be tested
  29042. * @return a boolean indicating whether one (or more) of the triggers is handled
  29043. */
  29044. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29045. /**
  29046. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29047. * speed.
  29048. * @param triggerA defines the trigger to be tested
  29049. * @param triggerB defines the trigger to be tested
  29050. * @return a boolean indicating whether one (or more) of the triggers is handled
  29051. */
  29052. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29053. /**
  29054. * Does this action manager handles actions of a given trigger
  29055. * @param trigger defines the trigger to be tested
  29056. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29057. * @return whether the trigger is handled
  29058. */
  29059. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29060. /**
  29061. * Serialize this manager to a JSON object
  29062. * @param name defines the property name to store this manager
  29063. * @returns a JSON representation of this manager
  29064. */
  29065. abstract serialize(name: string): any;
  29066. /**
  29067. * Registers an action to this action manager
  29068. * @param action defines the action to be registered
  29069. * @return the action amended (prepared) after registration
  29070. */
  29071. abstract registerAction(action: IAction): Nullable<IAction>;
  29072. /**
  29073. * Unregisters an action to this action manager
  29074. * @param action defines the action to be unregistered
  29075. * @return a boolean indicating whether the action has been unregistered
  29076. */
  29077. abstract unregisterAction(action: IAction): Boolean;
  29078. /**
  29079. * Does exist one action manager with at least one trigger
  29080. **/
  29081. static get HasTriggers(): boolean;
  29082. /**
  29083. * Does exist one action manager with at least one pick trigger
  29084. **/
  29085. static get HasPickTriggers(): boolean;
  29086. /**
  29087. * Does exist one action manager that handles actions of a given trigger
  29088. * @param trigger defines the trigger to be tested
  29089. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29090. **/
  29091. static HasSpecificTrigger(trigger: number): boolean;
  29092. }
  29093. }
  29094. declare module BABYLON {
  29095. /**
  29096. * Defines how a node can be built from a string name.
  29097. */
  29098. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29099. /**
  29100. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29101. */
  29102. export class Node implements IBehaviorAware<Node> {
  29103. /** @hidden */
  29104. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29105. private static _NodeConstructors;
  29106. /**
  29107. * Add a new node constructor
  29108. * @param type defines the type name of the node to construct
  29109. * @param constructorFunc defines the constructor function
  29110. */
  29111. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29112. /**
  29113. * Returns a node constructor based on type name
  29114. * @param type defines the type name
  29115. * @param name defines the new node name
  29116. * @param scene defines the hosting scene
  29117. * @param options defines optional options to transmit to constructors
  29118. * @returns the new constructor or null
  29119. */
  29120. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29121. /**
  29122. * Gets or sets the name of the node
  29123. */
  29124. name: string;
  29125. /**
  29126. * Gets or sets the id of the node
  29127. */
  29128. id: string;
  29129. /**
  29130. * Gets or sets the unique id of the node
  29131. */
  29132. uniqueId: number;
  29133. /**
  29134. * Gets or sets a string used to store user defined state for the node
  29135. */
  29136. state: string;
  29137. /**
  29138. * Gets or sets an object used to store user defined information for the node
  29139. */
  29140. metadata: any;
  29141. /**
  29142. * For internal use only. Please do not use.
  29143. */
  29144. reservedDataStore: any;
  29145. /**
  29146. * List of inspectable custom properties (used by the Inspector)
  29147. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29148. */
  29149. inspectableCustomProperties: IInspectable[];
  29150. private _doNotSerialize;
  29151. /**
  29152. * Gets or sets a boolean used to define if the node must be serialized
  29153. */
  29154. get doNotSerialize(): boolean;
  29155. set doNotSerialize(value: boolean);
  29156. /** @hidden */
  29157. _isDisposed: boolean;
  29158. /**
  29159. * Gets a list of Animations associated with the node
  29160. */
  29161. animations: Animation[];
  29162. protected _ranges: {
  29163. [name: string]: Nullable<AnimationRange>;
  29164. };
  29165. /**
  29166. * Callback raised when the node is ready to be used
  29167. */
  29168. onReady: Nullable<(node: Node) => void>;
  29169. private _isEnabled;
  29170. private _isParentEnabled;
  29171. private _isReady;
  29172. /** @hidden */
  29173. _currentRenderId: number;
  29174. private _parentUpdateId;
  29175. /** @hidden */
  29176. _childUpdateId: number;
  29177. /** @hidden */
  29178. _waitingParentId: Nullable<string>;
  29179. /** @hidden */
  29180. _scene: Scene;
  29181. /** @hidden */
  29182. _cache: any;
  29183. private _parentNode;
  29184. private _children;
  29185. /** @hidden */
  29186. _worldMatrix: Matrix;
  29187. /** @hidden */
  29188. _worldMatrixDeterminant: number;
  29189. /** @hidden */
  29190. _worldMatrixDeterminantIsDirty: boolean;
  29191. /** @hidden */
  29192. private _sceneRootNodesIndex;
  29193. /**
  29194. * Gets a boolean indicating if the node has been disposed
  29195. * @returns true if the node was disposed
  29196. */
  29197. isDisposed(): boolean;
  29198. /**
  29199. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29200. * @see https://doc.babylonjs.com/how_to/parenting
  29201. */
  29202. set parent(parent: Nullable<Node>);
  29203. get parent(): Nullable<Node>;
  29204. /** @hidden */
  29205. _addToSceneRootNodes(): void;
  29206. /** @hidden */
  29207. _removeFromSceneRootNodes(): void;
  29208. private _animationPropertiesOverride;
  29209. /**
  29210. * Gets or sets the animation properties override
  29211. */
  29212. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29213. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29214. /**
  29215. * Gets a string idenfifying the name of the class
  29216. * @returns "Node" string
  29217. */
  29218. getClassName(): string;
  29219. /** @hidden */
  29220. readonly _isNode: boolean;
  29221. /**
  29222. * An event triggered when the mesh is disposed
  29223. */
  29224. onDisposeObservable: Observable<Node>;
  29225. private _onDisposeObserver;
  29226. /**
  29227. * Sets a callback that will be raised when the node will be disposed
  29228. */
  29229. set onDispose(callback: () => void);
  29230. /**
  29231. * Creates a new Node
  29232. * @param name the name and id to be given to this node
  29233. * @param scene the scene this node will be added to
  29234. */
  29235. constructor(name: string, scene?: Nullable<Scene>);
  29236. /**
  29237. * Gets the scene of the node
  29238. * @returns a scene
  29239. */
  29240. getScene(): Scene;
  29241. /**
  29242. * Gets the engine of the node
  29243. * @returns a Engine
  29244. */
  29245. getEngine(): Engine;
  29246. private _behaviors;
  29247. /**
  29248. * Attach a behavior to the node
  29249. * @see http://doc.babylonjs.com/features/behaviour
  29250. * @param behavior defines the behavior to attach
  29251. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29252. * @returns the current Node
  29253. */
  29254. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29255. /**
  29256. * Remove an attached behavior
  29257. * @see http://doc.babylonjs.com/features/behaviour
  29258. * @param behavior defines the behavior to attach
  29259. * @returns the current Node
  29260. */
  29261. removeBehavior(behavior: Behavior<Node>): Node;
  29262. /**
  29263. * Gets the list of attached behaviors
  29264. * @see http://doc.babylonjs.com/features/behaviour
  29265. */
  29266. get behaviors(): Behavior<Node>[];
  29267. /**
  29268. * Gets an attached behavior by name
  29269. * @param name defines the name of the behavior to look for
  29270. * @see http://doc.babylonjs.com/features/behaviour
  29271. * @returns null if behavior was not found else the requested behavior
  29272. */
  29273. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29274. /**
  29275. * Returns the latest update of the World matrix
  29276. * @returns a Matrix
  29277. */
  29278. getWorldMatrix(): Matrix;
  29279. /** @hidden */
  29280. _getWorldMatrixDeterminant(): number;
  29281. /**
  29282. * Returns directly the latest state of the mesh World matrix.
  29283. * A Matrix is returned.
  29284. */
  29285. get worldMatrixFromCache(): Matrix;
  29286. /** @hidden */
  29287. _initCache(): void;
  29288. /** @hidden */
  29289. updateCache(force?: boolean): void;
  29290. /** @hidden */
  29291. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29292. /** @hidden */
  29293. _updateCache(ignoreParentClass?: boolean): void;
  29294. /** @hidden */
  29295. _isSynchronized(): boolean;
  29296. /** @hidden */
  29297. _markSyncedWithParent(): void;
  29298. /** @hidden */
  29299. isSynchronizedWithParent(): boolean;
  29300. /** @hidden */
  29301. isSynchronized(): boolean;
  29302. /**
  29303. * Is this node ready to be used/rendered
  29304. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29305. * @return true if the node is ready
  29306. */
  29307. isReady(completeCheck?: boolean): boolean;
  29308. /**
  29309. * Is this node enabled?
  29310. * 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
  29311. * @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
  29312. * @return whether this node (and its parent) is enabled
  29313. */
  29314. isEnabled(checkAncestors?: boolean): boolean;
  29315. /** @hidden */
  29316. protected _syncParentEnabledState(): void;
  29317. /**
  29318. * Set the enabled state of this node
  29319. * @param value defines the new enabled state
  29320. */
  29321. setEnabled(value: boolean): void;
  29322. /**
  29323. * Is this node a descendant of the given node?
  29324. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29325. * @param ancestor defines the parent node to inspect
  29326. * @returns a boolean indicating if this node is a descendant of the given node
  29327. */
  29328. isDescendantOf(ancestor: Node): boolean;
  29329. /** @hidden */
  29330. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29331. /**
  29332. * Will return all nodes that have this node as ascendant
  29333. * @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
  29334. * @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
  29335. * @return all children nodes of all types
  29336. */
  29337. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29338. /**
  29339. * Get all child-meshes of this node
  29340. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  29341. * @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
  29342. * @returns an array of AbstractMesh
  29343. */
  29344. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29345. /**
  29346. * Get all direct children of this node
  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. * @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)
  29349. * @returns an array of Node
  29350. */
  29351. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29352. /** @hidden */
  29353. _setReady(state: boolean): void;
  29354. /**
  29355. * Get an animation by name
  29356. * @param name defines the name of the animation to look for
  29357. * @returns null if not found else the requested animation
  29358. */
  29359. getAnimationByName(name: string): Nullable<Animation>;
  29360. /**
  29361. * Creates an animation range for this node
  29362. * @param name defines the name of the range
  29363. * @param from defines the starting key
  29364. * @param to defines the end key
  29365. */
  29366. createAnimationRange(name: string, from: number, to: number): void;
  29367. /**
  29368. * Delete a specific animation range
  29369. * @param name defines the name of the range to delete
  29370. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29371. */
  29372. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29373. /**
  29374. * Get an animation range by name
  29375. * @param name defines the name of the animation range to look for
  29376. * @returns null if not found else the requested animation range
  29377. */
  29378. getAnimationRange(name: string): Nullable<AnimationRange>;
  29379. /**
  29380. * Gets the list of all animation ranges defined on this node
  29381. * @returns an array
  29382. */
  29383. getAnimationRanges(): Nullable<AnimationRange>[];
  29384. /**
  29385. * Will start the animation sequence
  29386. * @param name defines the range frames for animation sequence
  29387. * @param loop defines if the animation should loop (false by default)
  29388. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29389. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29390. * @returns the object created for this animation. If range does not exist, it will return null
  29391. */
  29392. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29393. /**
  29394. * Serialize animation ranges into a JSON compatible object
  29395. * @returns serialization object
  29396. */
  29397. serializeAnimationRanges(): any;
  29398. /**
  29399. * Computes the world matrix of the node
  29400. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29401. * @returns the world matrix
  29402. */
  29403. computeWorldMatrix(force?: boolean): Matrix;
  29404. /**
  29405. * Releases resources associated with this node.
  29406. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29407. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29408. */
  29409. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29410. /**
  29411. * Parse animation range data from a serialization object and store them into a given node
  29412. * @param node defines where to store the animation ranges
  29413. * @param parsedNode defines the serialization object to read data from
  29414. * @param scene defines the hosting scene
  29415. */
  29416. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29417. /**
  29418. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29419. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29420. * @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
  29421. * @returns the new bounding vectors
  29422. */
  29423. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29424. min: Vector3;
  29425. max: Vector3;
  29426. };
  29427. }
  29428. }
  29429. declare module BABYLON {
  29430. /**
  29431. * @hidden
  29432. */
  29433. export class _IAnimationState {
  29434. key: number;
  29435. repeatCount: number;
  29436. workValue?: any;
  29437. loopMode?: number;
  29438. offsetValue?: any;
  29439. highLimitValue?: any;
  29440. }
  29441. /**
  29442. * Class used to store any kind of animation
  29443. */
  29444. export class Animation {
  29445. /**Name of the animation */
  29446. name: string;
  29447. /**Property to animate */
  29448. targetProperty: string;
  29449. /**The frames per second of the animation */
  29450. framePerSecond: number;
  29451. /**The data type of the animation */
  29452. dataType: number;
  29453. /**The loop mode of the animation */
  29454. loopMode?: number | undefined;
  29455. /**Specifies if blending should be enabled */
  29456. enableBlending?: boolean | undefined;
  29457. /**
  29458. * Use matrix interpolation instead of using direct key value when animating matrices
  29459. */
  29460. static AllowMatricesInterpolation: boolean;
  29461. /**
  29462. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29463. */
  29464. static AllowMatrixDecomposeForInterpolation: boolean;
  29465. /**
  29466. * Stores the key frames of the animation
  29467. */
  29468. private _keys;
  29469. /**
  29470. * Stores the easing function of the animation
  29471. */
  29472. private _easingFunction;
  29473. /**
  29474. * @hidden Internal use only
  29475. */
  29476. _runtimeAnimations: RuntimeAnimation[];
  29477. /**
  29478. * The set of event that will be linked to this animation
  29479. */
  29480. private _events;
  29481. /**
  29482. * Stores an array of target property paths
  29483. */
  29484. targetPropertyPath: string[];
  29485. /**
  29486. * Stores the blending speed of the animation
  29487. */
  29488. blendingSpeed: number;
  29489. /**
  29490. * Stores the animation ranges for the animation
  29491. */
  29492. private _ranges;
  29493. /**
  29494. * @hidden Internal use
  29495. */
  29496. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29497. /**
  29498. * Sets up an animation
  29499. * @param property The property to animate
  29500. * @param animationType The animation type to apply
  29501. * @param framePerSecond The frames per second of the animation
  29502. * @param easingFunction The easing function used in the animation
  29503. * @returns The created animation
  29504. */
  29505. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29506. /**
  29507. * Create and start an animation on a node
  29508. * @param name defines the name of the global animation that will be run on all nodes
  29509. * @param node defines the root node where the animation will take place
  29510. * @param targetProperty defines property to animate
  29511. * @param framePerSecond defines the number of frame per second yo use
  29512. * @param totalFrame defines the number of frames in total
  29513. * @param from defines the initial value
  29514. * @param to defines the final value
  29515. * @param loopMode defines which loop mode you want to use (off by default)
  29516. * @param easingFunction defines the easing function to use (linear by default)
  29517. * @param onAnimationEnd defines the callback to call when animation end
  29518. * @returns the animatable created for this animation
  29519. */
  29520. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29521. /**
  29522. * Create and start an animation on a node and its descendants
  29523. * @param name defines the name of the global animation that will be run on all nodes
  29524. * @param node defines the root node where the animation will take place
  29525. * @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
  29526. * @param targetProperty defines property to animate
  29527. * @param framePerSecond defines the number of frame per second to use
  29528. * @param totalFrame defines the number of frames in total
  29529. * @param from defines the initial value
  29530. * @param to defines the final value
  29531. * @param loopMode defines which loop mode you want to use (off by default)
  29532. * @param easingFunction defines the easing function to use (linear by default)
  29533. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29534. * @returns the list of animatables created for all nodes
  29535. * @example https://www.babylonjs-playground.com/#MH0VLI
  29536. */
  29537. 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[]>;
  29538. /**
  29539. * Creates a new animation, merges it with the existing animations and starts it
  29540. * @param name Name of the animation
  29541. * @param node Node which contains the scene that begins the animations
  29542. * @param targetProperty Specifies which property to animate
  29543. * @param framePerSecond The frames per second of the animation
  29544. * @param totalFrame The total number of frames
  29545. * @param from The frame at the beginning of the animation
  29546. * @param to The frame at the end of the animation
  29547. * @param loopMode Specifies the loop mode of the animation
  29548. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29549. * @param onAnimationEnd Callback to run once the animation is complete
  29550. * @returns Nullable animation
  29551. */
  29552. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29553. /**
  29554. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29555. * @param sourceAnimation defines the Animation containing keyframes to convert
  29556. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29557. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29558. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29559. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29560. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29561. */
  29562. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29563. /**
  29564. * Transition property of an host to the target Value
  29565. * @param property The property to transition
  29566. * @param targetValue The target Value of the property
  29567. * @param host The object where the property to animate belongs
  29568. * @param scene Scene used to run the animation
  29569. * @param frameRate Framerate (in frame/s) to use
  29570. * @param transition The transition type we want to use
  29571. * @param duration The duration of the animation, in milliseconds
  29572. * @param onAnimationEnd Callback trigger at the end of the animation
  29573. * @returns Nullable animation
  29574. */
  29575. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29576. /**
  29577. * Return the array of runtime animations currently using this animation
  29578. */
  29579. get runtimeAnimations(): RuntimeAnimation[];
  29580. /**
  29581. * Specifies if any of the runtime animations are currently running
  29582. */
  29583. get hasRunningRuntimeAnimations(): boolean;
  29584. /**
  29585. * Initializes the animation
  29586. * @param name Name of the animation
  29587. * @param targetProperty Property to animate
  29588. * @param framePerSecond The frames per second of the animation
  29589. * @param dataType The data type of the animation
  29590. * @param loopMode The loop mode of the animation
  29591. * @param enableBlending Specifies if blending should be enabled
  29592. */
  29593. constructor(
  29594. /**Name of the animation */
  29595. name: string,
  29596. /**Property to animate */
  29597. targetProperty: string,
  29598. /**The frames per second of the animation */
  29599. framePerSecond: number,
  29600. /**The data type of the animation */
  29601. dataType: number,
  29602. /**The loop mode of the animation */
  29603. loopMode?: number | undefined,
  29604. /**Specifies if blending should be enabled */
  29605. enableBlending?: boolean | undefined);
  29606. /**
  29607. * Converts the animation to a string
  29608. * @param fullDetails support for multiple levels of logging within scene loading
  29609. * @returns String form of the animation
  29610. */
  29611. toString(fullDetails?: boolean): string;
  29612. /**
  29613. * Add an event to this animation
  29614. * @param event Event to add
  29615. */
  29616. addEvent(event: AnimationEvent): void;
  29617. /**
  29618. * Remove all events found at the given frame
  29619. * @param frame The frame to remove events from
  29620. */
  29621. removeEvents(frame: number): void;
  29622. /**
  29623. * Retrieves all the events from the animation
  29624. * @returns Events from the animation
  29625. */
  29626. getEvents(): AnimationEvent[];
  29627. /**
  29628. * Creates an animation range
  29629. * @param name Name of the animation range
  29630. * @param from Starting frame of the animation range
  29631. * @param to Ending frame of the animation
  29632. */
  29633. createRange(name: string, from: number, to: number): void;
  29634. /**
  29635. * Deletes an animation range by name
  29636. * @param name Name of the animation range to delete
  29637. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29638. */
  29639. deleteRange(name: string, deleteFrames?: boolean): void;
  29640. /**
  29641. * Gets the animation range by name, or null if not defined
  29642. * @param name Name of the animation range
  29643. * @returns Nullable animation range
  29644. */
  29645. getRange(name: string): Nullable<AnimationRange>;
  29646. /**
  29647. * Gets the key frames from the animation
  29648. * @returns The key frames of the animation
  29649. */
  29650. getKeys(): Array<IAnimationKey>;
  29651. /**
  29652. * Gets the highest frame rate of the animation
  29653. * @returns Highest frame rate of the animation
  29654. */
  29655. getHighestFrame(): number;
  29656. /**
  29657. * Gets the easing function of the animation
  29658. * @returns Easing function of the animation
  29659. */
  29660. getEasingFunction(): IEasingFunction;
  29661. /**
  29662. * Sets the easing function of the animation
  29663. * @param easingFunction A custom mathematical formula for animation
  29664. */
  29665. setEasingFunction(easingFunction: EasingFunction): void;
  29666. /**
  29667. * Interpolates a scalar linearly
  29668. * @param startValue Start value of the animation curve
  29669. * @param endValue End value of the animation curve
  29670. * @param gradient Scalar amount to interpolate
  29671. * @returns Interpolated scalar value
  29672. */
  29673. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29674. /**
  29675. * Interpolates a scalar cubically
  29676. * @param startValue Start value of the animation curve
  29677. * @param outTangent End tangent of the animation
  29678. * @param endValue End value of the animation curve
  29679. * @param inTangent Start tangent of the animation curve
  29680. * @param gradient Scalar amount to interpolate
  29681. * @returns Interpolated scalar value
  29682. */
  29683. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29684. /**
  29685. * Interpolates a quaternion using a spherical linear interpolation
  29686. * @param startValue Start value of the animation curve
  29687. * @param endValue End value of the animation curve
  29688. * @param gradient Scalar amount to interpolate
  29689. * @returns Interpolated quaternion value
  29690. */
  29691. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29692. /**
  29693. * Interpolates a quaternion cubically
  29694. * @param startValue Start value of the animation curve
  29695. * @param outTangent End tangent of the animation curve
  29696. * @param endValue End value of the animation curve
  29697. * @param inTangent Start tangent of the animation curve
  29698. * @param gradient Scalar amount to interpolate
  29699. * @returns Interpolated quaternion value
  29700. */
  29701. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29702. /**
  29703. * Interpolates a Vector3 linearl
  29704. * @param startValue Start value of the animation curve
  29705. * @param endValue End value of the animation curve
  29706. * @param gradient Scalar amount to interpolate
  29707. * @returns Interpolated scalar value
  29708. */
  29709. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29710. /**
  29711. * Interpolates a Vector3 cubically
  29712. * @param startValue Start value of the animation curve
  29713. * @param outTangent End tangent of the animation
  29714. * @param endValue End value of the animation curve
  29715. * @param inTangent Start tangent of the animation curve
  29716. * @param gradient Scalar amount to interpolate
  29717. * @returns InterpolatedVector3 value
  29718. */
  29719. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29720. /**
  29721. * Interpolates a Vector2 linearly
  29722. * @param startValue Start value of the animation curve
  29723. * @param endValue End value of the animation curve
  29724. * @param gradient Scalar amount to interpolate
  29725. * @returns Interpolated Vector2 value
  29726. */
  29727. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29728. /**
  29729. * Interpolates a Vector2 cubically
  29730. * @param startValue Start value of the animation curve
  29731. * @param outTangent End tangent of the animation
  29732. * @param endValue End value of the animation curve
  29733. * @param inTangent Start tangent of the animation curve
  29734. * @param gradient Scalar amount to interpolate
  29735. * @returns Interpolated Vector2 value
  29736. */
  29737. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29738. /**
  29739. * Interpolates a size linearly
  29740. * @param startValue Start value of the animation curve
  29741. * @param endValue End value of the animation curve
  29742. * @param gradient Scalar amount to interpolate
  29743. * @returns Interpolated Size value
  29744. */
  29745. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29746. /**
  29747. * Interpolates a Color3 linearly
  29748. * @param startValue Start value of the animation curve
  29749. * @param endValue End value of the animation curve
  29750. * @param gradient Scalar amount to interpolate
  29751. * @returns Interpolated Color3 value
  29752. */
  29753. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29754. /**
  29755. * Interpolates a Color4 linearly
  29756. * @param startValue Start value of the animation curve
  29757. * @param endValue End value of the animation curve
  29758. * @param gradient Scalar amount to interpolate
  29759. * @returns Interpolated Color3 value
  29760. */
  29761. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29762. /**
  29763. * @hidden Internal use only
  29764. */
  29765. _getKeyValue(value: any): any;
  29766. /**
  29767. * @hidden Internal use only
  29768. */
  29769. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29770. /**
  29771. * Defines the function to use to interpolate matrices
  29772. * @param startValue defines the start matrix
  29773. * @param endValue defines the end matrix
  29774. * @param gradient defines the gradient between both matrices
  29775. * @param result defines an optional target matrix where to store the interpolation
  29776. * @returns the interpolated matrix
  29777. */
  29778. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29779. /**
  29780. * Makes a copy of the animation
  29781. * @returns Cloned animation
  29782. */
  29783. clone(): Animation;
  29784. /**
  29785. * Sets the key frames of the animation
  29786. * @param values The animation key frames to set
  29787. */
  29788. setKeys(values: Array<IAnimationKey>): void;
  29789. /**
  29790. * Serializes the animation to an object
  29791. * @returns Serialized object
  29792. */
  29793. serialize(): any;
  29794. /**
  29795. * Float animation type
  29796. */
  29797. static readonly ANIMATIONTYPE_FLOAT: number;
  29798. /**
  29799. * Vector3 animation type
  29800. */
  29801. static readonly ANIMATIONTYPE_VECTOR3: number;
  29802. /**
  29803. * Quaternion animation type
  29804. */
  29805. static readonly ANIMATIONTYPE_QUATERNION: number;
  29806. /**
  29807. * Matrix animation type
  29808. */
  29809. static readonly ANIMATIONTYPE_MATRIX: number;
  29810. /**
  29811. * Color3 animation type
  29812. */
  29813. static readonly ANIMATIONTYPE_COLOR3: number;
  29814. /**
  29815. * Color3 animation type
  29816. */
  29817. static readonly ANIMATIONTYPE_COLOR4: number;
  29818. /**
  29819. * Vector2 animation type
  29820. */
  29821. static readonly ANIMATIONTYPE_VECTOR2: number;
  29822. /**
  29823. * Size animation type
  29824. */
  29825. static readonly ANIMATIONTYPE_SIZE: number;
  29826. /**
  29827. * Relative Loop Mode
  29828. */
  29829. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29830. /**
  29831. * Cycle Loop Mode
  29832. */
  29833. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29834. /**
  29835. * Constant Loop Mode
  29836. */
  29837. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29838. /** @hidden */
  29839. static _UniversalLerp(left: any, right: any, amount: number): any;
  29840. /**
  29841. * Parses an animation object and creates an animation
  29842. * @param parsedAnimation Parsed animation object
  29843. * @returns Animation object
  29844. */
  29845. static Parse(parsedAnimation: any): Animation;
  29846. /**
  29847. * Appends the serialized animations from the source animations
  29848. * @param source Source containing the animations
  29849. * @param destination Target to store the animations
  29850. */
  29851. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29852. }
  29853. }
  29854. declare module BABYLON {
  29855. /**
  29856. * Interface containing an array of animations
  29857. */
  29858. export interface IAnimatable {
  29859. /**
  29860. * Array of animations
  29861. */
  29862. animations: Nullable<Array<Animation>>;
  29863. }
  29864. }
  29865. declare module BABYLON {
  29866. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29867. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29868. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29869. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29870. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29871. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29872. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29873. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29874. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29875. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29876. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29877. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29878. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29879. /**
  29880. * Decorator used to define property that can be serialized as reference to a camera
  29881. * @param sourceName defines the name of the property to decorate
  29882. */
  29883. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29884. /**
  29885. * Class used to help serialization objects
  29886. */
  29887. export class SerializationHelper {
  29888. /** @hidden */
  29889. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29890. /** @hidden */
  29891. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29892. /** @hidden */
  29893. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29894. /** @hidden */
  29895. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29896. /**
  29897. * Appends the serialized animations from the source animations
  29898. * @param source Source containing the animations
  29899. * @param destination Target to store the animations
  29900. */
  29901. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29902. /**
  29903. * Static function used to serialized a specific entity
  29904. * @param entity defines the entity to serialize
  29905. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29906. * @returns a JSON compatible object representing the serialization of the entity
  29907. */
  29908. static Serialize<T>(entity: T, serializationObject?: any): any;
  29909. /**
  29910. * Creates a new entity from a serialization data object
  29911. * @param creationFunction defines a function used to instanciated the new entity
  29912. * @param source defines the source serialization data
  29913. * @param scene defines the hosting scene
  29914. * @param rootUrl defines the root url for resources
  29915. * @returns a new entity
  29916. */
  29917. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29918. /**
  29919. * Clones an object
  29920. * @param creationFunction defines the function used to instanciate the new object
  29921. * @param source defines the source object
  29922. * @returns the cloned object
  29923. */
  29924. static Clone<T>(creationFunction: () => T, source: T): T;
  29925. /**
  29926. * Instanciates a new object based on a source one (some data will be shared between both object)
  29927. * @param creationFunction defines the function used to instanciate the new object
  29928. * @param source defines the source object
  29929. * @returns the new object
  29930. */
  29931. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29932. }
  29933. }
  29934. declare module BABYLON {
  29935. /**
  29936. * Class used to manipulate GUIDs
  29937. */
  29938. export class GUID {
  29939. /**
  29940. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29941. * Be aware Math.random() could cause collisions, but:
  29942. * "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"
  29943. * @returns a pseudo random id
  29944. */
  29945. static RandomId(): string;
  29946. }
  29947. }
  29948. declare module BABYLON {
  29949. /**
  29950. * Base class of all the textures in babylon.
  29951. * It groups all the common properties the materials, post process, lights... might need
  29952. * in order to make a correct use of the texture.
  29953. */
  29954. export class BaseTexture implements IAnimatable {
  29955. /**
  29956. * Default anisotropic filtering level for the application.
  29957. * It is set to 4 as a good tradeoff between perf and quality.
  29958. */
  29959. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29960. /**
  29961. * Gets or sets the unique id of the texture
  29962. */
  29963. uniqueId: number;
  29964. /**
  29965. * Define the name of the texture.
  29966. */
  29967. name: string;
  29968. /**
  29969. * Gets or sets an object used to store user defined information.
  29970. */
  29971. metadata: any;
  29972. /**
  29973. * For internal use only. Please do not use.
  29974. */
  29975. reservedDataStore: any;
  29976. private _hasAlpha;
  29977. /**
  29978. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29979. */
  29980. set hasAlpha(value: boolean);
  29981. get hasAlpha(): boolean;
  29982. /**
  29983. * Defines if the alpha value should be determined via the rgb values.
  29984. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29985. */
  29986. getAlphaFromRGB: boolean;
  29987. /**
  29988. * Intensity or strength of the texture.
  29989. * It is commonly used by materials to fine tune the intensity of the texture
  29990. */
  29991. level: number;
  29992. /**
  29993. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29994. * This is part of the texture as textures usually maps to one uv set.
  29995. */
  29996. coordinatesIndex: number;
  29997. private _coordinatesMode;
  29998. /**
  29999. * How a texture is mapped.
  30000. *
  30001. * | Value | Type | Description |
  30002. * | ----- | ----------------------------------- | ----------- |
  30003. * | 0 | EXPLICIT_MODE | |
  30004. * | 1 | SPHERICAL_MODE | |
  30005. * | 2 | PLANAR_MODE | |
  30006. * | 3 | CUBIC_MODE | |
  30007. * | 4 | PROJECTION_MODE | |
  30008. * | 5 | SKYBOX_MODE | |
  30009. * | 6 | INVCUBIC_MODE | |
  30010. * | 7 | EQUIRECTANGULAR_MODE | |
  30011. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30012. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30013. */
  30014. set coordinatesMode(value: number);
  30015. get coordinatesMode(): number;
  30016. /**
  30017. * | Value | Type | Description |
  30018. * | ----- | ------------------ | ----------- |
  30019. * | 0 | CLAMP_ADDRESSMODE | |
  30020. * | 1 | WRAP_ADDRESSMODE | |
  30021. * | 2 | MIRROR_ADDRESSMODE | |
  30022. */
  30023. wrapU: number;
  30024. /**
  30025. * | Value | Type | Description |
  30026. * | ----- | ------------------ | ----------- |
  30027. * | 0 | CLAMP_ADDRESSMODE | |
  30028. * | 1 | WRAP_ADDRESSMODE | |
  30029. * | 2 | MIRROR_ADDRESSMODE | |
  30030. */
  30031. wrapV: number;
  30032. /**
  30033. * | Value | Type | Description |
  30034. * | ----- | ------------------ | ----------- |
  30035. * | 0 | CLAMP_ADDRESSMODE | |
  30036. * | 1 | WRAP_ADDRESSMODE | |
  30037. * | 2 | MIRROR_ADDRESSMODE | |
  30038. */
  30039. wrapR: number;
  30040. /**
  30041. * With compliant hardware and browser (supporting anisotropic filtering)
  30042. * this defines the level of anisotropic filtering in the texture.
  30043. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30044. */
  30045. anisotropicFilteringLevel: number;
  30046. /**
  30047. * Define if the texture is a cube texture or if false a 2d texture.
  30048. */
  30049. get isCube(): boolean;
  30050. set isCube(value: boolean);
  30051. /**
  30052. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30053. */
  30054. get is3D(): boolean;
  30055. set is3D(value: boolean);
  30056. /**
  30057. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30058. */
  30059. get is2DArray(): boolean;
  30060. set is2DArray(value: boolean);
  30061. /**
  30062. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30063. * HDR texture are usually stored in linear space.
  30064. * This only impacts the PBR and Background materials
  30065. */
  30066. gammaSpace: boolean;
  30067. /**
  30068. * Gets or sets whether or not the texture contains RGBD data.
  30069. */
  30070. get isRGBD(): boolean;
  30071. set isRGBD(value: boolean);
  30072. /**
  30073. * Is Z inverted in the texture (useful in a cube texture).
  30074. */
  30075. invertZ: boolean;
  30076. /**
  30077. * Are mip maps generated for this texture or not.
  30078. */
  30079. get noMipmap(): boolean;
  30080. /**
  30081. * @hidden
  30082. */
  30083. lodLevelInAlpha: boolean;
  30084. /**
  30085. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30086. */
  30087. get lodGenerationOffset(): number;
  30088. set lodGenerationOffset(value: number);
  30089. /**
  30090. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30091. */
  30092. get lodGenerationScale(): number;
  30093. set lodGenerationScale(value: number);
  30094. /**
  30095. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30096. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30097. * average roughness values.
  30098. */
  30099. get linearSpecularLOD(): boolean;
  30100. set linearSpecularLOD(value: boolean);
  30101. /**
  30102. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30103. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30104. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30105. */
  30106. get irradianceTexture(): Nullable<BaseTexture>;
  30107. set irradianceTexture(value: Nullable<BaseTexture>);
  30108. /**
  30109. * Define if the texture is a render target.
  30110. */
  30111. isRenderTarget: boolean;
  30112. /**
  30113. * Define the unique id of the texture in the scene.
  30114. */
  30115. get uid(): string;
  30116. /**
  30117. * Return a string representation of the texture.
  30118. * @returns the texture as a string
  30119. */
  30120. toString(): string;
  30121. /**
  30122. * Get the class name of the texture.
  30123. * @returns "BaseTexture"
  30124. */
  30125. getClassName(): string;
  30126. /**
  30127. * Define the list of animation attached to the texture.
  30128. */
  30129. animations: Animation[];
  30130. /**
  30131. * An event triggered when the texture is disposed.
  30132. */
  30133. onDisposeObservable: Observable<BaseTexture>;
  30134. private _onDisposeObserver;
  30135. /**
  30136. * Callback triggered when the texture has been disposed.
  30137. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30138. */
  30139. set onDispose(callback: () => void);
  30140. /**
  30141. * Define the current state of the loading sequence when in delayed load mode.
  30142. */
  30143. delayLoadState: number;
  30144. private _scene;
  30145. /** @hidden */
  30146. _texture: Nullable<InternalTexture>;
  30147. private _uid;
  30148. /**
  30149. * Define if the texture is preventinga material to render or not.
  30150. * If not and the texture is not ready, the engine will use a default black texture instead.
  30151. */
  30152. get isBlocking(): boolean;
  30153. /**
  30154. * Instantiates a new BaseTexture.
  30155. * Base class of all the textures in babylon.
  30156. * It groups all the common properties the materials, post process, lights... might need
  30157. * in order to make a correct use of the texture.
  30158. * @param scene Define the scene the texture blongs to
  30159. */
  30160. constructor(scene: Nullable<Scene>);
  30161. /**
  30162. * Get the scene the texture belongs to.
  30163. * @returns the scene or null if undefined
  30164. */
  30165. getScene(): Nullable<Scene>;
  30166. /**
  30167. * Get the texture transform matrix used to offset tile the texture for istance.
  30168. * @returns the transformation matrix
  30169. */
  30170. getTextureMatrix(): Matrix;
  30171. /**
  30172. * Get the texture reflection matrix used to rotate/transform the reflection.
  30173. * @returns the reflection matrix
  30174. */
  30175. getReflectionTextureMatrix(): Matrix;
  30176. /**
  30177. * Get the underlying lower level texture from Babylon.
  30178. * @returns the insternal texture
  30179. */
  30180. getInternalTexture(): Nullable<InternalTexture>;
  30181. /**
  30182. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30183. * @returns true if ready or not blocking
  30184. */
  30185. isReadyOrNotBlocking(): boolean;
  30186. /**
  30187. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30188. * @returns true if fully ready
  30189. */
  30190. isReady(): boolean;
  30191. private _cachedSize;
  30192. /**
  30193. * Get the size of the texture.
  30194. * @returns the texture size.
  30195. */
  30196. getSize(): ISize;
  30197. /**
  30198. * Get the base size of the texture.
  30199. * It can be different from the size if the texture has been resized for POT for instance
  30200. * @returns the base size
  30201. */
  30202. getBaseSize(): ISize;
  30203. /**
  30204. * Update the sampling mode of the texture.
  30205. * Default is Trilinear mode.
  30206. *
  30207. * | Value | Type | Description |
  30208. * | ----- | ------------------ | ----------- |
  30209. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30210. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30211. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30212. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30213. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30214. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30215. * | 7 | NEAREST_LINEAR | |
  30216. * | 8 | NEAREST_NEAREST | |
  30217. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30218. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30219. * | 11 | LINEAR_LINEAR | |
  30220. * | 12 | LINEAR_NEAREST | |
  30221. *
  30222. * > _mag_: magnification filter (close to the viewer)
  30223. * > _min_: minification filter (far from the viewer)
  30224. * > _mip_: filter used between mip map levels
  30225. *@param samplingMode Define the new sampling mode of the texture
  30226. */
  30227. updateSamplingMode(samplingMode: number): void;
  30228. /**
  30229. * Scales the texture if is `canRescale()`
  30230. * @param ratio the resize factor we want to use to rescale
  30231. */
  30232. scale(ratio: number): void;
  30233. /**
  30234. * Get if the texture can rescale.
  30235. */
  30236. get canRescale(): boolean;
  30237. /** @hidden */
  30238. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30239. /** @hidden */
  30240. _rebuild(): void;
  30241. /**
  30242. * Triggers the load sequence in delayed load mode.
  30243. */
  30244. delayLoad(): void;
  30245. /**
  30246. * Clones the texture.
  30247. * @returns the cloned texture
  30248. */
  30249. clone(): Nullable<BaseTexture>;
  30250. /**
  30251. * Get the texture underlying type (INT, FLOAT...)
  30252. */
  30253. get textureType(): number;
  30254. /**
  30255. * Get the texture underlying format (RGB, RGBA...)
  30256. */
  30257. get textureFormat(): number;
  30258. /**
  30259. * Indicates that textures need to be re-calculated for all materials
  30260. */
  30261. protected _markAllSubMeshesAsTexturesDirty(): void;
  30262. /**
  30263. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30264. * This will returns an RGBA array buffer containing either in values (0-255) or
  30265. * float values (0-1) depending of the underlying buffer type.
  30266. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30267. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30268. * @param buffer defines a user defined buffer to fill with data (can be null)
  30269. * @returns The Array buffer containing the pixels data.
  30270. */
  30271. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30272. /**
  30273. * Release and destroy the underlying lower level texture aka internalTexture.
  30274. */
  30275. releaseInternalTexture(): void;
  30276. /** @hidden */
  30277. get _lodTextureHigh(): Nullable<BaseTexture>;
  30278. /** @hidden */
  30279. get _lodTextureMid(): Nullable<BaseTexture>;
  30280. /** @hidden */
  30281. get _lodTextureLow(): Nullable<BaseTexture>;
  30282. /**
  30283. * Dispose the texture and release its associated resources.
  30284. */
  30285. dispose(): void;
  30286. /**
  30287. * Serialize the texture into a JSON representation that can be parsed later on.
  30288. * @returns the JSON representation of the texture
  30289. */
  30290. serialize(): any;
  30291. /**
  30292. * Helper function to be called back once a list of texture contains only ready textures.
  30293. * @param textures Define the list of textures to wait for
  30294. * @param callback Define the callback triggered once the entire list will be ready
  30295. */
  30296. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30297. }
  30298. }
  30299. declare module BABYLON {
  30300. /**
  30301. * Options to be used when creating an effect.
  30302. */
  30303. export interface IEffectCreationOptions {
  30304. /**
  30305. * Atrributes that will be used in the shader.
  30306. */
  30307. attributes: string[];
  30308. /**
  30309. * Uniform varible names that will be set in the shader.
  30310. */
  30311. uniformsNames: string[];
  30312. /**
  30313. * Uniform buffer variable names that will be set in the shader.
  30314. */
  30315. uniformBuffersNames: string[];
  30316. /**
  30317. * Sampler texture variable names that will be set in the shader.
  30318. */
  30319. samplers: string[];
  30320. /**
  30321. * Define statements that will be set in the shader.
  30322. */
  30323. defines: any;
  30324. /**
  30325. * Possible fallbacks for this effect to improve performance when needed.
  30326. */
  30327. fallbacks: Nullable<IEffectFallbacks>;
  30328. /**
  30329. * Callback that will be called when the shader is compiled.
  30330. */
  30331. onCompiled: Nullable<(effect: Effect) => void>;
  30332. /**
  30333. * Callback that will be called if an error occurs during shader compilation.
  30334. */
  30335. onError: Nullable<(effect: Effect, errors: string) => void>;
  30336. /**
  30337. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30338. */
  30339. indexParameters?: any;
  30340. /**
  30341. * Max number of lights that can be used in the shader.
  30342. */
  30343. maxSimultaneousLights?: number;
  30344. /**
  30345. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30346. */
  30347. transformFeedbackVaryings?: Nullable<string[]>;
  30348. }
  30349. /**
  30350. * Effect containing vertex and fragment shader that can be executed on an object.
  30351. */
  30352. export class Effect implements IDisposable {
  30353. /**
  30354. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30355. */
  30356. static ShadersRepository: string;
  30357. /**
  30358. * Enable logging of the shader code when a compilation error occurs
  30359. */
  30360. static LogShaderCodeOnCompilationError: boolean;
  30361. /**
  30362. * Name of the effect.
  30363. */
  30364. name: any;
  30365. /**
  30366. * String container all the define statements that should be set on the shader.
  30367. */
  30368. defines: string;
  30369. /**
  30370. * Callback that will be called when the shader is compiled.
  30371. */
  30372. onCompiled: Nullable<(effect: Effect) => void>;
  30373. /**
  30374. * Callback that will be called if an error occurs during shader compilation.
  30375. */
  30376. onError: Nullable<(effect: Effect, errors: string) => void>;
  30377. /**
  30378. * Callback that will be called when effect is bound.
  30379. */
  30380. onBind: Nullable<(effect: Effect) => void>;
  30381. /**
  30382. * Unique ID of the effect.
  30383. */
  30384. uniqueId: number;
  30385. /**
  30386. * Observable that will be called when the shader is compiled.
  30387. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30388. */
  30389. onCompileObservable: Observable<Effect>;
  30390. /**
  30391. * Observable that will be called if an error occurs during shader compilation.
  30392. */
  30393. onErrorObservable: Observable<Effect>;
  30394. /** @hidden */
  30395. _onBindObservable: Nullable<Observable<Effect>>;
  30396. /**
  30397. * @hidden
  30398. * Specifies if the effect was previously ready
  30399. */
  30400. _wasPreviouslyReady: boolean;
  30401. /**
  30402. * Observable that will be called when effect is bound.
  30403. */
  30404. get onBindObservable(): Observable<Effect>;
  30405. /** @hidden */
  30406. _bonesComputationForcedToCPU: boolean;
  30407. private static _uniqueIdSeed;
  30408. private _engine;
  30409. private _uniformBuffersNames;
  30410. private _uniformsNames;
  30411. private _samplerList;
  30412. private _samplers;
  30413. private _isReady;
  30414. private _compilationError;
  30415. private _allFallbacksProcessed;
  30416. private _attributesNames;
  30417. private _attributes;
  30418. private _attributeLocationByName;
  30419. private _uniforms;
  30420. /**
  30421. * Key for the effect.
  30422. * @hidden
  30423. */
  30424. _key: string;
  30425. private _indexParameters;
  30426. private _fallbacks;
  30427. private _vertexSourceCode;
  30428. private _fragmentSourceCode;
  30429. private _vertexSourceCodeOverride;
  30430. private _fragmentSourceCodeOverride;
  30431. private _transformFeedbackVaryings;
  30432. /**
  30433. * Compiled shader to webGL program.
  30434. * @hidden
  30435. */
  30436. _pipelineContext: Nullable<IPipelineContext>;
  30437. private _valueCache;
  30438. private static _baseCache;
  30439. /**
  30440. * Instantiates an effect.
  30441. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30442. * @param baseName Name of the effect.
  30443. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30444. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30445. * @param samplers List of sampler variables that will be passed to the shader.
  30446. * @param engine Engine to be used to render the effect
  30447. * @param defines Define statements to be added to the shader.
  30448. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30449. * @param onCompiled Callback that will be called when the shader is compiled.
  30450. * @param onError Callback that will be called if an error occurs during shader compilation.
  30451. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30452. */
  30453. 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);
  30454. private _useFinalCode;
  30455. /**
  30456. * Unique key for this effect
  30457. */
  30458. get key(): string;
  30459. /**
  30460. * If the effect has been compiled and prepared.
  30461. * @returns if the effect is compiled and prepared.
  30462. */
  30463. isReady(): boolean;
  30464. private _isReadyInternal;
  30465. /**
  30466. * The engine the effect was initialized with.
  30467. * @returns the engine.
  30468. */
  30469. getEngine(): Engine;
  30470. /**
  30471. * The pipeline context for this effect
  30472. * @returns the associated pipeline context
  30473. */
  30474. getPipelineContext(): Nullable<IPipelineContext>;
  30475. /**
  30476. * The set of names of attribute variables for the shader.
  30477. * @returns An array of attribute names.
  30478. */
  30479. getAttributesNames(): string[];
  30480. /**
  30481. * Returns the attribute at the given index.
  30482. * @param index The index of the attribute.
  30483. * @returns The location of the attribute.
  30484. */
  30485. getAttributeLocation(index: number): number;
  30486. /**
  30487. * Returns the attribute based on the name of the variable.
  30488. * @param name of the attribute to look up.
  30489. * @returns the attribute location.
  30490. */
  30491. getAttributeLocationByName(name: string): number;
  30492. /**
  30493. * The number of attributes.
  30494. * @returns the numnber of attributes.
  30495. */
  30496. getAttributesCount(): number;
  30497. /**
  30498. * Gets the index of a uniform variable.
  30499. * @param uniformName of the uniform to look up.
  30500. * @returns the index.
  30501. */
  30502. getUniformIndex(uniformName: string): number;
  30503. /**
  30504. * Returns the attribute based on the name of the variable.
  30505. * @param uniformName of the uniform to look up.
  30506. * @returns the location of the uniform.
  30507. */
  30508. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30509. /**
  30510. * Returns an array of sampler variable names
  30511. * @returns The array of sampler variable neames.
  30512. */
  30513. getSamplers(): string[];
  30514. /**
  30515. * The error from the last compilation.
  30516. * @returns the error string.
  30517. */
  30518. getCompilationError(): string;
  30519. /**
  30520. * Gets a boolean indicating that all fallbacks were used during compilation
  30521. * @returns true if all fallbacks were used
  30522. */
  30523. allFallbacksProcessed(): boolean;
  30524. /**
  30525. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30526. * @param func The callback to be used.
  30527. */
  30528. executeWhenCompiled(func: (effect: Effect) => void): void;
  30529. private _checkIsReady;
  30530. private _loadShader;
  30531. /**
  30532. * Recompiles the webGL program
  30533. * @param vertexSourceCode The source code for the vertex shader.
  30534. * @param fragmentSourceCode The source code for the fragment shader.
  30535. * @param onCompiled Callback called when completed.
  30536. * @param onError Callback called on error.
  30537. * @hidden
  30538. */
  30539. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30540. /**
  30541. * Prepares the effect
  30542. * @hidden
  30543. */
  30544. _prepareEffect(): void;
  30545. private _getShaderCodeAndErrorLine;
  30546. private _processCompilationErrors;
  30547. /**
  30548. * Checks if the effect is supported. (Must be called after compilation)
  30549. */
  30550. get isSupported(): boolean;
  30551. /**
  30552. * Binds a texture to the engine to be used as output of the shader.
  30553. * @param channel Name of the output variable.
  30554. * @param texture Texture to bind.
  30555. * @hidden
  30556. */
  30557. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30558. /**
  30559. * Sets a texture on the engine to be used in the shader.
  30560. * @param channel Name of the sampler variable.
  30561. * @param texture Texture to set.
  30562. */
  30563. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30564. /**
  30565. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30566. * @param channel Name of the sampler variable.
  30567. * @param texture Texture to set.
  30568. */
  30569. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30570. /**
  30571. * Sets an array of textures on the engine to be used in the shader.
  30572. * @param channel Name of the variable.
  30573. * @param textures Textures to set.
  30574. */
  30575. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30576. /**
  30577. * 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)
  30578. * @param channel Name of the sampler variable.
  30579. * @param postProcess Post process to get the input texture from.
  30580. */
  30581. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30582. /**
  30583. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30584. * 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)
  30585. * @param channel Name of the sampler variable.
  30586. * @param postProcess Post process to get the output texture from.
  30587. */
  30588. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30589. /** @hidden */
  30590. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30591. /** @hidden */
  30592. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30593. /** @hidden */
  30594. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30595. /** @hidden */
  30596. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30597. /**
  30598. * Binds a buffer to a uniform.
  30599. * @param buffer Buffer to bind.
  30600. * @param name Name of the uniform variable to bind to.
  30601. */
  30602. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30603. /**
  30604. * Binds block to a uniform.
  30605. * @param blockName Name of the block to bind.
  30606. * @param index Index to bind.
  30607. */
  30608. bindUniformBlock(blockName: string, index: number): void;
  30609. /**
  30610. * Sets an interger value on a uniform variable.
  30611. * @param uniformName Name of the variable.
  30612. * @param value Value to be set.
  30613. * @returns this effect.
  30614. */
  30615. setInt(uniformName: string, value: number): Effect;
  30616. /**
  30617. * Sets an int array on a uniform variable.
  30618. * @param uniformName Name of the variable.
  30619. * @param array array to be set.
  30620. * @returns this effect.
  30621. */
  30622. setIntArray(uniformName: string, array: Int32Array): Effect;
  30623. /**
  30624. * 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)
  30625. * @param uniformName Name of the variable.
  30626. * @param array array to be set.
  30627. * @returns this effect.
  30628. */
  30629. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30630. /**
  30631. * 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)
  30632. * @param uniformName Name of the variable.
  30633. * @param array array to be set.
  30634. * @returns this effect.
  30635. */
  30636. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30637. /**
  30638. * 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)
  30639. * @param uniformName Name of the variable.
  30640. * @param array array to be set.
  30641. * @returns this effect.
  30642. */
  30643. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30644. /**
  30645. * Sets an float array on a uniform variable.
  30646. * @param uniformName Name of the variable.
  30647. * @param array array to be set.
  30648. * @returns this effect.
  30649. */
  30650. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30651. /**
  30652. * 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)
  30653. * @param uniformName Name of the variable.
  30654. * @param array array to be set.
  30655. * @returns this effect.
  30656. */
  30657. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30658. /**
  30659. * 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)
  30660. * @param uniformName Name of the variable.
  30661. * @param array array to be set.
  30662. * @returns this effect.
  30663. */
  30664. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30665. /**
  30666. * 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)
  30667. * @param uniformName Name of the variable.
  30668. * @param array array to be set.
  30669. * @returns this effect.
  30670. */
  30671. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30672. /**
  30673. * Sets an array on a uniform variable.
  30674. * @param uniformName Name of the variable.
  30675. * @param array array to be set.
  30676. * @returns this effect.
  30677. */
  30678. setArray(uniformName: string, array: number[]): Effect;
  30679. /**
  30680. * 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)
  30681. * @param uniformName Name of the variable.
  30682. * @param array array to be set.
  30683. * @returns this effect.
  30684. */
  30685. setArray2(uniformName: string, array: number[]): Effect;
  30686. /**
  30687. * 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)
  30688. * @param uniformName Name of the variable.
  30689. * @param array array to be set.
  30690. * @returns this effect.
  30691. */
  30692. setArray3(uniformName: string, array: number[]): Effect;
  30693. /**
  30694. * 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)
  30695. * @param uniformName Name of the variable.
  30696. * @param array array to be set.
  30697. * @returns this effect.
  30698. */
  30699. setArray4(uniformName: string, array: number[]): Effect;
  30700. /**
  30701. * Sets matrices on a uniform variable.
  30702. * @param uniformName Name of the variable.
  30703. * @param matrices matrices to be set.
  30704. * @returns this effect.
  30705. */
  30706. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30707. /**
  30708. * Sets matrix on a uniform variable.
  30709. * @param uniformName Name of the variable.
  30710. * @param matrix matrix to be set.
  30711. * @returns this effect.
  30712. */
  30713. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30714. /**
  30715. * 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)
  30716. * @param uniformName Name of the variable.
  30717. * @param matrix matrix to be set.
  30718. * @returns this effect.
  30719. */
  30720. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30721. /**
  30722. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30723. * @param uniformName Name of the variable.
  30724. * @param matrix matrix to be set.
  30725. * @returns this effect.
  30726. */
  30727. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30728. /**
  30729. * Sets a float on a uniform variable.
  30730. * @param uniformName Name of the variable.
  30731. * @param value value to be set.
  30732. * @returns this effect.
  30733. */
  30734. setFloat(uniformName: string, value: number): Effect;
  30735. /**
  30736. * Sets a boolean on a uniform variable.
  30737. * @param uniformName Name of the variable.
  30738. * @param bool value to be set.
  30739. * @returns this effect.
  30740. */
  30741. setBool(uniformName: string, bool: boolean): Effect;
  30742. /**
  30743. * Sets a Vector2 on a uniform variable.
  30744. * @param uniformName Name of the variable.
  30745. * @param vector2 vector2 to be set.
  30746. * @returns this effect.
  30747. */
  30748. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30749. /**
  30750. * Sets a float2 on a uniform variable.
  30751. * @param uniformName Name of the variable.
  30752. * @param x First float in float2.
  30753. * @param y Second float in float2.
  30754. * @returns this effect.
  30755. */
  30756. setFloat2(uniformName: string, x: number, y: number): Effect;
  30757. /**
  30758. * Sets a Vector3 on a uniform variable.
  30759. * @param uniformName Name of the variable.
  30760. * @param vector3 Value to be set.
  30761. * @returns this effect.
  30762. */
  30763. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30764. /**
  30765. * Sets a float3 on a uniform variable.
  30766. * @param uniformName Name of the variable.
  30767. * @param x First float in float3.
  30768. * @param y Second float in float3.
  30769. * @param z Third float in float3.
  30770. * @returns this effect.
  30771. */
  30772. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30773. /**
  30774. * Sets a Vector4 on a uniform variable.
  30775. * @param uniformName Name of the variable.
  30776. * @param vector4 Value to be set.
  30777. * @returns this effect.
  30778. */
  30779. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30780. /**
  30781. * Sets a float4 on a uniform variable.
  30782. * @param uniformName Name of the variable.
  30783. * @param x First float in float4.
  30784. * @param y Second float in float4.
  30785. * @param z Third float in float4.
  30786. * @param w Fourth float in float4.
  30787. * @returns this effect.
  30788. */
  30789. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30790. /**
  30791. * Sets a Color3 on a uniform variable.
  30792. * @param uniformName Name of the variable.
  30793. * @param color3 Value to be set.
  30794. * @returns this effect.
  30795. */
  30796. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30797. /**
  30798. * Sets a Color4 on a uniform variable.
  30799. * @param uniformName Name of the variable.
  30800. * @param color3 Value to be set.
  30801. * @param alpha Alpha value to be set.
  30802. * @returns this effect.
  30803. */
  30804. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30805. /**
  30806. * Sets a Color4 on a uniform variable
  30807. * @param uniformName defines the name of the variable
  30808. * @param color4 defines the value to be set
  30809. * @returns this effect.
  30810. */
  30811. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30812. /** Release all associated resources */
  30813. dispose(): void;
  30814. /**
  30815. * This function will add a new shader to the shader store
  30816. * @param name the name of the shader
  30817. * @param pixelShader optional pixel shader content
  30818. * @param vertexShader optional vertex shader content
  30819. */
  30820. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30821. /**
  30822. * Store of each shader (The can be looked up using effect.key)
  30823. */
  30824. static ShadersStore: {
  30825. [key: string]: string;
  30826. };
  30827. /**
  30828. * Store of each included file for a shader (The can be looked up using effect.key)
  30829. */
  30830. static IncludesShadersStore: {
  30831. [key: string]: string;
  30832. };
  30833. /**
  30834. * Resets the cache of effects.
  30835. */
  30836. static ResetCache(): void;
  30837. }
  30838. }
  30839. declare module BABYLON {
  30840. /**
  30841. * Interface used to describe the capabilities of the engine relatively to the current browser
  30842. */
  30843. export interface EngineCapabilities {
  30844. /** Maximum textures units per fragment shader */
  30845. maxTexturesImageUnits: number;
  30846. /** Maximum texture units per vertex shader */
  30847. maxVertexTextureImageUnits: number;
  30848. /** Maximum textures units in the entire pipeline */
  30849. maxCombinedTexturesImageUnits: number;
  30850. /** Maximum texture size */
  30851. maxTextureSize: number;
  30852. /** Maximum texture samples */
  30853. maxSamples?: number;
  30854. /** Maximum cube texture size */
  30855. maxCubemapTextureSize: number;
  30856. /** Maximum render texture size */
  30857. maxRenderTextureSize: number;
  30858. /** Maximum number of vertex attributes */
  30859. maxVertexAttribs: number;
  30860. /** Maximum number of varyings */
  30861. maxVaryingVectors: number;
  30862. /** Maximum number of uniforms per vertex shader */
  30863. maxVertexUniformVectors: number;
  30864. /** Maximum number of uniforms per fragment shader */
  30865. maxFragmentUniformVectors: number;
  30866. /** Defines if standard derivates (dx/dy) are supported */
  30867. standardDerivatives: boolean;
  30868. /** Defines if s3tc texture compression is supported */
  30869. s3tc?: WEBGL_compressed_texture_s3tc;
  30870. /** Defines if pvrtc texture compression is supported */
  30871. pvrtc: any;
  30872. /** Defines if etc1 texture compression is supported */
  30873. etc1: any;
  30874. /** Defines if etc2 texture compression is supported */
  30875. etc2: any;
  30876. /** Defines if astc texture compression is supported */
  30877. astc: any;
  30878. /** Defines if float textures are supported */
  30879. textureFloat: boolean;
  30880. /** Defines if vertex array objects are supported */
  30881. vertexArrayObject: boolean;
  30882. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30883. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30884. /** Gets the maximum level of anisotropy supported */
  30885. maxAnisotropy: number;
  30886. /** Defines if instancing is supported */
  30887. instancedArrays: boolean;
  30888. /** Defines if 32 bits indices are supported */
  30889. uintIndices: boolean;
  30890. /** Defines if high precision shaders are supported */
  30891. highPrecisionShaderSupported: boolean;
  30892. /** Defines if depth reading in the fragment shader is supported */
  30893. fragmentDepthSupported: boolean;
  30894. /** Defines if float texture linear filtering is supported*/
  30895. textureFloatLinearFiltering: boolean;
  30896. /** Defines if rendering to float textures is supported */
  30897. textureFloatRender: boolean;
  30898. /** Defines if half float textures are supported*/
  30899. textureHalfFloat: boolean;
  30900. /** Defines if half float texture linear filtering is supported*/
  30901. textureHalfFloatLinearFiltering: boolean;
  30902. /** Defines if rendering to half float textures is supported */
  30903. textureHalfFloatRender: boolean;
  30904. /** Defines if textureLOD shader command is supported */
  30905. textureLOD: boolean;
  30906. /** Defines if draw buffers extension is supported */
  30907. drawBuffersExtension: boolean;
  30908. /** Defines if depth textures are supported */
  30909. depthTextureExtension: boolean;
  30910. /** Defines if float color buffer are supported */
  30911. colorBufferFloat: boolean;
  30912. /** Gets disjoint timer query extension (null if not supported) */
  30913. timerQuery?: EXT_disjoint_timer_query;
  30914. /** Defines if timestamp can be used with timer query */
  30915. canUseTimestampForTimerQuery: boolean;
  30916. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30917. multiview?: any;
  30918. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30919. oculusMultiview?: any;
  30920. /** Function used to let the system compiles shaders in background */
  30921. parallelShaderCompile?: {
  30922. COMPLETION_STATUS_KHR: number;
  30923. };
  30924. /** Max number of texture samples for MSAA */
  30925. maxMSAASamples: number;
  30926. /** Defines if the blend min max extension is supported */
  30927. blendMinMax: boolean;
  30928. }
  30929. }
  30930. declare module BABYLON {
  30931. /**
  30932. * @hidden
  30933. **/
  30934. export class DepthCullingState {
  30935. private _isDepthTestDirty;
  30936. private _isDepthMaskDirty;
  30937. private _isDepthFuncDirty;
  30938. private _isCullFaceDirty;
  30939. private _isCullDirty;
  30940. private _isZOffsetDirty;
  30941. private _isFrontFaceDirty;
  30942. private _depthTest;
  30943. private _depthMask;
  30944. private _depthFunc;
  30945. private _cull;
  30946. private _cullFace;
  30947. private _zOffset;
  30948. private _frontFace;
  30949. /**
  30950. * Initializes the state.
  30951. */
  30952. constructor();
  30953. get isDirty(): boolean;
  30954. get zOffset(): number;
  30955. set zOffset(value: number);
  30956. get cullFace(): Nullable<number>;
  30957. set cullFace(value: Nullable<number>);
  30958. get cull(): Nullable<boolean>;
  30959. set cull(value: Nullable<boolean>);
  30960. get depthFunc(): Nullable<number>;
  30961. set depthFunc(value: Nullable<number>);
  30962. get depthMask(): boolean;
  30963. set depthMask(value: boolean);
  30964. get depthTest(): boolean;
  30965. set depthTest(value: boolean);
  30966. get frontFace(): Nullable<number>;
  30967. set frontFace(value: Nullable<number>);
  30968. reset(): void;
  30969. apply(gl: WebGLRenderingContext): void;
  30970. }
  30971. }
  30972. declare module BABYLON {
  30973. /**
  30974. * @hidden
  30975. **/
  30976. export class StencilState {
  30977. /** 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 */
  30978. static readonly ALWAYS: number;
  30979. /** Passed to stencilOperation to specify that stencil value must be kept */
  30980. static readonly KEEP: number;
  30981. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30982. static readonly REPLACE: number;
  30983. private _isStencilTestDirty;
  30984. private _isStencilMaskDirty;
  30985. private _isStencilFuncDirty;
  30986. private _isStencilOpDirty;
  30987. private _stencilTest;
  30988. private _stencilMask;
  30989. private _stencilFunc;
  30990. private _stencilFuncRef;
  30991. private _stencilFuncMask;
  30992. private _stencilOpStencilFail;
  30993. private _stencilOpDepthFail;
  30994. private _stencilOpStencilDepthPass;
  30995. get isDirty(): boolean;
  30996. get stencilFunc(): number;
  30997. set stencilFunc(value: number);
  30998. get stencilFuncRef(): number;
  30999. set stencilFuncRef(value: number);
  31000. get stencilFuncMask(): number;
  31001. set stencilFuncMask(value: number);
  31002. get stencilOpStencilFail(): number;
  31003. set stencilOpStencilFail(value: number);
  31004. get stencilOpDepthFail(): number;
  31005. set stencilOpDepthFail(value: number);
  31006. get stencilOpStencilDepthPass(): number;
  31007. set stencilOpStencilDepthPass(value: number);
  31008. get stencilMask(): number;
  31009. set stencilMask(value: number);
  31010. get stencilTest(): boolean;
  31011. set stencilTest(value: boolean);
  31012. constructor();
  31013. reset(): void;
  31014. apply(gl: WebGLRenderingContext): void;
  31015. }
  31016. }
  31017. declare module BABYLON {
  31018. /**
  31019. * @hidden
  31020. **/
  31021. export class AlphaState {
  31022. private _isAlphaBlendDirty;
  31023. private _isBlendFunctionParametersDirty;
  31024. private _isBlendEquationParametersDirty;
  31025. private _isBlendConstantsDirty;
  31026. private _alphaBlend;
  31027. private _blendFunctionParameters;
  31028. private _blendEquationParameters;
  31029. private _blendConstants;
  31030. /**
  31031. * Initializes the state.
  31032. */
  31033. constructor();
  31034. get isDirty(): boolean;
  31035. get alphaBlend(): boolean;
  31036. set alphaBlend(value: boolean);
  31037. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31038. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31039. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31040. reset(): void;
  31041. apply(gl: WebGLRenderingContext): void;
  31042. }
  31043. }
  31044. declare module BABYLON {
  31045. /** @hidden */
  31046. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31047. attributeProcessor(attribute: string): string;
  31048. varyingProcessor(varying: string, isFragment: boolean): string;
  31049. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31050. }
  31051. }
  31052. declare module BABYLON {
  31053. /**
  31054. * Interface for attribute information associated with buffer instanciation
  31055. */
  31056. export interface InstancingAttributeInfo {
  31057. /**
  31058. * Name of the GLSL attribute
  31059. * if attribute index is not specified, this is used to retrieve the index from the effect
  31060. */
  31061. attributeName: string;
  31062. /**
  31063. * Index/offset of the attribute in the vertex shader
  31064. * if not specified, this will be computes from the name.
  31065. */
  31066. index?: number;
  31067. /**
  31068. * size of the attribute, 1, 2, 3 or 4
  31069. */
  31070. attributeSize: number;
  31071. /**
  31072. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31073. */
  31074. offset: number;
  31075. /**
  31076. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31077. * default to 1
  31078. */
  31079. divisor?: number;
  31080. /**
  31081. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31082. * default is FLOAT
  31083. */
  31084. attributeType?: number;
  31085. /**
  31086. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31087. */
  31088. normalized?: boolean;
  31089. }
  31090. }
  31091. declare module BABYLON {
  31092. interface ThinEngine {
  31093. /**
  31094. * Update a video texture
  31095. * @param texture defines the texture to update
  31096. * @param video defines the video element to use
  31097. * @param invertY defines if data must be stored with Y axis inverted
  31098. */
  31099. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31100. }
  31101. }
  31102. declare module BABYLON {
  31103. /**
  31104. * Settings for finer control over video usage
  31105. */
  31106. export interface VideoTextureSettings {
  31107. /**
  31108. * Applies `autoplay` to video, if specified
  31109. */
  31110. autoPlay?: boolean;
  31111. /**
  31112. * Applies `loop` to video, if specified
  31113. */
  31114. loop?: boolean;
  31115. /**
  31116. * Automatically updates internal texture from video at every frame in the render loop
  31117. */
  31118. autoUpdateTexture: boolean;
  31119. /**
  31120. * Image src displayed during the video loading or until the user interacts with the video.
  31121. */
  31122. poster?: string;
  31123. }
  31124. /**
  31125. * If you want to display a video in your scene, this is the special texture for that.
  31126. * This special texture works similar to other textures, with the exception of a few parameters.
  31127. * @see https://doc.babylonjs.com/how_to/video_texture
  31128. */
  31129. export class VideoTexture extends Texture {
  31130. /**
  31131. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31132. */
  31133. readonly autoUpdateTexture: boolean;
  31134. /**
  31135. * The video instance used by the texture internally
  31136. */
  31137. readonly video: HTMLVideoElement;
  31138. private _onUserActionRequestedObservable;
  31139. /**
  31140. * Event triggerd when a dom action is required by the user to play the video.
  31141. * This happens due to recent changes in browser policies preventing video to auto start.
  31142. */
  31143. get onUserActionRequestedObservable(): Observable<Texture>;
  31144. private _generateMipMaps;
  31145. private _engine;
  31146. private _stillImageCaptured;
  31147. private _displayingPosterTexture;
  31148. private _settings;
  31149. private _createInternalTextureOnEvent;
  31150. private _frameId;
  31151. private _currentSrc;
  31152. /**
  31153. * Creates a video texture.
  31154. * If you want to display a video in your scene, this is the special texture for that.
  31155. * This special texture works similar to other textures, with the exception of a few parameters.
  31156. * @see https://doc.babylonjs.com/how_to/video_texture
  31157. * @param name optional name, will detect from video source, if not defined
  31158. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31159. * @param scene is obviously the current scene.
  31160. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31161. * @param invertY is false by default but can be used to invert video on Y axis
  31162. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31163. * @param settings allows finer control over video usage
  31164. */
  31165. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31166. private _getName;
  31167. private _getVideo;
  31168. private _createInternalTexture;
  31169. private reset;
  31170. /**
  31171. * @hidden Internal method to initiate `update`.
  31172. */
  31173. _rebuild(): void;
  31174. /**
  31175. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31176. */
  31177. update(): void;
  31178. /**
  31179. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31180. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31181. */
  31182. updateTexture(isVisible: boolean): void;
  31183. protected _updateInternalTexture: () => void;
  31184. /**
  31185. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31186. * @param url New url.
  31187. */
  31188. updateURL(url: string): void;
  31189. /**
  31190. * Clones the texture.
  31191. * @returns the cloned texture
  31192. */
  31193. clone(): VideoTexture;
  31194. /**
  31195. * Dispose the texture and release its associated resources.
  31196. */
  31197. dispose(): void;
  31198. /**
  31199. * Creates a video texture straight from a stream.
  31200. * @param scene Define the scene the texture should be created in
  31201. * @param stream Define the stream the texture should be created from
  31202. * @returns The created video texture as a promise
  31203. */
  31204. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31205. /**
  31206. * Creates a video texture straight from your WebCam video feed.
  31207. * @param scene Define the scene the texture should be created in
  31208. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31209. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31210. * @returns The created video texture as a promise
  31211. */
  31212. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31213. minWidth: number;
  31214. maxWidth: number;
  31215. minHeight: number;
  31216. maxHeight: number;
  31217. deviceId: string;
  31218. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31219. /**
  31220. * Creates a video texture straight from your WebCam video feed.
  31221. * @param scene Define the scene the texture should be created in
  31222. * @param onReady Define a callback to triggered once the texture will be ready
  31223. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31224. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31225. */
  31226. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31227. minWidth: number;
  31228. maxWidth: number;
  31229. minHeight: number;
  31230. maxHeight: number;
  31231. deviceId: string;
  31232. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31233. }
  31234. }
  31235. declare module BABYLON {
  31236. /**
  31237. * Defines the interface used by objects working like Scene
  31238. * @hidden
  31239. */
  31240. export interface ISceneLike {
  31241. _addPendingData(data: any): void;
  31242. _removePendingData(data: any): void;
  31243. offlineProvider: IOfflineProvider;
  31244. }
  31245. /** Interface defining initialization parameters for Engine class */
  31246. export interface EngineOptions extends WebGLContextAttributes {
  31247. /**
  31248. * Defines if the engine should no exceed a specified device ratio
  31249. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31250. */
  31251. limitDeviceRatio?: number;
  31252. /**
  31253. * Defines if webvr should be enabled automatically
  31254. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31255. */
  31256. autoEnableWebVR?: boolean;
  31257. /**
  31258. * Defines if webgl2 should be turned off even if supported
  31259. * @see http://doc.babylonjs.com/features/webgl2
  31260. */
  31261. disableWebGL2Support?: boolean;
  31262. /**
  31263. * Defines if webaudio should be initialized as well
  31264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31265. */
  31266. audioEngine?: boolean;
  31267. /**
  31268. * Defines if animations should run using a deterministic lock step
  31269. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31270. */
  31271. deterministicLockstep?: boolean;
  31272. /** Defines the maximum steps to use with deterministic lock step mode */
  31273. lockstepMaxSteps?: number;
  31274. /** Defines the seconds between each deterministic lock step */
  31275. timeStep?: number;
  31276. /**
  31277. * Defines that engine should ignore context lost events
  31278. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31279. */
  31280. doNotHandleContextLost?: boolean;
  31281. /**
  31282. * Defines that engine should ignore modifying touch action attribute and style
  31283. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31284. */
  31285. doNotHandleTouchAction?: boolean;
  31286. /**
  31287. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31288. */
  31289. useHighPrecisionFloats?: boolean;
  31290. }
  31291. /**
  31292. * The base engine class (root of all engines)
  31293. */
  31294. export class ThinEngine {
  31295. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31296. static ExceptionList: ({
  31297. key: string;
  31298. capture: string;
  31299. captureConstraint: number;
  31300. targets: string[];
  31301. } | {
  31302. key: string;
  31303. capture: null;
  31304. captureConstraint: null;
  31305. targets: string[];
  31306. })[];
  31307. /** @hidden */
  31308. static _TextureLoaders: IInternalTextureLoader[];
  31309. /**
  31310. * Returns the current npm package of the sdk
  31311. */
  31312. static get NpmPackage(): string;
  31313. /**
  31314. * Returns the current version of the framework
  31315. */
  31316. static get Version(): string;
  31317. /**
  31318. * Returns a string describing the current engine
  31319. */
  31320. get description(): string;
  31321. /**
  31322. * Gets or sets the epsilon value used by collision engine
  31323. */
  31324. static CollisionsEpsilon: number;
  31325. /**
  31326. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31327. */
  31328. static get ShadersRepository(): string;
  31329. static set ShadersRepository(value: string);
  31330. /** @hidden */
  31331. _shaderProcessor: IShaderProcessor;
  31332. /**
  31333. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31334. */
  31335. forcePOTTextures: boolean;
  31336. /**
  31337. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31338. */
  31339. isFullscreen: boolean;
  31340. /**
  31341. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31342. */
  31343. cullBackFaces: boolean;
  31344. /**
  31345. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31346. */
  31347. renderEvenInBackground: boolean;
  31348. /**
  31349. * Gets or sets a boolean indicating that cache can be kept between frames
  31350. */
  31351. preventCacheWipeBetweenFrames: boolean;
  31352. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31353. validateShaderPrograms: boolean;
  31354. /**
  31355. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31356. * This can provide greater z depth for distant objects.
  31357. */
  31358. useReverseDepthBuffer: boolean;
  31359. /**
  31360. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31361. */
  31362. disableUniformBuffers: boolean;
  31363. /** @hidden */
  31364. _uniformBuffers: UniformBuffer[];
  31365. /**
  31366. * Gets a boolean indicating that the engine supports uniform buffers
  31367. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31368. */
  31369. get supportsUniformBuffers(): boolean;
  31370. /** @hidden */
  31371. _gl: WebGLRenderingContext;
  31372. /** @hidden */
  31373. _webGLVersion: number;
  31374. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31375. protected _windowIsBackground: boolean;
  31376. protected _creationOptions: EngineOptions;
  31377. protected _highPrecisionShadersAllowed: boolean;
  31378. /** @hidden */
  31379. get _shouldUseHighPrecisionShader(): boolean;
  31380. /**
  31381. * Gets a boolean indicating that only power of 2 textures are supported
  31382. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31383. */
  31384. get needPOTTextures(): boolean;
  31385. /** @hidden */
  31386. _badOS: boolean;
  31387. /** @hidden */
  31388. _badDesktopOS: boolean;
  31389. private _hardwareScalingLevel;
  31390. /** @hidden */
  31391. _caps: EngineCapabilities;
  31392. private _isStencilEnable;
  31393. private _glVersion;
  31394. private _glRenderer;
  31395. private _glVendor;
  31396. /** @hidden */
  31397. _videoTextureSupported: boolean;
  31398. protected _renderingQueueLaunched: boolean;
  31399. protected _activeRenderLoops: (() => void)[];
  31400. /**
  31401. * Observable signaled when a context lost event is raised
  31402. */
  31403. onContextLostObservable: Observable<ThinEngine>;
  31404. /**
  31405. * Observable signaled when a context restored event is raised
  31406. */
  31407. onContextRestoredObservable: Observable<ThinEngine>;
  31408. private _onContextLost;
  31409. private _onContextRestored;
  31410. protected _contextWasLost: boolean;
  31411. /** @hidden */
  31412. _doNotHandleContextLost: boolean;
  31413. /**
  31414. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31415. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31416. */
  31417. get doNotHandleContextLost(): boolean;
  31418. set doNotHandleContextLost(value: boolean);
  31419. /**
  31420. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31421. */
  31422. disableVertexArrayObjects: boolean;
  31423. /** @hidden */
  31424. protected _colorWrite: boolean;
  31425. /** @hidden */
  31426. protected _colorWriteChanged: boolean;
  31427. /** @hidden */
  31428. protected _depthCullingState: DepthCullingState;
  31429. /** @hidden */
  31430. protected _stencilState: StencilState;
  31431. /** @hidden */
  31432. _alphaState: AlphaState;
  31433. /** @hidden */
  31434. _alphaMode: number;
  31435. /** @hidden */
  31436. _alphaEquation: number;
  31437. /** @hidden */
  31438. _internalTexturesCache: InternalTexture[];
  31439. /** @hidden */
  31440. protected _activeChannel: number;
  31441. private _currentTextureChannel;
  31442. /** @hidden */
  31443. protected _boundTexturesCache: {
  31444. [key: string]: Nullable<InternalTexture>;
  31445. };
  31446. /** @hidden */
  31447. protected _currentEffect: Nullable<Effect>;
  31448. /** @hidden */
  31449. protected _currentProgram: Nullable<WebGLProgram>;
  31450. private _compiledEffects;
  31451. private _vertexAttribArraysEnabled;
  31452. /** @hidden */
  31453. protected _cachedViewport: Nullable<IViewportLike>;
  31454. private _cachedVertexArrayObject;
  31455. /** @hidden */
  31456. protected _cachedVertexBuffers: any;
  31457. /** @hidden */
  31458. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31459. /** @hidden */
  31460. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31461. /** @hidden */
  31462. _currentRenderTarget: Nullable<InternalTexture>;
  31463. private _uintIndicesCurrentlySet;
  31464. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31465. /** @hidden */
  31466. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31467. private _currentBufferPointers;
  31468. private _currentInstanceLocations;
  31469. private _currentInstanceBuffers;
  31470. private _textureUnits;
  31471. /** @hidden */
  31472. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31473. /** @hidden */
  31474. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31475. /** @hidden */
  31476. _boundRenderFunction: any;
  31477. private _vaoRecordInProgress;
  31478. private _mustWipeVertexAttributes;
  31479. private _emptyTexture;
  31480. private _emptyCubeTexture;
  31481. private _emptyTexture3D;
  31482. private _emptyTexture2DArray;
  31483. /** @hidden */
  31484. _frameHandler: number;
  31485. private _nextFreeTextureSlots;
  31486. private _maxSimultaneousTextures;
  31487. private _activeRequests;
  31488. /** @hidden */
  31489. _transformTextureUrl: Nullable<(url: string) => string>;
  31490. protected get _supportsHardwareTextureRescaling(): boolean;
  31491. private _framebufferDimensionsObject;
  31492. /**
  31493. * sets the object from which width and height will be taken from when getting render width and height
  31494. * Will fallback to the gl object
  31495. * @param dimensions the framebuffer width and height that will be used.
  31496. */
  31497. set framebufferDimensionsObject(dimensions: Nullable<{
  31498. framebufferWidth: number;
  31499. framebufferHeight: number;
  31500. }>);
  31501. /**
  31502. * Gets the current viewport
  31503. */
  31504. get currentViewport(): Nullable<IViewportLike>;
  31505. /**
  31506. * Gets the default empty texture
  31507. */
  31508. get emptyTexture(): InternalTexture;
  31509. /**
  31510. * Gets the default empty 3D texture
  31511. */
  31512. get emptyTexture3D(): InternalTexture;
  31513. /**
  31514. * Gets the default empty 2D array texture
  31515. */
  31516. get emptyTexture2DArray(): InternalTexture;
  31517. /**
  31518. * Gets the default empty cube texture
  31519. */
  31520. get emptyCubeTexture(): InternalTexture;
  31521. /**
  31522. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31523. */
  31524. readonly premultipliedAlpha: boolean;
  31525. /**
  31526. * Observable event triggered before each texture is initialized
  31527. */
  31528. onBeforeTextureInitObservable: Observable<Texture>;
  31529. /**
  31530. * Creates a new engine
  31531. * @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
  31532. * @param antialias defines enable antialiasing (default: false)
  31533. * @param options defines further options to be sent to the getContext() function
  31534. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31535. */
  31536. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31537. private _rebuildInternalTextures;
  31538. private _rebuildEffects;
  31539. /**
  31540. * Gets a boolean indicating if all created effects are ready
  31541. * @returns true if all effects are ready
  31542. */
  31543. areAllEffectsReady(): boolean;
  31544. protected _rebuildBuffers(): void;
  31545. protected _initGLContext(): void;
  31546. /**
  31547. * Gets version of the current webGL context
  31548. */
  31549. get webGLVersion(): number;
  31550. /**
  31551. * Gets a string idenfifying the name of the class
  31552. * @returns "Engine" string
  31553. */
  31554. getClassName(): string;
  31555. /**
  31556. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31557. */
  31558. get isStencilEnable(): boolean;
  31559. /** @hidden */
  31560. _prepareWorkingCanvas(): void;
  31561. /**
  31562. * Reset the texture cache to empty state
  31563. */
  31564. resetTextureCache(): void;
  31565. /**
  31566. * Gets an object containing information about the current webGL context
  31567. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31568. */
  31569. getGlInfo(): {
  31570. vendor: string;
  31571. renderer: string;
  31572. version: string;
  31573. };
  31574. /**
  31575. * Defines the hardware scaling level.
  31576. * By default the hardware scaling level is computed from the window device ratio.
  31577. * 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.
  31578. * @param level defines the level to use
  31579. */
  31580. setHardwareScalingLevel(level: number): void;
  31581. /**
  31582. * Gets the current hardware scaling level.
  31583. * By default the hardware scaling level is computed from the window device ratio.
  31584. * 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.
  31585. * @returns a number indicating the current hardware scaling level
  31586. */
  31587. getHardwareScalingLevel(): number;
  31588. /**
  31589. * Gets the list of loaded textures
  31590. * @returns an array containing all loaded textures
  31591. */
  31592. getLoadedTexturesCache(): InternalTexture[];
  31593. /**
  31594. * Gets the object containing all engine capabilities
  31595. * @returns the EngineCapabilities object
  31596. */
  31597. getCaps(): EngineCapabilities;
  31598. /**
  31599. * stop executing a render loop function and remove it from the execution array
  31600. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31601. */
  31602. stopRenderLoop(renderFunction?: () => void): void;
  31603. /** @hidden */
  31604. _renderLoop(): void;
  31605. /**
  31606. * Gets the HTML canvas attached with the current webGL context
  31607. * @returns a HTML canvas
  31608. */
  31609. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31610. /**
  31611. * Gets host window
  31612. * @returns the host window object
  31613. */
  31614. getHostWindow(): Nullable<Window>;
  31615. /**
  31616. * Gets the current render width
  31617. * @param useScreen defines if screen size must be used (or the current render target if any)
  31618. * @returns a number defining the current render width
  31619. */
  31620. getRenderWidth(useScreen?: boolean): number;
  31621. /**
  31622. * Gets the current render height
  31623. * @param useScreen defines if screen size must be used (or the current render target if any)
  31624. * @returns a number defining the current render height
  31625. */
  31626. getRenderHeight(useScreen?: boolean): number;
  31627. /**
  31628. * Can be used to override the current requestAnimationFrame requester.
  31629. * @hidden
  31630. */
  31631. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31632. /**
  31633. * Register and execute a render loop. The engine can have more than one render function
  31634. * @param renderFunction defines the function to continuously execute
  31635. */
  31636. runRenderLoop(renderFunction: () => void): void;
  31637. /**
  31638. * Clear the current render buffer or the current render target (if any is set up)
  31639. * @param color defines the color to use
  31640. * @param backBuffer defines if the back buffer must be cleared
  31641. * @param depth defines if the depth buffer must be cleared
  31642. * @param stencil defines if the stencil buffer must be cleared
  31643. */
  31644. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31645. private _viewportCached;
  31646. /** @hidden */
  31647. _viewport(x: number, y: number, width: number, height: number): void;
  31648. /**
  31649. * Set the WebGL's viewport
  31650. * @param viewport defines the viewport element to be used
  31651. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31652. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31653. */
  31654. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31655. /**
  31656. * Begin a new frame
  31657. */
  31658. beginFrame(): void;
  31659. /**
  31660. * Enf the current frame
  31661. */
  31662. endFrame(): void;
  31663. /**
  31664. * Resize the view according to the canvas' size
  31665. */
  31666. resize(): void;
  31667. /**
  31668. * Force a specific size of the canvas
  31669. * @param width defines the new canvas' width
  31670. * @param height defines the new canvas' height
  31671. */
  31672. setSize(width: number, height: number): void;
  31673. /**
  31674. * Binds the frame buffer to the specified texture.
  31675. * @param texture The texture to render to or null for the default canvas
  31676. * @param faceIndex The face of the texture to render to in case of cube texture
  31677. * @param requiredWidth The width of the target to render to
  31678. * @param requiredHeight The height of the target to render to
  31679. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31680. * @param lodLevel defines the lod level to bind to the frame buffer
  31681. * @param layer defines the 2d array index to bind to frame buffer to
  31682. */
  31683. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31684. /** @hidden */
  31685. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31686. /**
  31687. * Unbind the current render target texture from the webGL context
  31688. * @param texture defines the render target texture to unbind
  31689. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31690. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31691. */
  31692. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31693. /**
  31694. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31695. */
  31696. flushFramebuffer(): void;
  31697. /**
  31698. * Unbind the current render target and bind the default framebuffer
  31699. */
  31700. restoreDefaultFramebuffer(): void;
  31701. /** @hidden */
  31702. protected _resetVertexBufferBinding(): void;
  31703. /**
  31704. * Creates a vertex buffer
  31705. * @param data the data for the vertex buffer
  31706. * @returns the new WebGL static buffer
  31707. */
  31708. createVertexBuffer(data: DataArray): DataBuffer;
  31709. private _createVertexBuffer;
  31710. /**
  31711. * Creates a dynamic vertex buffer
  31712. * @param data the data for the dynamic vertex buffer
  31713. * @returns the new WebGL dynamic buffer
  31714. */
  31715. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31716. protected _resetIndexBufferBinding(): void;
  31717. /**
  31718. * Creates a new index buffer
  31719. * @param indices defines the content of the index buffer
  31720. * @param updatable defines if the index buffer must be updatable
  31721. * @returns a new webGL buffer
  31722. */
  31723. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31724. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31725. /**
  31726. * Bind a webGL buffer to the webGL context
  31727. * @param buffer defines the buffer to bind
  31728. */
  31729. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31730. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31731. private bindBuffer;
  31732. /**
  31733. * update the bound buffer with the given data
  31734. * @param data defines the data to update
  31735. */
  31736. updateArrayBuffer(data: Float32Array): void;
  31737. private _vertexAttribPointer;
  31738. /** @hidden */
  31739. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31740. private _bindVertexBuffersAttributes;
  31741. /**
  31742. * Records a vertex array object
  31743. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31744. * @param vertexBuffers defines the list of vertex buffers to store
  31745. * @param indexBuffer defines the index buffer to store
  31746. * @param effect defines the effect to store
  31747. * @returns the new vertex array object
  31748. */
  31749. recordVertexArrayObject(vertexBuffers: {
  31750. [key: string]: VertexBuffer;
  31751. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31752. /**
  31753. * Bind a specific vertex array object
  31754. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31755. * @param vertexArrayObject defines the vertex array object to bind
  31756. * @param indexBuffer defines the index buffer to bind
  31757. */
  31758. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31759. /**
  31760. * Bind webGl buffers directly to the webGL context
  31761. * @param vertexBuffer defines the vertex buffer to bind
  31762. * @param indexBuffer defines the index buffer to bind
  31763. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31764. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31765. * @param effect defines the effect associated with the vertex buffer
  31766. */
  31767. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31768. private _unbindVertexArrayObject;
  31769. /**
  31770. * Bind a list of vertex buffers to the webGL context
  31771. * @param vertexBuffers defines the list of vertex buffers to bind
  31772. * @param indexBuffer defines the index buffer to bind
  31773. * @param effect defines the effect associated with the vertex buffers
  31774. */
  31775. bindBuffers(vertexBuffers: {
  31776. [key: string]: Nullable<VertexBuffer>;
  31777. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31778. /**
  31779. * Unbind all instance attributes
  31780. */
  31781. unbindInstanceAttributes(): void;
  31782. /**
  31783. * Release and free the memory of a vertex array object
  31784. * @param vao defines the vertex array object to delete
  31785. */
  31786. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31787. /** @hidden */
  31788. _releaseBuffer(buffer: DataBuffer): boolean;
  31789. protected _deleteBuffer(buffer: DataBuffer): void;
  31790. /**
  31791. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31792. * @param instancesBuffer defines the webGL buffer to update and bind
  31793. * @param data defines the data to store in the buffer
  31794. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31795. */
  31796. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31797. /**
  31798. * Bind the content of a webGL buffer used with instantiation
  31799. * @param instancesBuffer defines the webGL buffer to bind
  31800. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31801. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31802. */
  31803. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31804. /**
  31805. * Disable the instance attribute corresponding to the name in parameter
  31806. * @param name defines the name of the attribute to disable
  31807. */
  31808. disableInstanceAttributeByName(name: string): void;
  31809. /**
  31810. * Disable the instance attribute corresponding to the location in parameter
  31811. * @param attributeLocation defines the attribute location of the attribute to disable
  31812. */
  31813. disableInstanceAttribute(attributeLocation: number): void;
  31814. /**
  31815. * Disable the attribute corresponding to the location in parameter
  31816. * @param attributeLocation defines the attribute location of the attribute to disable
  31817. */
  31818. disableAttributeByIndex(attributeLocation: number): void;
  31819. /**
  31820. * Send a draw order
  31821. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31822. * @param indexStart defines the starting index
  31823. * @param indexCount defines the number of index to draw
  31824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31825. */
  31826. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31827. /**
  31828. * Draw a list of points
  31829. * @param verticesStart defines the index of first vertex to draw
  31830. * @param verticesCount defines the count of vertices to draw
  31831. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31832. */
  31833. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31834. /**
  31835. * Draw a list of unindexed primitives
  31836. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31837. * @param verticesStart defines the index of first vertex to draw
  31838. * @param verticesCount defines the count of vertices to draw
  31839. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31840. */
  31841. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31842. /**
  31843. * Draw a list of indexed primitives
  31844. * @param fillMode defines the primitive to use
  31845. * @param indexStart defines the starting index
  31846. * @param indexCount defines the number of index to draw
  31847. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31848. */
  31849. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31850. /**
  31851. * Draw a list of unindexed primitives
  31852. * @param fillMode defines the primitive to use
  31853. * @param verticesStart defines the index of first vertex to draw
  31854. * @param verticesCount defines the count of vertices to draw
  31855. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31856. */
  31857. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31858. private _drawMode;
  31859. /** @hidden */
  31860. protected _reportDrawCall(): void;
  31861. /** @hidden */
  31862. _releaseEffect(effect: Effect): void;
  31863. /** @hidden */
  31864. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31865. /**
  31866. * Create a new effect (used to store vertex/fragment shaders)
  31867. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31868. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31869. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31870. * @param samplers defines an array of string used to represent textures
  31871. * @param defines defines the string containing the defines to use to compile the shaders
  31872. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31873. * @param onCompiled defines a function to call when the effect creation is successful
  31874. * @param onError defines a function to call when the effect creation has failed
  31875. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31876. * @returns the new Effect
  31877. */
  31878. 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;
  31879. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31880. private _compileShader;
  31881. private _compileRawShader;
  31882. /** @hidden */
  31883. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31884. /**
  31885. * Directly creates a webGL program
  31886. * @param pipelineContext defines the pipeline context to attach to
  31887. * @param vertexCode defines the vertex shader code to use
  31888. * @param fragmentCode defines the fragment shader code to use
  31889. * @param context defines the webGL context to use (if not set, the current one will be used)
  31890. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31891. * @returns the new webGL program
  31892. */
  31893. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31894. /**
  31895. * Creates a webGL program
  31896. * @param pipelineContext defines the pipeline context to attach to
  31897. * @param vertexCode defines the vertex shader code to use
  31898. * @param fragmentCode defines the fragment shader code to use
  31899. * @param defines defines the string containing the defines to use to compile the shaders
  31900. * @param context defines the webGL context to use (if not set, the current one will be used)
  31901. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31902. * @returns the new webGL program
  31903. */
  31904. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31905. /**
  31906. * Creates a new pipeline context
  31907. * @returns the new pipeline
  31908. */
  31909. createPipelineContext(): IPipelineContext;
  31910. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31911. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31912. /** @hidden */
  31913. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31914. /** @hidden */
  31915. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31916. /** @hidden */
  31917. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31918. /**
  31919. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31920. * @param pipelineContext defines the pipeline context to use
  31921. * @param uniformsNames defines the list of uniform names
  31922. * @returns an array of webGL uniform locations
  31923. */
  31924. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31925. /**
  31926. * Gets the lsit of active attributes for a given webGL program
  31927. * @param pipelineContext defines the pipeline context to use
  31928. * @param attributesNames defines the list of attribute names to get
  31929. * @returns an array of indices indicating the offset of each attribute
  31930. */
  31931. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31932. /**
  31933. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31934. * @param effect defines the effect to activate
  31935. */
  31936. enableEffect(effect: Nullable<Effect>): void;
  31937. /**
  31938. * Set the value of an uniform to a number (int)
  31939. * @param uniform defines the webGL uniform location where to store the value
  31940. * @param value defines the int number to store
  31941. */
  31942. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31943. /**
  31944. * Set the value of an uniform to an array of int32
  31945. * @param uniform defines the webGL uniform location where to store the value
  31946. * @param array defines the array of int32 to store
  31947. */
  31948. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31949. /**
  31950. * Set the value of an uniform to an array of int32 (stored as vec2)
  31951. * @param uniform defines the webGL uniform location where to store the value
  31952. * @param array defines the array of int32 to store
  31953. */
  31954. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31955. /**
  31956. * Set the value of an uniform to an array of int32 (stored as vec3)
  31957. * @param uniform defines the webGL uniform location where to store the value
  31958. * @param array defines the array of int32 to store
  31959. */
  31960. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31961. /**
  31962. * Set the value of an uniform to an array of int32 (stored as vec4)
  31963. * @param uniform defines the webGL uniform location where to store the value
  31964. * @param array defines the array of int32 to store
  31965. */
  31966. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31967. /**
  31968. * Set the value of an uniform to an array of number
  31969. * @param uniform defines the webGL uniform location where to store the value
  31970. * @param array defines the array of number to store
  31971. */
  31972. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31973. /**
  31974. * Set the value of an uniform to an array of number (stored as vec2)
  31975. * @param uniform defines the webGL uniform location where to store the value
  31976. * @param array defines the array of number to store
  31977. */
  31978. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31979. /**
  31980. * Set the value of an uniform to an array of number (stored as vec3)
  31981. * @param uniform defines the webGL uniform location where to store the value
  31982. * @param array defines the array of number to store
  31983. */
  31984. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31985. /**
  31986. * Set the value of an uniform to an array of number (stored as vec4)
  31987. * @param uniform defines the webGL uniform location where to store the value
  31988. * @param array defines the array of number to store
  31989. */
  31990. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31991. /**
  31992. * Set the value of an uniform to an array of float32 (stored as matrices)
  31993. * @param uniform defines the webGL uniform location where to store the value
  31994. * @param matrices defines the array of float32 to store
  31995. */
  31996. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31997. /**
  31998. * Set the value of an uniform to a matrix (3x3)
  31999. * @param uniform defines the webGL uniform location where to store the value
  32000. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32001. */
  32002. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32003. /**
  32004. * Set the value of an uniform to a matrix (2x2)
  32005. * @param uniform defines the webGL uniform location where to store the value
  32006. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32007. */
  32008. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32009. /**
  32010. * Set the value of an uniform to a number (float)
  32011. * @param uniform defines the webGL uniform location where to store the value
  32012. * @param value defines the float number to store
  32013. */
  32014. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32015. /**
  32016. * Set the value of an uniform to a vec2
  32017. * @param uniform defines the webGL uniform location where to store the value
  32018. * @param x defines the 1st component of the value
  32019. * @param y defines the 2nd component of the value
  32020. */
  32021. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32022. /**
  32023. * Set the value of an uniform to a vec3
  32024. * @param uniform defines the webGL uniform location where to store the value
  32025. * @param x defines the 1st component of the value
  32026. * @param y defines the 2nd component of the value
  32027. * @param z defines the 3rd component of the value
  32028. */
  32029. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32030. /**
  32031. * Set the value of an uniform to a vec4
  32032. * @param uniform defines the webGL uniform location where to store the value
  32033. * @param x defines the 1st component of the value
  32034. * @param y defines the 2nd component of the value
  32035. * @param z defines the 3rd component of the value
  32036. * @param w defines the 4th component of the value
  32037. */
  32038. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32039. /**
  32040. * Apply all cached states (depth, culling, stencil and alpha)
  32041. */
  32042. applyStates(): void;
  32043. /**
  32044. * Enable or disable color writing
  32045. * @param enable defines the state to set
  32046. */
  32047. setColorWrite(enable: boolean): void;
  32048. /**
  32049. * Gets a boolean indicating if color writing is enabled
  32050. * @returns the current color writing state
  32051. */
  32052. getColorWrite(): boolean;
  32053. /**
  32054. * Gets the depth culling state manager
  32055. */
  32056. get depthCullingState(): DepthCullingState;
  32057. /**
  32058. * Gets the alpha state manager
  32059. */
  32060. get alphaState(): AlphaState;
  32061. /**
  32062. * Gets the stencil state manager
  32063. */
  32064. get stencilState(): StencilState;
  32065. /**
  32066. * Clears the list of texture accessible through engine.
  32067. * This can help preventing texture load conflict due to name collision.
  32068. */
  32069. clearInternalTexturesCache(): void;
  32070. /**
  32071. * Force the entire cache to be cleared
  32072. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32073. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32074. */
  32075. wipeCaches(bruteForce?: boolean): void;
  32076. /** @hidden */
  32077. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32078. min: number;
  32079. mag: number;
  32080. };
  32081. /** @hidden */
  32082. _createTexture(): WebGLTexture;
  32083. /**
  32084. * Usually called from Texture.ts.
  32085. * Passed information to create a WebGLTexture
  32086. * @param url defines a value which contains one of the following:
  32087. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32088. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32089. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32090. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32091. * @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)
  32092. * @param scene needed for loading to the correct scene
  32093. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32094. * @param onLoad optional callback to be called upon successful completion
  32095. * @param onError optional callback to be called upon failure
  32096. * @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
  32097. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32098. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32099. * @param forcedExtension defines the extension to use to pick the right loader
  32100. * @param mimeType defines an optional mime type
  32101. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32102. */
  32103. 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;
  32104. /**
  32105. * Loads an image as an HTMLImageElement.
  32106. * @param input url string, ArrayBuffer, or Blob to load
  32107. * @param onLoad callback called when the image successfully loads
  32108. * @param onError callback called when the image fails to load
  32109. * @param offlineProvider offline provider for caching
  32110. * @param mimeType optional mime type
  32111. * @returns the HTMLImageElement of the loaded image
  32112. * @hidden
  32113. */
  32114. 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>;
  32115. /**
  32116. * @hidden
  32117. */
  32118. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32119. /**
  32120. * Creates a raw texture
  32121. * @param data defines the data to store in the texture
  32122. * @param width defines the width of the texture
  32123. * @param height defines the height of the texture
  32124. * @param format defines the format of the data
  32125. * @param generateMipMaps defines if the engine should generate the mip levels
  32126. * @param invertY defines if data must be stored with Y axis inverted
  32127. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32128. * @param compression defines the compression used (null by default)
  32129. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32130. * @returns the raw texture inside an InternalTexture
  32131. */
  32132. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32133. /**
  32134. * Creates a new raw cube texture
  32135. * @param data defines the array of data to use to create each face
  32136. * @param size defines the size of the textures
  32137. * @param format defines the format of the data
  32138. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32139. * @param generateMipMaps defines if the engine should generate the mip levels
  32140. * @param invertY defines if data must be stored with Y axis inverted
  32141. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32142. * @param compression defines the compression used (null by default)
  32143. * @returns the cube texture as an InternalTexture
  32144. */
  32145. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32146. /**
  32147. * Creates a new raw 3D texture
  32148. * @param data defines the data used to create the texture
  32149. * @param width defines the width of the texture
  32150. * @param height defines the height of the texture
  32151. * @param depth defines the depth of the texture
  32152. * @param format defines the format of the texture
  32153. * @param generateMipMaps defines if the engine must generate mip levels
  32154. * @param invertY defines if data must be stored with Y axis inverted
  32155. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32156. * @param compression defines the compressed used (can be null)
  32157. * @param textureType defines the compressed used (can be null)
  32158. * @returns a new raw 3D texture (stored in an InternalTexture)
  32159. */
  32160. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32161. /**
  32162. * Creates a new raw 2D array texture
  32163. * @param data defines the data used to create the texture
  32164. * @param width defines the width of the texture
  32165. * @param height defines the height of the texture
  32166. * @param depth defines the number of layers of the texture
  32167. * @param format defines the format of the texture
  32168. * @param generateMipMaps defines if the engine must generate mip levels
  32169. * @param invertY defines if data must be stored with Y axis inverted
  32170. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32171. * @param compression defines the compressed used (can be null)
  32172. * @param textureType defines the compressed used (can be null)
  32173. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32174. */
  32175. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32176. private _unpackFlipYCached;
  32177. /**
  32178. * In case you are sharing the context with other applications, it might
  32179. * be interested to not cache the unpack flip y state to ensure a consistent
  32180. * value would be set.
  32181. */
  32182. enableUnpackFlipYCached: boolean;
  32183. /** @hidden */
  32184. _unpackFlipY(value: boolean): void;
  32185. /** @hidden */
  32186. _getUnpackAlignement(): number;
  32187. private _getTextureTarget;
  32188. /**
  32189. * Update the sampling mode of a given texture
  32190. * @param samplingMode defines the required sampling mode
  32191. * @param texture defines the texture to update
  32192. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32193. */
  32194. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32195. /**
  32196. * Update the sampling mode of a given texture
  32197. * @param texture defines the texture to update
  32198. * @param wrapU defines the texture wrap mode of the u coordinates
  32199. * @param wrapV defines the texture wrap mode of the v coordinates
  32200. * @param wrapR defines the texture wrap mode of the r coordinates
  32201. */
  32202. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32203. /** @hidden */
  32204. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32205. width: number;
  32206. height: number;
  32207. layers?: number;
  32208. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32209. /** @hidden */
  32210. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32211. /** @hidden */
  32212. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32213. /**
  32214. * Update a portion of an internal texture
  32215. * @param texture defines the texture to update
  32216. * @param imageData defines the data to store into the texture
  32217. * @param xOffset defines the x coordinates of the update rectangle
  32218. * @param yOffset defines the y coordinates of the update rectangle
  32219. * @param width defines the width of the update rectangle
  32220. * @param height defines the height of the update rectangle
  32221. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32222. * @param lod defines the lod level to update (0 by default)
  32223. */
  32224. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32225. /** @hidden */
  32226. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32227. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32228. private _prepareWebGLTexture;
  32229. /** @hidden */
  32230. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32231. private _getDepthStencilBuffer;
  32232. /** @hidden */
  32233. _releaseFramebufferObjects(texture: InternalTexture): void;
  32234. /** @hidden */
  32235. _releaseTexture(texture: InternalTexture): void;
  32236. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32237. protected _setProgram(program: WebGLProgram): void;
  32238. protected _boundUniforms: {
  32239. [key: number]: WebGLUniformLocation;
  32240. };
  32241. /**
  32242. * Binds an effect to the webGL context
  32243. * @param effect defines the effect to bind
  32244. */
  32245. bindSamplers(effect: Effect): void;
  32246. private _activateCurrentTexture;
  32247. /** @hidden */
  32248. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32249. /** @hidden */
  32250. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32251. /**
  32252. * Unbind all textures from the webGL context
  32253. */
  32254. unbindAllTextures(): void;
  32255. /**
  32256. * Sets a texture to the according uniform.
  32257. * @param channel The texture channel
  32258. * @param uniform The uniform to set
  32259. * @param texture The texture to apply
  32260. */
  32261. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32262. private _bindSamplerUniformToChannel;
  32263. private _getTextureWrapMode;
  32264. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32265. /**
  32266. * Sets an array of texture to the webGL context
  32267. * @param channel defines the channel where the texture array must be set
  32268. * @param uniform defines the associated uniform location
  32269. * @param textures defines the array of textures to bind
  32270. */
  32271. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32272. /** @hidden */
  32273. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32274. private _setTextureParameterFloat;
  32275. private _setTextureParameterInteger;
  32276. /**
  32277. * Unbind all vertex attributes from the webGL context
  32278. */
  32279. unbindAllAttributes(): void;
  32280. /**
  32281. * 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
  32282. */
  32283. releaseEffects(): void;
  32284. /**
  32285. * Dispose and release all associated resources
  32286. */
  32287. dispose(): void;
  32288. /**
  32289. * Attach a new callback raised when context lost event is fired
  32290. * @param callback defines the callback to call
  32291. */
  32292. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32293. /**
  32294. * Attach a new callback raised when context restored event is fired
  32295. * @param callback defines the callback to call
  32296. */
  32297. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32298. /**
  32299. * Get the current error code of the webGL context
  32300. * @returns the error code
  32301. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32302. */
  32303. getError(): number;
  32304. private _canRenderToFloatFramebuffer;
  32305. private _canRenderToHalfFloatFramebuffer;
  32306. private _canRenderToFramebuffer;
  32307. /** @hidden */
  32308. _getWebGLTextureType(type: number): number;
  32309. /** @hidden */
  32310. _getInternalFormat(format: number): number;
  32311. /** @hidden */
  32312. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32313. /** @hidden */
  32314. _getRGBAMultiSampleBufferFormat(type: number): number;
  32315. /** @hidden */
  32316. _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;
  32317. /**
  32318. * Loads a file from a url
  32319. * @param url url to load
  32320. * @param onSuccess callback called when the file successfully loads
  32321. * @param onProgress callback called while file is loading (if the server supports this mode)
  32322. * @param offlineProvider defines the offline provider for caching
  32323. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32324. * @param onError callback called when the file fails to load
  32325. * @returns a file request object
  32326. * @hidden
  32327. */
  32328. 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;
  32329. /**
  32330. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32331. * @param x defines the x coordinate of the rectangle where pixels must be read
  32332. * @param y defines the y coordinate of the rectangle where pixels must be read
  32333. * @param width defines the width of the rectangle where pixels must be read
  32334. * @param height defines the height of the rectangle where pixels must be read
  32335. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32336. * @returns a Uint8Array containing RGBA colors
  32337. */
  32338. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32339. private static _isSupported;
  32340. /**
  32341. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32342. * @returns true if the engine can be created
  32343. * @ignorenaming
  32344. */
  32345. static isSupported(): boolean;
  32346. /**
  32347. * Find the next highest power of two.
  32348. * @param x Number to start search from.
  32349. * @return Next highest power of two.
  32350. */
  32351. static CeilingPOT(x: number): number;
  32352. /**
  32353. * Find the next lowest power of two.
  32354. * @param x Number to start search from.
  32355. * @return Next lowest power of two.
  32356. */
  32357. static FloorPOT(x: number): number;
  32358. /**
  32359. * Find the nearest power of two.
  32360. * @param x Number to start search from.
  32361. * @return Next nearest power of two.
  32362. */
  32363. static NearestPOT(x: number): number;
  32364. /**
  32365. * Get the closest exponent of two
  32366. * @param value defines the value to approximate
  32367. * @param max defines the maximum value to return
  32368. * @param mode defines how to define the closest value
  32369. * @returns closest exponent of two of the given value
  32370. */
  32371. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32372. /**
  32373. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32374. * @param func - the function to be called
  32375. * @param requester - the object that will request the next frame. Falls back to window.
  32376. * @returns frame number
  32377. */
  32378. static QueueNewFrame(func: () => void, requester?: any): number;
  32379. /**
  32380. * Gets host document
  32381. * @returns the host document object
  32382. */
  32383. getHostDocument(): Nullable<Document>;
  32384. }
  32385. }
  32386. declare module BABYLON {
  32387. /**
  32388. * Class representing spherical harmonics coefficients to the 3rd degree
  32389. */
  32390. export class SphericalHarmonics {
  32391. /**
  32392. * Defines whether or not the harmonics have been prescaled for rendering.
  32393. */
  32394. preScaled: boolean;
  32395. /**
  32396. * The l0,0 coefficients of the spherical harmonics
  32397. */
  32398. l00: Vector3;
  32399. /**
  32400. * The l1,-1 coefficients of the spherical harmonics
  32401. */
  32402. l1_1: Vector3;
  32403. /**
  32404. * The l1,0 coefficients of the spherical harmonics
  32405. */
  32406. l10: Vector3;
  32407. /**
  32408. * The l1,1 coefficients of the spherical harmonics
  32409. */
  32410. l11: Vector3;
  32411. /**
  32412. * The l2,-2 coefficients of the spherical harmonics
  32413. */
  32414. l2_2: Vector3;
  32415. /**
  32416. * The l2,-1 coefficients of the spherical harmonics
  32417. */
  32418. l2_1: Vector3;
  32419. /**
  32420. * The l2,0 coefficients of the spherical harmonics
  32421. */
  32422. l20: Vector3;
  32423. /**
  32424. * The l2,1 coefficients of the spherical harmonics
  32425. */
  32426. l21: Vector3;
  32427. /**
  32428. * The l2,2 coefficients of the spherical harmonics
  32429. */
  32430. l22: Vector3;
  32431. /**
  32432. * Adds a light to the spherical harmonics
  32433. * @param direction the direction of the light
  32434. * @param color the color of the light
  32435. * @param deltaSolidAngle the delta solid angle of the light
  32436. */
  32437. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32438. /**
  32439. * Scales the spherical harmonics by the given amount
  32440. * @param scale the amount to scale
  32441. */
  32442. scaleInPlace(scale: number): void;
  32443. /**
  32444. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32445. *
  32446. * ```
  32447. * E_lm = A_l * L_lm
  32448. * ```
  32449. *
  32450. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32451. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32452. * the scaling factors are given in equation 9.
  32453. */
  32454. convertIncidentRadianceToIrradiance(): void;
  32455. /**
  32456. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32457. *
  32458. * ```
  32459. * L = (1/pi) * E * rho
  32460. * ```
  32461. *
  32462. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32463. */
  32464. convertIrradianceToLambertianRadiance(): void;
  32465. /**
  32466. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32467. * required operations at run time.
  32468. *
  32469. * This is simply done by scaling back the SH with Ylm constants parameter.
  32470. * The trigonometric part being applied by the shader at run time.
  32471. */
  32472. preScaleForRendering(): void;
  32473. /**
  32474. * Constructs a spherical harmonics from an array.
  32475. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32476. * @returns the spherical harmonics
  32477. */
  32478. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32479. /**
  32480. * Gets the spherical harmonics from polynomial
  32481. * @param polynomial the spherical polynomial
  32482. * @returns the spherical harmonics
  32483. */
  32484. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32485. }
  32486. /**
  32487. * Class representing spherical polynomial coefficients to the 3rd degree
  32488. */
  32489. export class SphericalPolynomial {
  32490. private _harmonics;
  32491. /**
  32492. * The spherical harmonics used to create the polynomials.
  32493. */
  32494. get preScaledHarmonics(): SphericalHarmonics;
  32495. /**
  32496. * The x coefficients of the spherical polynomial
  32497. */
  32498. x: Vector3;
  32499. /**
  32500. * The y coefficients of the spherical polynomial
  32501. */
  32502. y: Vector3;
  32503. /**
  32504. * The z coefficients of the spherical polynomial
  32505. */
  32506. z: Vector3;
  32507. /**
  32508. * The xx coefficients of the spherical polynomial
  32509. */
  32510. xx: Vector3;
  32511. /**
  32512. * The yy coefficients of the spherical polynomial
  32513. */
  32514. yy: Vector3;
  32515. /**
  32516. * The zz coefficients of the spherical polynomial
  32517. */
  32518. zz: Vector3;
  32519. /**
  32520. * The xy coefficients of the spherical polynomial
  32521. */
  32522. xy: Vector3;
  32523. /**
  32524. * The yz coefficients of the spherical polynomial
  32525. */
  32526. yz: Vector3;
  32527. /**
  32528. * The zx coefficients of the spherical polynomial
  32529. */
  32530. zx: Vector3;
  32531. /**
  32532. * Adds an ambient color to the spherical polynomial
  32533. * @param color the color to add
  32534. */
  32535. addAmbient(color: Color3): void;
  32536. /**
  32537. * Scales the spherical polynomial by the given amount
  32538. * @param scale the amount to scale
  32539. */
  32540. scaleInPlace(scale: number): void;
  32541. /**
  32542. * Gets the spherical polynomial from harmonics
  32543. * @param harmonics the spherical harmonics
  32544. * @returns the spherical polynomial
  32545. */
  32546. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32547. /**
  32548. * Constructs a spherical polynomial from an array.
  32549. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32550. * @returns the spherical polynomial
  32551. */
  32552. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32553. }
  32554. }
  32555. declare module BABYLON {
  32556. /**
  32557. * Defines the source of the internal texture
  32558. */
  32559. export enum InternalTextureSource {
  32560. /**
  32561. * The source of the texture data is unknown
  32562. */
  32563. Unknown = 0,
  32564. /**
  32565. * Texture data comes from an URL
  32566. */
  32567. Url = 1,
  32568. /**
  32569. * Texture data is only used for temporary storage
  32570. */
  32571. Temp = 2,
  32572. /**
  32573. * Texture data comes from raw data (ArrayBuffer)
  32574. */
  32575. Raw = 3,
  32576. /**
  32577. * Texture content is dynamic (video or dynamic texture)
  32578. */
  32579. Dynamic = 4,
  32580. /**
  32581. * Texture content is generated by rendering to it
  32582. */
  32583. RenderTarget = 5,
  32584. /**
  32585. * Texture content is part of a multi render target process
  32586. */
  32587. MultiRenderTarget = 6,
  32588. /**
  32589. * Texture data comes from a cube data file
  32590. */
  32591. Cube = 7,
  32592. /**
  32593. * Texture data comes from a raw cube data
  32594. */
  32595. CubeRaw = 8,
  32596. /**
  32597. * Texture data come from a prefiltered cube data file
  32598. */
  32599. CubePrefiltered = 9,
  32600. /**
  32601. * Texture content is raw 3D data
  32602. */
  32603. Raw3D = 10,
  32604. /**
  32605. * Texture content is raw 2D array data
  32606. */
  32607. Raw2DArray = 11,
  32608. /**
  32609. * Texture content is a depth texture
  32610. */
  32611. Depth = 12,
  32612. /**
  32613. * Texture data comes from a raw cube data encoded with RGBD
  32614. */
  32615. CubeRawRGBD = 13
  32616. }
  32617. /**
  32618. * Class used to store data associated with WebGL texture data for the engine
  32619. * This class should not be used directly
  32620. */
  32621. export class InternalTexture {
  32622. /** @hidden */
  32623. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32624. /**
  32625. * Defines if the texture is ready
  32626. */
  32627. isReady: boolean;
  32628. /**
  32629. * Defines if the texture is a cube texture
  32630. */
  32631. isCube: boolean;
  32632. /**
  32633. * Defines if the texture contains 3D data
  32634. */
  32635. is3D: boolean;
  32636. /**
  32637. * Defines if the texture contains 2D array data
  32638. */
  32639. is2DArray: boolean;
  32640. /**
  32641. * Defines if the texture contains multiview data
  32642. */
  32643. isMultiview: boolean;
  32644. /**
  32645. * Gets the URL used to load this texture
  32646. */
  32647. url: string;
  32648. /**
  32649. * Gets the sampling mode of the texture
  32650. */
  32651. samplingMode: number;
  32652. /**
  32653. * Gets a boolean indicating if the texture needs mipmaps generation
  32654. */
  32655. generateMipMaps: boolean;
  32656. /**
  32657. * Gets the number of samples used by the texture (WebGL2+ only)
  32658. */
  32659. samples: number;
  32660. /**
  32661. * Gets the type of the texture (int, float...)
  32662. */
  32663. type: number;
  32664. /**
  32665. * Gets the format of the texture (RGB, RGBA...)
  32666. */
  32667. format: number;
  32668. /**
  32669. * Observable called when the texture is loaded
  32670. */
  32671. onLoadedObservable: Observable<InternalTexture>;
  32672. /**
  32673. * Gets the width of the texture
  32674. */
  32675. width: number;
  32676. /**
  32677. * Gets the height of the texture
  32678. */
  32679. height: number;
  32680. /**
  32681. * Gets the depth of the texture
  32682. */
  32683. depth: number;
  32684. /**
  32685. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32686. */
  32687. baseWidth: number;
  32688. /**
  32689. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32690. */
  32691. baseHeight: number;
  32692. /**
  32693. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32694. */
  32695. baseDepth: number;
  32696. /**
  32697. * Gets a boolean indicating if the texture is inverted on Y axis
  32698. */
  32699. invertY: boolean;
  32700. /** @hidden */
  32701. _invertVScale: boolean;
  32702. /** @hidden */
  32703. _associatedChannel: number;
  32704. /** @hidden */
  32705. _source: InternalTextureSource;
  32706. /** @hidden */
  32707. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32708. /** @hidden */
  32709. _bufferView: Nullable<ArrayBufferView>;
  32710. /** @hidden */
  32711. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32712. /** @hidden */
  32713. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32714. /** @hidden */
  32715. _size: number;
  32716. /** @hidden */
  32717. _extension: string;
  32718. /** @hidden */
  32719. _files: Nullable<string[]>;
  32720. /** @hidden */
  32721. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32722. /** @hidden */
  32723. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32724. /** @hidden */
  32725. _framebuffer: Nullable<WebGLFramebuffer>;
  32726. /** @hidden */
  32727. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32728. /** @hidden */
  32729. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32730. /** @hidden */
  32731. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32732. /** @hidden */
  32733. _attachments: Nullable<number[]>;
  32734. /** @hidden */
  32735. _cachedCoordinatesMode: Nullable<number>;
  32736. /** @hidden */
  32737. _cachedWrapU: Nullable<number>;
  32738. /** @hidden */
  32739. _cachedWrapV: Nullable<number>;
  32740. /** @hidden */
  32741. _cachedWrapR: Nullable<number>;
  32742. /** @hidden */
  32743. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32744. /** @hidden */
  32745. _isDisabled: boolean;
  32746. /** @hidden */
  32747. _compression: Nullable<string>;
  32748. /** @hidden */
  32749. _generateStencilBuffer: boolean;
  32750. /** @hidden */
  32751. _generateDepthBuffer: boolean;
  32752. /** @hidden */
  32753. _comparisonFunction: number;
  32754. /** @hidden */
  32755. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32756. /** @hidden */
  32757. _lodGenerationScale: number;
  32758. /** @hidden */
  32759. _lodGenerationOffset: number;
  32760. /** @hidden */
  32761. _depthStencilTexture: Nullable<InternalTexture>;
  32762. /** @hidden */
  32763. _colorTextureArray: Nullable<WebGLTexture>;
  32764. /** @hidden */
  32765. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32766. /** @hidden */
  32767. _lodTextureHigh: Nullable<BaseTexture>;
  32768. /** @hidden */
  32769. _lodTextureMid: Nullable<BaseTexture>;
  32770. /** @hidden */
  32771. _lodTextureLow: Nullable<BaseTexture>;
  32772. /** @hidden */
  32773. _isRGBD: boolean;
  32774. /** @hidden */
  32775. _linearSpecularLOD: boolean;
  32776. /** @hidden */
  32777. _irradianceTexture: Nullable<BaseTexture>;
  32778. /** @hidden */
  32779. _webGLTexture: Nullable<WebGLTexture>;
  32780. /** @hidden */
  32781. _references: number;
  32782. private _engine;
  32783. /**
  32784. * Gets the Engine the texture belongs to.
  32785. * @returns The babylon engine
  32786. */
  32787. getEngine(): ThinEngine;
  32788. /**
  32789. * Gets the data source type of the texture
  32790. */
  32791. get source(): InternalTextureSource;
  32792. /**
  32793. * Creates a new InternalTexture
  32794. * @param engine defines the engine to use
  32795. * @param source defines the type of data that will be used
  32796. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32797. */
  32798. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32799. /**
  32800. * Increments the number of references (ie. the number of Texture that point to it)
  32801. */
  32802. incrementReferences(): void;
  32803. /**
  32804. * Change the size of the texture (not the size of the content)
  32805. * @param width defines the new width
  32806. * @param height defines the new height
  32807. * @param depth defines the new depth (1 by default)
  32808. */
  32809. updateSize(width: int, height: int, depth?: int): void;
  32810. /** @hidden */
  32811. _rebuild(): void;
  32812. /** @hidden */
  32813. _swapAndDie(target: InternalTexture): void;
  32814. /**
  32815. * Dispose the current allocated resources
  32816. */
  32817. dispose(): void;
  32818. }
  32819. }
  32820. declare module BABYLON {
  32821. /**
  32822. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32824. */
  32825. export class Analyser {
  32826. /**
  32827. * Gets or sets the smoothing
  32828. * @ignorenaming
  32829. */
  32830. SMOOTHING: number;
  32831. /**
  32832. * Gets or sets the FFT table size
  32833. * @ignorenaming
  32834. */
  32835. FFT_SIZE: number;
  32836. /**
  32837. * Gets or sets the bar graph amplitude
  32838. * @ignorenaming
  32839. */
  32840. BARGRAPHAMPLITUDE: number;
  32841. /**
  32842. * Gets or sets the position of the debug canvas
  32843. * @ignorenaming
  32844. */
  32845. DEBUGCANVASPOS: {
  32846. x: number;
  32847. y: number;
  32848. };
  32849. /**
  32850. * Gets or sets the debug canvas size
  32851. * @ignorenaming
  32852. */
  32853. DEBUGCANVASSIZE: {
  32854. width: number;
  32855. height: number;
  32856. };
  32857. private _byteFreqs;
  32858. private _byteTime;
  32859. private _floatFreqs;
  32860. private _webAudioAnalyser;
  32861. private _debugCanvas;
  32862. private _debugCanvasContext;
  32863. private _scene;
  32864. private _registerFunc;
  32865. private _audioEngine;
  32866. /**
  32867. * Creates a new analyser
  32868. * @param scene defines hosting scene
  32869. */
  32870. constructor(scene: Scene);
  32871. /**
  32872. * Get the number of data values you will have to play with for the visualization
  32873. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32874. * @returns a number
  32875. */
  32876. getFrequencyBinCount(): number;
  32877. /**
  32878. * Gets the current frequency data as a byte array
  32879. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32880. * @returns a Uint8Array
  32881. */
  32882. getByteFrequencyData(): Uint8Array;
  32883. /**
  32884. * Gets the current waveform as a byte array
  32885. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32886. * @returns a Uint8Array
  32887. */
  32888. getByteTimeDomainData(): Uint8Array;
  32889. /**
  32890. * Gets the current frequency data as a float array
  32891. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32892. * @returns a Float32Array
  32893. */
  32894. getFloatFrequencyData(): Float32Array;
  32895. /**
  32896. * Renders the debug canvas
  32897. */
  32898. drawDebugCanvas(): void;
  32899. /**
  32900. * Stops rendering the debug canvas and removes it
  32901. */
  32902. stopDebugCanvas(): void;
  32903. /**
  32904. * Connects two audio nodes
  32905. * @param inputAudioNode defines first node to connect
  32906. * @param outputAudioNode defines second node to connect
  32907. */
  32908. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32909. /**
  32910. * Releases all associated resources
  32911. */
  32912. dispose(): void;
  32913. }
  32914. }
  32915. declare module BABYLON {
  32916. /**
  32917. * This represents an audio engine and it is responsible
  32918. * to play, synchronize and analyse sounds throughout the application.
  32919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32920. */
  32921. export interface IAudioEngine extends IDisposable {
  32922. /**
  32923. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32924. */
  32925. readonly canUseWebAudio: boolean;
  32926. /**
  32927. * Gets the current AudioContext if available.
  32928. */
  32929. readonly audioContext: Nullable<AudioContext>;
  32930. /**
  32931. * The master gain node defines the global audio volume of your audio engine.
  32932. */
  32933. readonly masterGain: GainNode;
  32934. /**
  32935. * Gets whether or not mp3 are supported by your browser.
  32936. */
  32937. readonly isMP3supported: boolean;
  32938. /**
  32939. * Gets whether or not ogg are supported by your browser.
  32940. */
  32941. readonly isOGGsupported: boolean;
  32942. /**
  32943. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32944. * @ignoreNaming
  32945. */
  32946. WarnedWebAudioUnsupported: boolean;
  32947. /**
  32948. * Defines if the audio engine relies on a custom unlocked button.
  32949. * In this case, the embedded button will not be displayed.
  32950. */
  32951. useCustomUnlockedButton: boolean;
  32952. /**
  32953. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32954. */
  32955. readonly unlocked: boolean;
  32956. /**
  32957. * Event raised when audio has been unlocked on the browser.
  32958. */
  32959. onAudioUnlockedObservable: Observable<AudioEngine>;
  32960. /**
  32961. * Event raised when audio has been locked on the browser.
  32962. */
  32963. onAudioLockedObservable: Observable<AudioEngine>;
  32964. /**
  32965. * Flags the audio engine in Locked state.
  32966. * This happens due to new browser policies preventing audio to autoplay.
  32967. */
  32968. lock(): void;
  32969. /**
  32970. * Unlocks the audio engine once a user action has been done on the dom.
  32971. * This is helpful to resume play once browser policies have been satisfied.
  32972. */
  32973. unlock(): void;
  32974. /**
  32975. * Gets the global volume sets on the master gain.
  32976. * @returns the global volume if set or -1 otherwise
  32977. */
  32978. getGlobalVolume(): number;
  32979. /**
  32980. * Sets the global volume of your experience (sets on the master gain).
  32981. * @param newVolume Defines the new global volume of the application
  32982. */
  32983. setGlobalVolume(newVolume: number): void;
  32984. /**
  32985. * Connect the audio engine to an audio analyser allowing some amazing
  32986. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32988. * @param analyser The analyser to connect to the engine
  32989. */
  32990. connectToAnalyser(analyser: Analyser): void;
  32991. }
  32992. /**
  32993. * This represents the default audio engine used in babylon.
  32994. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32996. */
  32997. export class AudioEngine implements IAudioEngine {
  32998. private _audioContext;
  32999. private _audioContextInitialized;
  33000. private _muteButton;
  33001. private _hostElement;
  33002. /**
  33003. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33004. */
  33005. canUseWebAudio: boolean;
  33006. /**
  33007. * The master gain node defines the global audio volume of your audio engine.
  33008. */
  33009. masterGain: GainNode;
  33010. /**
  33011. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33012. * @ignoreNaming
  33013. */
  33014. WarnedWebAudioUnsupported: boolean;
  33015. /**
  33016. * Gets whether or not mp3 are supported by your browser.
  33017. */
  33018. isMP3supported: boolean;
  33019. /**
  33020. * Gets whether or not ogg are supported by your browser.
  33021. */
  33022. isOGGsupported: boolean;
  33023. /**
  33024. * Gets whether audio has been unlocked on the device.
  33025. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33026. * a user interaction has happened.
  33027. */
  33028. unlocked: boolean;
  33029. /**
  33030. * Defines if the audio engine relies on a custom unlocked button.
  33031. * In this case, the embedded button will not be displayed.
  33032. */
  33033. useCustomUnlockedButton: boolean;
  33034. /**
  33035. * Event raised when audio has been unlocked on the browser.
  33036. */
  33037. onAudioUnlockedObservable: Observable<AudioEngine>;
  33038. /**
  33039. * Event raised when audio has been locked on the browser.
  33040. */
  33041. onAudioLockedObservable: Observable<AudioEngine>;
  33042. /**
  33043. * Gets the current AudioContext if available.
  33044. */
  33045. get audioContext(): Nullable<AudioContext>;
  33046. private _connectedAnalyser;
  33047. /**
  33048. * Instantiates a new audio engine.
  33049. *
  33050. * There should be only one per page as some browsers restrict the number
  33051. * of audio contexts you can create.
  33052. * @param hostElement defines the host element where to display the mute icon if necessary
  33053. */
  33054. constructor(hostElement?: Nullable<HTMLElement>);
  33055. /**
  33056. * Flags the audio engine in Locked state.
  33057. * This happens due to new browser policies preventing audio to autoplay.
  33058. */
  33059. lock(): void;
  33060. /**
  33061. * Unlocks the audio engine once a user action has been done on the dom.
  33062. * This is helpful to resume play once browser policies have been satisfied.
  33063. */
  33064. unlock(): void;
  33065. private _resumeAudioContext;
  33066. private _initializeAudioContext;
  33067. private _tryToRun;
  33068. private _triggerRunningState;
  33069. private _triggerSuspendedState;
  33070. private _displayMuteButton;
  33071. private _moveButtonToTopLeft;
  33072. private _onResize;
  33073. private _hideMuteButton;
  33074. /**
  33075. * Destroy and release the resources associated with the audio ccontext.
  33076. */
  33077. dispose(): void;
  33078. /**
  33079. * Gets the global volume sets on the master gain.
  33080. * @returns the global volume if set or -1 otherwise
  33081. */
  33082. getGlobalVolume(): number;
  33083. /**
  33084. * Sets the global volume of your experience (sets on the master gain).
  33085. * @param newVolume Defines the new global volume of the application
  33086. */
  33087. setGlobalVolume(newVolume: number): void;
  33088. /**
  33089. * Connect the audio engine to an audio analyser allowing some amazing
  33090. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33092. * @param analyser The analyser to connect to the engine
  33093. */
  33094. connectToAnalyser(analyser: Analyser): void;
  33095. }
  33096. }
  33097. declare module BABYLON {
  33098. /**
  33099. * Interface used to present a loading screen while loading a scene
  33100. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33101. */
  33102. export interface ILoadingScreen {
  33103. /**
  33104. * Function called to display the loading screen
  33105. */
  33106. displayLoadingUI: () => void;
  33107. /**
  33108. * Function called to hide the loading screen
  33109. */
  33110. hideLoadingUI: () => void;
  33111. /**
  33112. * Gets or sets the color to use for the background
  33113. */
  33114. loadingUIBackgroundColor: string;
  33115. /**
  33116. * Gets or sets the text to display while loading
  33117. */
  33118. loadingUIText: string;
  33119. }
  33120. /**
  33121. * Class used for the default loading screen
  33122. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33123. */
  33124. export class DefaultLoadingScreen implements ILoadingScreen {
  33125. private _renderingCanvas;
  33126. private _loadingText;
  33127. private _loadingDivBackgroundColor;
  33128. private _loadingDiv;
  33129. private _loadingTextDiv;
  33130. /** Gets or sets the logo url to use for the default loading screen */
  33131. static DefaultLogoUrl: string;
  33132. /** Gets or sets the spinner url to use for the default loading screen */
  33133. static DefaultSpinnerUrl: string;
  33134. /**
  33135. * Creates a new default loading screen
  33136. * @param _renderingCanvas defines the canvas used to render the scene
  33137. * @param _loadingText defines the default text to display
  33138. * @param _loadingDivBackgroundColor defines the default background color
  33139. */
  33140. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33141. /**
  33142. * Function called to display the loading screen
  33143. */
  33144. displayLoadingUI(): void;
  33145. /**
  33146. * Function called to hide the loading screen
  33147. */
  33148. hideLoadingUI(): void;
  33149. /**
  33150. * Gets or sets the text to display while loading
  33151. */
  33152. set loadingUIText(text: string);
  33153. get loadingUIText(): string;
  33154. /**
  33155. * Gets or sets the color to use for the background
  33156. */
  33157. get loadingUIBackgroundColor(): string;
  33158. set loadingUIBackgroundColor(color: string);
  33159. private _resizeLoadingUI;
  33160. }
  33161. }
  33162. declare module BABYLON {
  33163. /**
  33164. * Interface for any object that can request an animation frame
  33165. */
  33166. export interface ICustomAnimationFrameRequester {
  33167. /**
  33168. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33169. */
  33170. renderFunction?: Function;
  33171. /**
  33172. * Called to request the next frame to render to
  33173. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33174. */
  33175. requestAnimationFrame: Function;
  33176. /**
  33177. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33178. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33179. */
  33180. requestID?: number;
  33181. }
  33182. }
  33183. declare module BABYLON {
  33184. /**
  33185. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33186. */
  33187. export class PerformanceMonitor {
  33188. private _enabled;
  33189. private _rollingFrameTime;
  33190. private _lastFrameTimeMs;
  33191. /**
  33192. * constructor
  33193. * @param frameSampleSize The number of samples required to saturate the sliding window
  33194. */
  33195. constructor(frameSampleSize?: number);
  33196. /**
  33197. * Samples current frame
  33198. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33199. */
  33200. sampleFrame(timeMs?: number): void;
  33201. /**
  33202. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33203. */
  33204. get averageFrameTime(): number;
  33205. /**
  33206. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33207. */
  33208. get averageFrameTimeVariance(): number;
  33209. /**
  33210. * Returns the frame time of the most recent frame
  33211. */
  33212. get instantaneousFrameTime(): number;
  33213. /**
  33214. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33215. */
  33216. get averageFPS(): number;
  33217. /**
  33218. * Returns the average framerate in frames per second using the most recent frame time
  33219. */
  33220. get instantaneousFPS(): number;
  33221. /**
  33222. * Returns true if enough samples have been taken to completely fill the sliding window
  33223. */
  33224. get isSaturated(): boolean;
  33225. /**
  33226. * Enables contributions to the sliding window sample set
  33227. */
  33228. enable(): void;
  33229. /**
  33230. * Disables contributions to the sliding window sample set
  33231. * Samples will not be interpolated over the disabled period
  33232. */
  33233. disable(): void;
  33234. /**
  33235. * Returns true if sampling is enabled
  33236. */
  33237. get isEnabled(): boolean;
  33238. /**
  33239. * Resets performance monitor
  33240. */
  33241. reset(): void;
  33242. }
  33243. /**
  33244. * RollingAverage
  33245. *
  33246. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33247. */
  33248. export class RollingAverage {
  33249. /**
  33250. * Current average
  33251. */
  33252. average: number;
  33253. /**
  33254. * Current variance
  33255. */
  33256. variance: number;
  33257. protected _samples: Array<number>;
  33258. protected _sampleCount: number;
  33259. protected _pos: number;
  33260. protected _m2: number;
  33261. /**
  33262. * constructor
  33263. * @param length The number of samples required to saturate the sliding window
  33264. */
  33265. constructor(length: number);
  33266. /**
  33267. * Adds a sample to the sample set
  33268. * @param v The sample value
  33269. */
  33270. add(v: number): void;
  33271. /**
  33272. * Returns previously added values or null if outside of history or outside the sliding window domain
  33273. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33274. * @return Value previously recorded with add() or null if outside of range
  33275. */
  33276. history(i: number): number;
  33277. /**
  33278. * Returns true if enough samples have been taken to completely fill the sliding window
  33279. * @return true if sample-set saturated
  33280. */
  33281. isSaturated(): boolean;
  33282. /**
  33283. * Resets the rolling average (equivalent to 0 samples taken so far)
  33284. */
  33285. reset(): void;
  33286. /**
  33287. * Wraps a value around the sample range boundaries
  33288. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33289. * @return Wrapped position in sample range
  33290. */
  33291. protected _wrapPosition(i: number): number;
  33292. }
  33293. }
  33294. declare module BABYLON {
  33295. /**
  33296. * This class is used to track a performance counter which is number based.
  33297. * The user has access to many properties which give statistics of different nature.
  33298. *
  33299. * The implementer can track two kinds of Performance Counter: time and count.
  33300. * 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.
  33301. * 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.
  33302. */
  33303. export class PerfCounter {
  33304. /**
  33305. * Gets or sets a global boolean to turn on and off all the counters
  33306. */
  33307. static Enabled: boolean;
  33308. /**
  33309. * Returns the smallest value ever
  33310. */
  33311. get min(): number;
  33312. /**
  33313. * Returns the biggest value ever
  33314. */
  33315. get max(): number;
  33316. /**
  33317. * Returns the average value since the performance counter is running
  33318. */
  33319. get average(): number;
  33320. /**
  33321. * Returns the average value of the last second the counter was monitored
  33322. */
  33323. get lastSecAverage(): number;
  33324. /**
  33325. * Returns the current value
  33326. */
  33327. get current(): number;
  33328. /**
  33329. * Gets the accumulated total
  33330. */
  33331. get total(): number;
  33332. /**
  33333. * Gets the total value count
  33334. */
  33335. get count(): number;
  33336. /**
  33337. * Creates a new counter
  33338. */
  33339. constructor();
  33340. /**
  33341. * Call this method to start monitoring a new frame.
  33342. * 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.
  33343. */
  33344. fetchNewFrame(): void;
  33345. /**
  33346. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33347. * @param newCount the count value to add to the monitored count
  33348. * @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.
  33349. */
  33350. addCount(newCount: number, fetchResult: boolean): void;
  33351. /**
  33352. * Start monitoring this performance counter
  33353. */
  33354. beginMonitoring(): void;
  33355. /**
  33356. * Compute the time lapsed since the previous beginMonitoring() call.
  33357. * @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
  33358. */
  33359. endMonitoring(newFrame?: boolean): void;
  33360. private _fetchResult;
  33361. private _startMonitoringTime;
  33362. private _min;
  33363. private _max;
  33364. private _average;
  33365. private _current;
  33366. private _totalValueCount;
  33367. private _totalAccumulated;
  33368. private _lastSecAverage;
  33369. private _lastSecAccumulated;
  33370. private _lastSecTime;
  33371. private _lastSecValueCount;
  33372. }
  33373. }
  33374. declare module BABYLON {
  33375. interface ThinEngine {
  33376. /**
  33377. * Sets alpha constants used by some alpha blending modes
  33378. * @param r defines the red component
  33379. * @param g defines the green component
  33380. * @param b defines the blue component
  33381. * @param a defines the alpha component
  33382. */
  33383. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33384. /**
  33385. * Sets the current alpha mode
  33386. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33387. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33388. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33389. */
  33390. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33391. /**
  33392. * Gets the current alpha mode
  33393. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33394. * @returns the current alpha mode
  33395. */
  33396. getAlphaMode(): number;
  33397. /**
  33398. * Sets the current alpha equation
  33399. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33400. */
  33401. setAlphaEquation(equation: number): void;
  33402. /**
  33403. * Gets the current alpha equation.
  33404. * @returns the current alpha equation
  33405. */
  33406. getAlphaEquation(): number;
  33407. }
  33408. }
  33409. declare module BABYLON {
  33410. /**
  33411. * Defines the interface used by display changed events
  33412. */
  33413. export interface IDisplayChangedEventArgs {
  33414. /** Gets the vrDisplay object (if any) */
  33415. vrDisplay: Nullable<any>;
  33416. /** Gets a boolean indicating if webVR is supported */
  33417. vrSupported: boolean;
  33418. }
  33419. /**
  33420. * Defines the interface used by objects containing a viewport (like a camera)
  33421. */
  33422. interface IViewportOwnerLike {
  33423. /**
  33424. * Gets or sets the viewport
  33425. */
  33426. viewport: IViewportLike;
  33427. }
  33428. /**
  33429. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33430. */
  33431. export class Engine extends ThinEngine {
  33432. /** Defines that alpha blending is disabled */
  33433. static readonly ALPHA_DISABLE: number;
  33434. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33435. static readonly ALPHA_ADD: number;
  33436. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33437. static readonly ALPHA_COMBINE: number;
  33438. /** Defines that alpha blending to DEST - SRC * DEST */
  33439. static readonly ALPHA_SUBTRACT: number;
  33440. /** Defines that alpha blending to SRC * DEST */
  33441. static readonly ALPHA_MULTIPLY: number;
  33442. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33443. static readonly ALPHA_MAXIMIZED: number;
  33444. /** Defines that alpha blending to SRC + DEST */
  33445. static readonly ALPHA_ONEONE: number;
  33446. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33447. static readonly ALPHA_PREMULTIPLIED: number;
  33448. /**
  33449. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33450. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33451. */
  33452. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33453. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33454. static readonly ALPHA_INTERPOLATE: number;
  33455. /**
  33456. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33457. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33458. */
  33459. static readonly ALPHA_SCREENMODE: number;
  33460. /** Defines that the ressource is not delayed*/
  33461. static readonly DELAYLOADSTATE_NONE: number;
  33462. /** Defines that the ressource was successfully delay loaded */
  33463. static readonly DELAYLOADSTATE_LOADED: number;
  33464. /** Defines that the ressource is currently delay loading */
  33465. static readonly DELAYLOADSTATE_LOADING: number;
  33466. /** Defines that the ressource is delayed and has not started loading */
  33467. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33469. static readonly NEVER: number;
  33470. /** 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 */
  33471. static readonly ALWAYS: number;
  33472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33473. static readonly LESS: number;
  33474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33475. static readonly EQUAL: number;
  33476. /** 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 */
  33477. static readonly LEQUAL: number;
  33478. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33479. static readonly GREATER: number;
  33480. /** 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 */
  33481. static readonly GEQUAL: number;
  33482. /** 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 */
  33483. static readonly NOTEQUAL: number;
  33484. /** Passed to stencilOperation to specify that stencil value must be kept */
  33485. static readonly KEEP: number;
  33486. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33487. static readonly REPLACE: number;
  33488. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33489. static readonly INCR: number;
  33490. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33491. static readonly DECR: number;
  33492. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33493. static readonly INVERT: number;
  33494. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33495. static readonly INCR_WRAP: number;
  33496. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33497. static readonly DECR_WRAP: number;
  33498. /** Texture is not repeating outside of 0..1 UVs */
  33499. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33500. /** Texture is repeating outside of 0..1 UVs */
  33501. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33502. /** Texture is repeating and mirrored */
  33503. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33504. /** ALPHA */
  33505. static readonly TEXTUREFORMAT_ALPHA: number;
  33506. /** LUMINANCE */
  33507. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33508. /** LUMINANCE_ALPHA */
  33509. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33510. /** RGB */
  33511. static readonly TEXTUREFORMAT_RGB: number;
  33512. /** RGBA */
  33513. static readonly TEXTUREFORMAT_RGBA: number;
  33514. /** RED */
  33515. static readonly TEXTUREFORMAT_RED: number;
  33516. /** RED (2nd reference) */
  33517. static readonly TEXTUREFORMAT_R: number;
  33518. /** RG */
  33519. static readonly TEXTUREFORMAT_RG: number;
  33520. /** RED_INTEGER */
  33521. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33522. /** RED_INTEGER (2nd reference) */
  33523. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33524. /** RG_INTEGER */
  33525. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33526. /** RGB_INTEGER */
  33527. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33528. /** RGBA_INTEGER */
  33529. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33530. /** UNSIGNED_BYTE */
  33531. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33532. /** UNSIGNED_BYTE (2nd reference) */
  33533. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33534. /** FLOAT */
  33535. static readonly TEXTURETYPE_FLOAT: number;
  33536. /** HALF_FLOAT */
  33537. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33538. /** BYTE */
  33539. static readonly TEXTURETYPE_BYTE: number;
  33540. /** SHORT */
  33541. static readonly TEXTURETYPE_SHORT: number;
  33542. /** UNSIGNED_SHORT */
  33543. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33544. /** INT */
  33545. static readonly TEXTURETYPE_INT: number;
  33546. /** UNSIGNED_INT */
  33547. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33548. /** UNSIGNED_SHORT_4_4_4_4 */
  33549. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33550. /** UNSIGNED_SHORT_5_5_5_1 */
  33551. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33552. /** UNSIGNED_SHORT_5_6_5 */
  33553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33554. /** UNSIGNED_INT_2_10_10_10_REV */
  33555. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33556. /** UNSIGNED_INT_24_8 */
  33557. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33558. /** UNSIGNED_INT_10F_11F_11F_REV */
  33559. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33560. /** UNSIGNED_INT_5_9_9_9_REV */
  33561. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33562. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33563. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33564. /** nearest is mag = nearest and min = nearest and mip = linear */
  33565. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33566. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33567. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33568. /** Trilinear is mag = linear and min = linear and mip = linear */
  33569. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33570. /** nearest is mag = nearest and min = nearest and mip = linear */
  33571. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33572. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33573. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33574. /** Trilinear is mag = linear and min = linear and mip = linear */
  33575. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33576. /** mag = nearest and min = nearest and mip = nearest */
  33577. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33578. /** mag = nearest and min = linear and mip = nearest */
  33579. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33580. /** mag = nearest and min = linear and mip = linear */
  33581. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33582. /** mag = nearest and min = linear and mip = none */
  33583. static readonly TEXTURE_NEAREST_LINEAR: number;
  33584. /** mag = nearest and min = nearest and mip = none */
  33585. static readonly TEXTURE_NEAREST_NEAREST: number;
  33586. /** mag = linear and min = nearest and mip = nearest */
  33587. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33588. /** mag = linear and min = nearest and mip = linear */
  33589. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33590. /** mag = linear and min = linear and mip = none */
  33591. static readonly TEXTURE_LINEAR_LINEAR: number;
  33592. /** mag = linear and min = nearest and mip = none */
  33593. static readonly TEXTURE_LINEAR_NEAREST: number;
  33594. /** Explicit coordinates mode */
  33595. static readonly TEXTURE_EXPLICIT_MODE: number;
  33596. /** Spherical coordinates mode */
  33597. static readonly TEXTURE_SPHERICAL_MODE: number;
  33598. /** Planar coordinates mode */
  33599. static readonly TEXTURE_PLANAR_MODE: number;
  33600. /** Cubic coordinates mode */
  33601. static readonly TEXTURE_CUBIC_MODE: number;
  33602. /** Projection coordinates mode */
  33603. static readonly TEXTURE_PROJECTION_MODE: number;
  33604. /** Skybox coordinates mode */
  33605. static readonly TEXTURE_SKYBOX_MODE: number;
  33606. /** Inverse Cubic coordinates mode */
  33607. static readonly TEXTURE_INVCUBIC_MODE: number;
  33608. /** Equirectangular coordinates mode */
  33609. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33610. /** Equirectangular Fixed coordinates mode */
  33611. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33612. /** Equirectangular Fixed Mirrored coordinates mode */
  33613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33614. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33615. static readonly SCALEMODE_FLOOR: number;
  33616. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33617. static readonly SCALEMODE_NEAREST: number;
  33618. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33619. static readonly SCALEMODE_CEILING: number;
  33620. /**
  33621. * Returns the current npm package of the sdk
  33622. */
  33623. static get NpmPackage(): string;
  33624. /**
  33625. * Returns the current version of the framework
  33626. */
  33627. static get Version(): string;
  33628. /** Gets the list of created engines */
  33629. static get Instances(): Engine[];
  33630. /**
  33631. * Gets the latest created engine
  33632. */
  33633. static get LastCreatedEngine(): Nullable<Engine>;
  33634. /**
  33635. * Gets the latest created scene
  33636. */
  33637. static get LastCreatedScene(): Nullable<Scene>;
  33638. /**
  33639. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33640. * @param flag defines which part of the materials must be marked as dirty
  33641. * @param predicate defines a predicate used to filter which materials should be affected
  33642. */
  33643. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33644. /**
  33645. * Method called to create the default loading screen.
  33646. * This can be overriden in your own app.
  33647. * @param canvas The rendering canvas element
  33648. * @returns The loading screen
  33649. */
  33650. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33651. /**
  33652. * Method called to create the default rescale post process on each engine.
  33653. */
  33654. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33655. /**
  33656. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33657. **/
  33658. enableOfflineSupport: boolean;
  33659. /**
  33660. * 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)
  33661. **/
  33662. disableManifestCheck: boolean;
  33663. /**
  33664. * Gets the list of created scenes
  33665. */
  33666. scenes: Scene[];
  33667. /**
  33668. * Event raised when a new scene is created
  33669. */
  33670. onNewSceneAddedObservable: Observable<Scene>;
  33671. /**
  33672. * Gets the list of created postprocesses
  33673. */
  33674. postProcesses: PostProcess[];
  33675. /**
  33676. * Gets a boolean indicating if the pointer is currently locked
  33677. */
  33678. isPointerLock: boolean;
  33679. /**
  33680. * Observable event triggered each time the rendering canvas is resized
  33681. */
  33682. onResizeObservable: Observable<Engine>;
  33683. /**
  33684. * Observable event triggered each time the canvas loses focus
  33685. */
  33686. onCanvasBlurObservable: Observable<Engine>;
  33687. /**
  33688. * Observable event triggered each time the canvas gains focus
  33689. */
  33690. onCanvasFocusObservable: Observable<Engine>;
  33691. /**
  33692. * Observable event triggered each time the canvas receives pointerout event
  33693. */
  33694. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33695. /**
  33696. * Observable raised when the engine begins a new frame
  33697. */
  33698. onBeginFrameObservable: Observable<Engine>;
  33699. /**
  33700. * If set, will be used to request the next animation frame for the render loop
  33701. */
  33702. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33703. /**
  33704. * Observable raised when the engine ends the current frame
  33705. */
  33706. onEndFrameObservable: Observable<Engine>;
  33707. /**
  33708. * Observable raised when the engine is about to compile a shader
  33709. */
  33710. onBeforeShaderCompilationObservable: Observable<Engine>;
  33711. /**
  33712. * Observable raised when the engine has jsut compiled a shader
  33713. */
  33714. onAfterShaderCompilationObservable: Observable<Engine>;
  33715. /**
  33716. * Gets the audio engine
  33717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33718. * @ignorenaming
  33719. */
  33720. static audioEngine: IAudioEngine;
  33721. /**
  33722. * Default AudioEngine factory responsible of creating the Audio Engine.
  33723. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33724. */
  33725. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33726. /**
  33727. * Default offline support factory responsible of creating a tool used to store data locally.
  33728. * By default, this will create a Database object if the workload has been embedded.
  33729. */
  33730. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33731. private _loadingScreen;
  33732. private _pointerLockRequested;
  33733. private _dummyFramebuffer;
  33734. private _rescalePostProcess;
  33735. private _deterministicLockstep;
  33736. private _lockstepMaxSteps;
  33737. private _timeStep;
  33738. protected get _supportsHardwareTextureRescaling(): boolean;
  33739. private _fps;
  33740. private _deltaTime;
  33741. /** @hidden */
  33742. _drawCalls: PerfCounter;
  33743. /** 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 */
  33744. canvasTabIndex: number;
  33745. /**
  33746. * Turn this value on if you want to pause FPS computation when in background
  33747. */
  33748. disablePerformanceMonitorInBackground: boolean;
  33749. private _performanceMonitor;
  33750. /**
  33751. * Gets the performance monitor attached to this engine
  33752. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33753. */
  33754. get performanceMonitor(): PerformanceMonitor;
  33755. private _onFocus;
  33756. private _onBlur;
  33757. private _onCanvasPointerOut;
  33758. private _onCanvasBlur;
  33759. private _onCanvasFocus;
  33760. private _onFullscreenChange;
  33761. private _onPointerLockChange;
  33762. /**
  33763. * Gets the HTML element used to attach event listeners
  33764. * @returns a HTML element
  33765. */
  33766. getInputElement(): Nullable<HTMLElement>;
  33767. /**
  33768. * Creates a new engine
  33769. * @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
  33770. * @param antialias defines enable antialiasing (default: false)
  33771. * @param options defines further options to be sent to the getContext() function
  33772. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33773. */
  33774. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33775. /**
  33776. * Gets current aspect ratio
  33777. * @param viewportOwner defines the camera to use to get the aspect ratio
  33778. * @param useScreen defines if screen size must be used (or the current render target if any)
  33779. * @returns a number defining the aspect ratio
  33780. */
  33781. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33782. /**
  33783. * Gets current screen aspect ratio
  33784. * @returns a number defining the aspect ratio
  33785. */
  33786. getScreenAspectRatio(): number;
  33787. /**
  33788. * Gets the client rect of the HTML canvas attached with the current webGL context
  33789. * @returns a client rectanglee
  33790. */
  33791. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33792. /**
  33793. * Gets the client rect of the HTML element used for events
  33794. * @returns a client rectanglee
  33795. */
  33796. getInputElementClientRect(): Nullable<ClientRect>;
  33797. /**
  33798. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33799. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33800. * @returns true if engine is in deterministic lock step mode
  33801. */
  33802. isDeterministicLockStep(): boolean;
  33803. /**
  33804. * Gets the max steps when engine is running in deterministic lock step
  33805. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33806. * @returns the max steps
  33807. */
  33808. getLockstepMaxSteps(): number;
  33809. /**
  33810. * Returns the time in ms between steps when using deterministic lock step.
  33811. * @returns time step in (ms)
  33812. */
  33813. getTimeStep(): number;
  33814. /**
  33815. * Force the mipmap generation for the given render target texture
  33816. * @param texture defines the render target texture to use
  33817. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33818. */
  33819. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33820. /** States */
  33821. /**
  33822. * Set various states to the webGL context
  33823. * @param culling defines backface culling state
  33824. * @param zOffset defines the value to apply to zOffset (0 by default)
  33825. * @param force defines if states must be applied even if cache is up to date
  33826. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33827. */
  33828. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33829. /**
  33830. * Set the z offset to apply to current rendering
  33831. * @param value defines the offset to apply
  33832. */
  33833. setZOffset(value: number): void;
  33834. /**
  33835. * Gets the current value of the zOffset
  33836. * @returns the current zOffset state
  33837. */
  33838. getZOffset(): number;
  33839. /**
  33840. * Enable or disable depth buffering
  33841. * @param enable defines the state to set
  33842. */
  33843. setDepthBuffer(enable: boolean): void;
  33844. /**
  33845. * Gets a boolean indicating if depth writing is enabled
  33846. * @returns the current depth writing state
  33847. */
  33848. getDepthWrite(): boolean;
  33849. /**
  33850. * Enable or disable depth writing
  33851. * @param enable defines the state to set
  33852. */
  33853. setDepthWrite(enable: boolean): void;
  33854. /**
  33855. * Gets a boolean indicating if stencil buffer is enabled
  33856. * @returns the current stencil buffer state
  33857. */
  33858. getStencilBuffer(): boolean;
  33859. /**
  33860. * Enable or disable the stencil buffer
  33861. * @param enable defines if the stencil buffer must be enabled or disabled
  33862. */
  33863. setStencilBuffer(enable: boolean): void;
  33864. /**
  33865. * Gets the current stencil mask
  33866. * @returns a number defining the new stencil mask to use
  33867. */
  33868. getStencilMask(): number;
  33869. /**
  33870. * Sets the current stencil mask
  33871. * @param mask defines the new stencil mask to use
  33872. */
  33873. setStencilMask(mask: number): void;
  33874. /**
  33875. * Gets the current stencil function
  33876. * @returns a number defining the stencil function to use
  33877. */
  33878. getStencilFunction(): number;
  33879. /**
  33880. * Gets the current stencil reference value
  33881. * @returns a number defining the stencil reference value to use
  33882. */
  33883. getStencilFunctionReference(): number;
  33884. /**
  33885. * Gets the current stencil mask
  33886. * @returns a number defining the stencil mask to use
  33887. */
  33888. getStencilFunctionMask(): number;
  33889. /**
  33890. * Sets the current stencil function
  33891. * @param stencilFunc defines the new stencil function to use
  33892. */
  33893. setStencilFunction(stencilFunc: number): void;
  33894. /**
  33895. * Sets the current stencil reference
  33896. * @param reference defines the new stencil reference to use
  33897. */
  33898. setStencilFunctionReference(reference: number): void;
  33899. /**
  33900. * Sets the current stencil mask
  33901. * @param mask defines the new stencil mask to use
  33902. */
  33903. setStencilFunctionMask(mask: number): void;
  33904. /**
  33905. * Gets the current stencil operation when stencil fails
  33906. * @returns a number defining stencil operation to use when stencil fails
  33907. */
  33908. getStencilOperationFail(): number;
  33909. /**
  33910. * Gets the current stencil operation when depth fails
  33911. * @returns a number defining stencil operation to use when depth fails
  33912. */
  33913. getStencilOperationDepthFail(): number;
  33914. /**
  33915. * Gets the current stencil operation when stencil passes
  33916. * @returns a number defining stencil operation to use when stencil passes
  33917. */
  33918. getStencilOperationPass(): number;
  33919. /**
  33920. * Sets the stencil operation to use when stencil fails
  33921. * @param operation defines the stencil operation to use when stencil fails
  33922. */
  33923. setStencilOperationFail(operation: number): void;
  33924. /**
  33925. * Sets the stencil operation to use when depth fails
  33926. * @param operation defines the stencil operation to use when depth fails
  33927. */
  33928. setStencilOperationDepthFail(operation: number): void;
  33929. /**
  33930. * Sets the stencil operation to use when stencil passes
  33931. * @param operation defines the stencil operation to use when stencil passes
  33932. */
  33933. setStencilOperationPass(operation: number): void;
  33934. /**
  33935. * Sets a boolean indicating if the dithering state is enabled or disabled
  33936. * @param value defines the dithering state
  33937. */
  33938. setDitheringState(value: boolean): void;
  33939. /**
  33940. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33941. * @param value defines the rasterizer state
  33942. */
  33943. setRasterizerState(value: boolean): void;
  33944. /**
  33945. * Gets the current depth function
  33946. * @returns a number defining the depth function
  33947. */
  33948. getDepthFunction(): Nullable<number>;
  33949. /**
  33950. * Sets the current depth function
  33951. * @param depthFunc defines the function to use
  33952. */
  33953. setDepthFunction(depthFunc: number): void;
  33954. /**
  33955. * Sets the current depth function to GREATER
  33956. */
  33957. setDepthFunctionToGreater(): void;
  33958. /**
  33959. * Sets the current depth function to GEQUAL
  33960. */
  33961. setDepthFunctionToGreaterOrEqual(): void;
  33962. /**
  33963. * Sets the current depth function to LESS
  33964. */
  33965. setDepthFunctionToLess(): void;
  33966. /**
  33967. * Sets the current depth function to LEQUAL
  33968. */
  33969. setDepthFunctionToLessOrEqual(): void;
  33970. private _cachedStencilBuffer;
  33971. private _cachedStencilFunction;
  33972. private _cachedStencilMask;
  33973. private _cachedStencilOperationPass;
  33974. private _cachedStencilOperationFail;
  33975. private _cachedStencilOperationDepthFail;
  33976. private _cachedStencilReference;
  33977. /**
  33978. * Caches the the state of the stencil buffer
  33979. */
  33980. cacheStencilState(): void;
  33981. /**
  33982. * Restores the state of the stencil buffer
  33983. */
  33984. restoreStencilState(): void;
  33985. /**
  33986. * Directly set the WebGL Viewport
  33987. * @param x defines the x coordinate of the viewport (in screen space)
  33988. * @param y defines the y coordinate of the viewport (in screen space)
  33989. * @param width defines the width of the viewport (in screen space)
  33990. * @param height defines the height of the viewport (in screen space)
  33991. * @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
  33992. */
  33993. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33994. /**
  33995. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33996. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33997. * @param y defines the y-coordinate of the corner of the clear rectangle
  33998. * @param width defines the width of the clear rectangle
  33999. * @param height defines the height of the clear rectangle
  34000. * @param clearColor defines the clear color
  34001. */
  34002. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34003. /**
  34004. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34005. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34006. * @param y defines the y-coordinate of the corner of the clear rectangle
  34007. * @param width defines the width of the clear rectangle
  34008. * @param height defines the height of the clear rectangle
  34009. */
  34010. enableScissor(x: number, y: number, width: number, height: number): void;
  34011. /**
  34012. * Disable previously set scissor test rectangle
  34013. */
  34014. disableScissor(): void;
  34015. protected _reportDrawCall(): void;
  34016. /**
  34017. * Initializes a webVR display and starts listening to display change events
  34018. * The onVRDisplayChangedObservable will be notified upon these changes
  34019. * @returns The onVRDisplayChangedObservable
  34020. */
  34021. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34022. /** @hidden */
  34023. _prepareVRComponent(): void;
  34024. /** @hidden */
  34025. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34026. /** @hidden */
  34027. _submitVRFrame(): void;
  34028. /**
  34029. * Call this function to leave webVR mode
  34030. * Will do nothing if webVR is not supported or if there is no webVR device
  34031. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34032. */
  34033. disableVR(): void;
  34034. /**
  34035. * Gets a boolean indicating that the system is in VR mode and is presenting
  34036. * @returns true if VR mode is engaged
  34037. */
  34038. isVRPresenting(): boolean;
  34039. /** @hidden */
  34040. _requestVRFrame(): void;
  34041. /** @hidden */
  34042. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34043. /**
  34044. * Gets the source code of the vertex shader associated with a specific webGL program
  34045. * @param program defines the program to use
  34046. * @returns a string containing the source code of the vertex shader associated with the program
  34047. */
  34048. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34049. /**
  34050. * Gets the source code of the fragment shader associated with a specific webGL program
  34051. * @param program defines the program to use
  34052. * @returns a string containing the source code of the fragment shader associated with the program
  34053. */
  34054. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34055. /**
  34056. * Sets a depth stencil texture from a render target to the according uniform.
  34057. * @param channel The texture channel
  34058. * @param uniform The uniform to set
  34059. * @param texture The render target texture containing the depth stencil texture to apply
  34060. */
  34061. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34062. /**
  34063. * Sets a texture to the webGL context from a postprocess
  34064. * @param channel defines the channel to use
  34065. * @param postProcess defines the source postprocess
  34066. */
  34067. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34068. /**
  34069. * Binds the output of the passed in post process to the texture channel specified
  34070. * @param channel The channel the texture should be bound to
  34071. * @param postProcess The post process which's output should be bound
  34072. */
  34073. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34074. /** @hidden */
  34075. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34076. protected _rebuildBuffers(): void;
  34077. /** @hidden */
  34078. _renderFrame(): void;
  34079. _renderLoop(): void;
  34080. /** @hidden */
  34081. _renderViews(): boolean;
  34082. /**
  34083. * Toggle full screen mode
  34084. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34085. */
  34086. switchFullscreen(requestPointerLock: boolean): void;
  34087. /**
  34088. * Enters full screen mode
  34089. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34090. */
  34091. enterFullscreen(requestPointerLock: boolean): void;
  34092. /**
  34093. * Exits full screen mode
  34094. */
  34095. exitFullscreen(): void;
  34096. /**
  34097. * Enters Pointerlock mode
  34098. */
  34099. enterPointerlock(): void;
  34100. /**
  34101. * Exits Pointerlock mode
  34102. */
  34103. exitPointerlock(): void;
  34104. /**
  34105. * Begin a new frame
  34106. */
  34107. beginFrame(): void;
  34108. /**
  34109. * Enf the current frame
  34110. */
  34111. endFrame(): void;
  34112. resize(): void;
  34113. /**
  34114. * Force a specific size of the canvas
  34115. * @param width defines the new canvas' width
  34116. * @param height defines the new canvas' height
  34117. */
  34118. setSize(width: number, height: number): void;
  34119. /**
  34120. * Updates a dynamic vertex buffer.
  34121. * @param vertexBuffer the vertex buffer to update
  34122. * @param data the data used to update the vertex buffer
  34123. * @param byteOffset the byte offset of the data
  34124. * @param byteLength the byte length of the data
  34125. */
  34126. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34127. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34128. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34129. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34130. _releaseTexture(texture: InternalTexture): void;
  34131. /**
  34132. * @hidden
  34133. * Rescales a texture
  34134. * @param source input texutre
  34135. * @param destination destination texture
  34136. * @param scene scene to use to render the resize
  34137. * @param internalFormat format to use when resizing
  34138. * @param onComplete callback to be called when resize has completed
  34139. */
  34140. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34141. /**
  34142. * Gets the current framerate
  34143. * @returns a number representing the framerate
  34144. */
  34145. getFps(): number;
  34146. /**
  34147. * Gets the time spent between current and previous frame
  34148. * @returns a number representing the delta time in ms
  34149. */
  34150. getDeltaTime(): number;
  34151. private _measureFps;
  34152. /** @hidden */
  34153. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34154. /**
  34155. * Update a dynamic index buffer
  34156. * @param indexBuffer defines the target index buffer
  34157. * @param indices defines the data to update
  34158. * @param offset defines the offset in the target index buffer where update should start
  34159. */
  34160. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34161. /**
  34162. * Updates the sample count of a render target texture
  34163. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34164. * @param texture defines the texture to update
  34165. * @param samples defines the sample count to set
  34166. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34167. */
  34168. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34169. /**
  34170. * Updates a depth texture Comparison Mode and Function.
  34171. * If the comparison Function is equal to 0, the mode will be set to none.
  34172. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34173. * @param texture The texture to set the comparison function for
  34174. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34175. */
  34176. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34177. /**
  34178. * Creates a webGL buffer to use with instanciation
  34179. * @param capacity defines the size of the buffer
  34180. * @returns the webGL buffer
  34181. */
  34182. createInstancesBuffer(capacity: number): DataBuffer;
  34183. /**
  34184. * Delete a webGL buffer used with instanciation
  34185. * @param buffer defines the webGL buffer to delete
  34186. */
  34187. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34188. private _clientWaitAsync;
  34189. /** @hidden */
  34190. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34191. /** @hidden */
  34192. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34193. dispose(): void;
  34194. private _disableTouchAction;
  34195. /**
  34196. * Display the loading screen
  34197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34198. */
  34199. displayLoadingUI(): void;
  34200. /**
  34201. * Hide the loading screen
  34202. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34203. */
  34204. hideLoadingUI(): void;
  34205. /**
  34206. * Gets the current loading screen object
  34207. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34208. */
  34209. get loadingScreen(): ILoadingScreen;
  34210. /**
  34211. * Sets the current loading screen object
  34212. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34213. */
  34214. set loadingScreen(loadingScreen: ILoadingScreen);
  34215. /**
  34216. * Sets the current loading screen text
  34217. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34218. */
  34219. set loadingUIText(text: string);
  34220. /**
  34221. * Sets the current loading screen background color
  34222. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34223. */
  34224. set loadingUIBackgroundColor(color: string);
  34225. /** Pointerlock and fullscreen */
  34226. /**
  34227. * Ask the browser to promote the current element to pointerlock mode
  34228. * @param element defines the DOM element to promote
  34229. */
  34230. static _RequestPointerlock(element: HTMLElement): void;
  34231. /**
  34232. * Asks the browser to exit pointerlock mode
  34233. */
  34234. static _ExitPointerlock(): void;
  34235. /**
  34236. * Ask the browser to promote the current element to fullscreen rendering mode
  34237. * @param element defines the DOM element to promote
  34238. */
  34239. static _RequestFullscreen(element: HTMLElement): void;
  34240. /**
  34241. * Asks the browser to exit fullscreen mode
  34242. */
  34243. static _ExitFullscreen(): void;
  34244. }
  34245. }
  34246. declare module BABYLON {
  34247. /**
  34248. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34249. * during the life time of the application.
  34250. */
  34251. export class EngineStore {
  34252. /** Gets the list of created engines */
  34253. static Instances: Engine[];
  34254. /** @hidden */
  34255. static _LastCreatedScene: Nullable<Scene>;
  34256. /**
  34257. * Gets the latest created engine
  34258. */
  34259. static get LastCreatedEngine(): Nullable<Engine>;
  34260. /**
  34261. * Gets the latest created scene
  34262. */
  34263. static get LastCreatedScene(): Nullable<Scene>;
  34264. /**
  34265. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34266. * @ignorenaming
  34267. */
  34268. static UseFallbackTexture: boolean;
  34269. /**
  34270. * Texture content used if a texture cannot loaded
  34271. * @ignorenaming
  34272. */
  34273. static FallbackTexture: string;
  34274. }
  34275. }
  34276. declare module BABYLON {
  34277. /**
  34278. * Helper class that provides a small promise polyfill
  34279. */
  34280. export class PromisePolyfill {
  34281. /**
  34282. * Static function used to check if the polyfill is required
  34283. * If this is the case then the function will inject the polyfill to window.Promise
  34284. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34285. */
  34286. static Apply(force?: boolean): void;
  34287. }
  34288. }
  34289. declare module BABYLON {
  34290. /**
  34291. * Interface for screenshot methods with describe argument called `size` as object with options
  34292. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34293. */
  34294. export interface IScreenshotSize {
  34295. /**
  34296. * number in pixels for canvas height
  34297. */
  34298. height?: number;
  34299. /**
  34300. * multiplier allowing render at a higher or lower resolution
  34301. * If value is defined then height and width will be ignored and taken from camera
  34302. */
  34303. precision?: number;
  34304. /**
  34305. * number in pixels for canvas width
  34306. */
  34307. width?: number;
  34308. }
  34309. }
  34310. declare module BABYLON {
  34311. interface IColor4Like {
  34312. r: float;
  34313. g: float;
  34314. b: float;
  34315. a: float;
  34316. }
  34317. /**
  34318. * Class containing a set of static utilities functions
  34319. */
  34320. export class Tools {
  34321. /**
  34322. * Gets or sets the base URL to use to load assets
  34323. */
  34324. static get BaseUrl(): string;
  34325. static set BaseUrl(value: string);
  34326. /**
  34327. * Enable/Disable Custom HTTP Request Headers globally.
  34328. * default = false
  34329. * @see CustomRequestHeaders
  34330. */
  34331. static UseCustomRequestHeaders: boolean;
  34332. /**
  34333. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34334. * i.e. when loading files, where the server/service expects an Authorization header
  34335. */
  34336. static CustomRequestHeaders: {
  34337. [key: string]: string;
  34338. };
  34339. /**
  34340. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34341. */
  34342. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34343. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34344. /**
  34345. * Default behaviour for cors in the application.
  34346. * It can be a string if the expected behavior is identical in the entire app.
  34347. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34348. */
  34349. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34350. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34351. /**
  34352. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34353. * @ignorenaming
  34354. */
  34355. static get UseFallbackTexture(): boolean;
  34356. static set UseFallbackTexture(value: boolean);
  34357. /**
  34358. * Use this object to register external classes like custom textures or material
  34359. * to allow the laoders to instantiate them
  34360. */
  34361. static get RegisteredExternalClasses(): {
  34362. [key: string]: Object;
  34363. };
  34364. static set RegisteredExternalClasses(classes: {
  34365. [key: string]: Object;
  34366. });
  34367. /**
  34368. * Texture content used if a texture cannot loaded
  34369. * @ignorenaming
  34370. */
  34371. static get fallbackTexture(): string;
  34372. static set fallbackTexture(value: string);
  34373. /**
  34374. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34375. * @param u defines the coordinate on X axis
  34376. * @param v defines the coordinate on Y axis
  34377. * @param width defines the width of the source data
  34378. * @param height defines the height of the source data
  34379. * @param pixels defines the source byte array
  34380. * @param color defines the output color
  34381. */
  34382. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34383. /**
  34384. * Interpolates between a and b via alpha
  34385. * @param a The lower value (returned when alpha = 0)
  34386. * @param b The upper value (returned when alpha = 1)
  34387. * @param alpha The interpolation-factor
  34388. * @return The mixed value
  34389. */
  34390. static Mix(a: number, b: number, alpha: number): number;
  34391. /**
  34392. * Tries to instantiate a new object from a given class name
  34393. * @param className defines the class name to instantiate
  34394. * @returns the new object or null if the system was not able to do the instantiation
  34395. */
  34396. static Instantiate(className: string): any;
  34397. /**
  34398. * Provides a slice function that will work even on IE
  34399. * @param data defines the array to slice
  34400. * @param start defines the start of the data (optional)
  34401. * @param end defines the end of the data (optional)
  34402. * @returns the new sliced array
  34403. */
  34404. static Slice<T>(data: T, start?: number, end?: number): T;
  34405. /**
  34406. * Polyfill for setImmediate
  34407. * @param action defines the action to execute after the current execution block
  34408. */
  34409. static SetImmediate(action: () => void): void;
  34410. /**
  34411. * Function indicating if a number is an exponent of 2
  34412. * @param value defines the value to test
  34413. * @returns true if the value is an exponent of 2
  34414. */
  34415. static IsExponentOfTwo(value: number): boolean;
  34416. private static _tmpFloatArray;
  34417. /**
  34418. * Returns the nearest 32-bit single precision float representation of a Number
  34419. * @param value A Number. If the parameter is of a different type, it will get converted
  34420. * to a number or to NaN if it cannot be converted
  34421. * @returns number
  34422. */
  34423. static FloatRound(value: number): number;
  34424. /**
  34425. * Extracts the filename from a path
  34426. * @param path defines the path to use
  34427. * @returns the filename
  34428. */
  34429. static GetFilename(path: string): string;
  34430. /**
  34431. * Extracts the "folder" part of a path (everything before the filename).
  34432. * @param uri The URI to extract the info from
  34433. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34434. * @returns The "folder" part of the path
  34435. */
  34436. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34437. /**
  34438. * Extracts text content from a DOM element hierarchy
  34439. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34440. */
  34441. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34442. /**
  34443. * Convert an angle in radians to degrees
  34444. * @param angle defines the angle to convert
  34445. * @returns the angle in degrees
  34446. */
  34447. static ToDegrees(angle: number): number;
  34448. /**
  34449. * Convert an angle in degrees to radians
  34450. * @param angle defines the angle to convert
  34451. * @returns the angle in radians
  34452. */
  34453. static ToRadians(angle: number): number;
  34454. /**
  34455. * Returns an array if obj is not an array
  34456. * @param obj defines the object to evaluate as an array
  34457. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34458. * @returns either obj directly if obj is an array or a new array containing obj
  34459. */
  34460. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34461. /**
  34462. * Gets the pointer prefix to use
  34463. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34464. */
  34465. static GetPointerPrefix(): string;
  34466. /**
  34467. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34468. * @param url define the url we are trying
  34469. * @param element define the dom element where to configure the cors policy
  34470. */
  34471. static SetCorsBehavior(url: string | string[], element: {
  34472. crossOrigin: string | null;
  34473. }): void;
  34474. /**
  34475. * Removes unwanted characters from an url
  34476. * @param url defines the url to clean
  34477. * @returns the cleaned url
  34478. */
  34479. static CleanUrl(url: string): string;
  34480. /**
  34481. * Gets or sets a function used to pre-process url before using them to load assets
  34482. */
  34483. static get PreprocessUrl(): (url: string) => string;
  34484. static set PreprocessUrl(processor: (url: string) => string);
  34485. /**
  34486. * Loads an image as an HTMLImageElement.
  34487. * @param input url string, ArrayBuffer, or Blob to load
  34488. * @param onLoad callback called when the image successfully loads
  34489. * @param onError callback called when the image fails to load
  34490. * @param offlineProvider offline provider for caching
  34491. * @param mimeType optional mime type
  34492. * @returns the HTMLImageElement of the loaded image
  34493. */
  34494. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34495. /**
  34496. * Loads a file from a url
  34497. * @param url url string, ArrayBuffer, or Blob to load
  34498. * @param onSuccess callback called when the file successfully loads
  34499. * @param onProgress callback called while file is loading (if the server supports this mode)
  34500. * @param offlineProvider defines the offline provider for caching
  34501. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34502. * @param onError callback called when the file fails to load
  34503. * @returns a file request object
  34504. */
  34505. 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;
  34506. /**
  34507. * Loads a file from a url
  34508. * @param url the file url to load
  34509. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34510. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34511. */
  34512. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34513. /**
  34514. * Load a script (identified by an url). When the url returns, the
  34515. * content of this file is added into a new script element, attached to the DOM (body element)
  34516. * @param scriptUrl defines the url of the script to laod
  34517. * @param onSuccess defines the callback called when the script is loaded
  34518. * @param onError defines the callback to call if an error occurs
  34519. * @param scriptId defines the id of the script element
  34520. */
  34521. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34522. /**
  34523. * Load an asynchronous script (identified by an url). When the url returns, the
  34524. * content of this file is added into a new script element, attached to the DOM (body element)
  34525. * @param scriptUrl defines the url of the script to laod
  34526. * @param scriptId defines the id of the script element
  34527. * @returns a promise request object
  34528. */
  34529. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34530. /**
  34531. * Loads a file from a blob
  34532. * @param fileToLoad defines the blob to use
  34533. * @param callback defines the callback to call when data is loaded
  34534. * @param progressCallback defines the callback to call during loading process
  34535. * @returns a file request object
  34536. */
  34537. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34538. /**
  34539. * Reads a file from a File object
  34540. * @param file defines the file to load
  34541. * @param onSuccess defines the callback to call when data is loaded
  34542. * @param onProgress defines the callback to call during loading process
  34543. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34544. * @param onError defines the callback to call when an error occurs
  34545. * @returns a file request object
  34546. */
  34547. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34548. /**
  34549. * Creates a data url from a given string content
  34550. * @param content defines the content to convert
  34551. * @returns the new data url link
  34552. */
  34553. static FileAsURL(content: string): string;
  34554. /**
  34555. * Format the given number to a specific decimal format
  34556. * @param value defines the number to format
  34557. * @param decimals defines the number of decimals to use
  34558. * @returns the formatted string
  34559. */
  34560. static Format(value: number, decimals?: number): string;
  34561. /**
  34562. * Tries to copy an object by duplicating every property
  34563. * @param source defines the source object
  34564. * @param destination defines the target object
  34565. * @param doNotCopyList defines a list of properties to avoid
  34566. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34567. */
  34568. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34569. /**
  34570. * Gets a boolean indicating if the given object has no own property
  34571. * @param obj defines the object to test
  34572. * @returns true if object has no own property
  34573. */
  34574. static IsEmpty(obj: any): boolean;
  34575. /**
  34576. * Function used to register events at window level
  34577. * @param windowElement defines the Window object to use
  34578. * @param events defines the events to register
  34579. */
  34580. static RegisterTopRootEvents(windowElement: Window, events: {
  34581. name: string;
  34582. handler: Nullable<(e: FocusEvent) => any>;
  34583. }[]): void;
  34584. /**
  34585. * Function used to unregister events from window level
  34586. * @param windowElement defines the Window object to use
  34587. * @param events defines the events to unregister
  34588. */
  34589. static UnregisterTopRootEvents(windowElement: Window, events: {
  34590. name: string;
  34591. handler: Nullable<(e: FocusEvent) => any>;
  34592. }[]): void;
  34593. /**
  34594. * @ignore
  34595. */
  34596. static _ScreenshotCanvas: HTMLCanvasElement;
  34597. /**
  34598. * Dumps the current bound framebuffer
  34599. * @param width defines the rendering width
  34600. * @param height defines the rendering height
  34601. * @param engine defines the hosting engine
  34602. * @param successCallback defines the callback triggered once the data are available
  34603. * @param mimeType defines the mime type of the result
  34604. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34605. */
  34606. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34607. /**
  34608. * Converts the canvas data to blob.
  34609. * This acts as a polyfill for browsers not supporting the to blob function.
  34610. * @param canvas Defines the canvas to extract the data from
  34611. * @param successCallback Defines the callback triggered once the data are available
  34612. * @param mimeType Defines the mime type of the result
  34613. */
  34614. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34615. /**
  34616. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34617. * @param successCallback defines the callback triggered once the data are available
  34618. * @param mimeType defines the mime type of the result
  34619. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34620. */
  34621. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34622. /**
  34623. * Downloads a blob in the browser
  34624. * @param blob defines the blob to download
  34625. * @param fileName defines the name of the downloaded file
  34626. */
  34627. static Download(blob: Blob, fileName: string): void;
  34628. /**
  34629. * Captures a screenshot of the current rendering
  34630. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34631. * @param engine defines the rendering engine
  34632. * @param camera defines the source camera
  34633. * @param size This parameter can be set to a single number or to an object with the
  34634. * following (optional) properties: precision, width, height. If a single number is passed,
  34635. * it will be used for both width and height. If an object is passed, the screenshot size
  34636. * will be derived from the parameters. The precision property is a multiplier allowing
  34637. * rendering at a higher or lower resolution
  34638. * @param successCallback defines the callback receives a single parameter which contains the
  34639. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34640. * src parameter of an <img> to display it
  34641. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34642. * Check your browser for supported MIME types
  34643. */
  34644. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34645. /**
  34646. * Captures a screenshot of the current rendering
  34647. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34648. * @param engine defines the rendering engine
  34649. * @param camera defines the source camera
  34650. * @param size This parameter can be set to a single number or to an object with the
  34651. * following (optional) properties: precision, width, height. If a single number is passed,
  34652. * it will be used for both width and height. If an object is passed, the screenshot size
  34653. * will be derived from the parameters. The precision property is a multiplier allowing
  34654. * rendering at a higher or lower resolution
  34655. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34656. * Check your browser for supported MIME types
  34657. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34658. * to the src parameter of an <img> to display it
  34659. */
  34660. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34661. /**
  34662. * Generates an image screenshot from the specified camera.
  34663. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34664. * @param engine The engine to use for rendering
  34665. * @param camera The camera to use for rendering
  34666. * @param size This parameter can be set to a single number or to an object with the
  34667. * following (optional) properties: precision, width, height. If a single number is passed,
  34668. * it will be used for both width and height. If an object is passed, the screenshot size
  34669. * will be derived from the parameters. The precision property is a multiplier allowing
  34670. * rendering at a higher or lower resolution
  34671. * @param successCallback The callback receives a single parameter which contains the
  34672. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34673. * src parameter of an <img> to display it
  34674. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34675. * Check your browser for supported MIME types
  34676. * @param samples Texture samples (default: 1)
  34677. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34678. * @param fileName A name for for the downloaded file.
  34679. */
  34680. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34681. /**
  34682. * Generates an image screenshot from the specified camera.
  34683. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34684. * @param engine The engine to use for rendering
  34685. * @param camera The camera to use for rendering
  34686. * @param size This parameter can be set to a single number or to an object with the
  34687. * following (optional) properties: precision, width, height. If a single number is passed,
  34688. * it will be used for both width and height. If an object is passed, the screenshot size
  34689. * will be derived from the parameters. The precision property is a multiplier allowing
  34690. * rendering at a higher or lower resolution
  34691. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34692. * Check your browser for supported MIME types
  34693. * @param samples Texture samples (default: 1)
  34694. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34695. * @param fileName A name for for the downloaded file.
  34696. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34697. * to the src parameter of an <img> to display it
  34698. */
  34699. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34700. /**
  34701. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34702. * Be aware Math.random() could cause collisions, but:
  34703. * "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"
  34704. * @returns a pseudo random id
  34705. */
  34706. static RandomId(): string;
  34707. /**
  34708. * Test if the given uri is a base64 string
  34709. * @param uri The uri to test
  34710. * @return True if the uri is a base64 string or false otherwise
  34711. */
  34712. static IsBase64(uri: string): boolean;
  34713. /**
  34714. * Decode the given base64 uri.
  34715. * @param uri The uri to decode
  34716. * @return The decoded base64 data.
  34717. */
  34718. static DecodeBase64(uri: string): ArrayBuffer;
  34719. /**
  34720. * Gets the absolute url.
  34721. * @param url the input url
  34722. * @return the absolute url
  34723. */
  34724. static GetAbsoluteUrl(url: string): string;
  34725. /**
  34726. * No log
  34727. */
  34728. static readonly NoneLogLevel: number;
  34729. /**
  34730. * Only message logs
  34731. */
  34732. static readonly MessageLogLevel: number;
  34733. /**
  34734. * Only warning logs
  34735. */
  34736. static readonly WarningLogLevel: number;
  34737. /**
  34738. * Only error logs
  34739. */
  34740. static readonly ErrorLogLevel: number;
  34741. /**
  34742. * All logs
  34743. */
  34744. static readonly AllLogLevel: number;
  34745. /**
  34746. * Gets a value indicating the number of loading errors
  34747. * @ignorenaming
  34748. */
  34749. static get errorsCount(): number;
  34750. /**
  34751. * Callback called when a new log is added
  34752. */
  34753. static OnNewCacheEntry: (entry: string) => void;
  34754. /**
  34755. * Log a message to the console
  34756. * @param message defines the message to log
  34757. */
  34758. static Log(message: string): void;
  34759. /**
  34760. * Write a warning message to the console
  34761. * @param message defines the message to log
  34762. */
  34763. static Warn(message: string): void;
  34764. /**
  34765. * Write an error message to the console
  34766. * @param message defines the message to log
  34767. */
  34768. static Error(message: string): void;
  34769. /**
  34770. * Gets current log cache (list of logs)
  34771. */
  34772. static get LogCache(): string;
  34773. /**
  34774. * Clears the log cache
  34775. */
  34776. static ClearLogCache(): void;
  34777. /**
  34778. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34779. */
  34780. static set LogLevels(level: number);
  34781. /**
  34782. * Checks if the window object exists
  34783. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34784. */
  34785. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34786. /**
  34787. * No performance log
  34788. */
  34789. static readonly PerformanceNoneLogLevel: number;
  34790. /**
  34791. * Use user marks to log performance
  34792. */
  34793. static readonly PerformanceUserMarkLogLevel: number;
  34794. /**
  34795. * Log performance to the console
  34796. */
  34797. static readonly PerformanceConsoleLogLevel: number;
  34798. private static _performance;
  34799. /**
  34800. * Sets the current performance log level
  34801. */
  34802. static set PerformanceLogLevel(level: number);
  34803. private static _StartPerformanceCounterDisabled;
  34804. private static _EndPerformanceCounterDisabled;
  34805. private static _StartUserMark;
  34806. private static _EndUserMark;
  34807. private static _StartPerformanceConsole;
  34808. private static _EndPerformanceConsole;
  34809. /**
  34810. * Starts a performance counter
  34811. */
  34812. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34813. /**
  34814. * Ends a specific performance coutner
  34815. */
  34816. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34817. /**
  34818. * Gets either window.performance.now() if supported or Date.now() else
  34819. */
  34820. static get Now(): number;
  34821. /**
  34822. * This method will return the name of the class used to create the instance of the given object.
  34823. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34824. * @param object the object to get the class name from
  34825. * @param isType defines if the object is actually a type
  34826. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34827. */
  34828. static GetClassName(object: any, isType?: boolean): string;
  34829. /**
  34830. * Gets the first element of an array satisfying a given predicate
  34831. * @param array defines the array to browse
  34832. * @param predicate defines the predicate to use
  34833. * @returns null if not found or the element
  34834. */
  34835. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34836. /**
  34837. * This method will return the name of the full name of the class, including its owning module (if any).
  34838. * 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).
  34839. * @param object the object to get the class name from
  34840. * @param isType defines if the object is actually a type
  34841. * @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.
  34842. * @ignorenaming
  34843. */
  34844. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34845. /**
  34846. * Returns a promise that resolves after the given amount of time.
  34847. * @param delay Number of milliseconds to delay
  34848. * @returns Promise that resolves after the given amount of time
  34849. */
  34850. static DelayAsync(delay: number): Promise<void>;
  34851. /**
  34852. * Utility function to detect if the current user agent is Safari
  34853. * @returns whether or not the current user agent is safari
  34854. */
  34855. static IsSafari(): boolean;
  34856. }
  34857. /**
  34858. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34859. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34860. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34861. * @param name The name of the class, case should be preserved
  34862. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34863. */
  34864. export function className(name: string, module?: string): (target: Object) => void;
  34865. /**
  34866. * An implementation of a loop for asynchronous functions.
  34867. */
  34868. export class AsyncLoop {
  34869. /**
  34870. * Defines the number of iterations for the loop
  34871. */
  34872. iterations: number;
  34873. /**
  34874. * Defines the current index of the loop.
  34875. */
  34876. index: number;
  34877. private _done;
  34878. private _fn;
  34879. private _successCallback;
  34880. /**
  34881. * Constructor.
  34882. * @param iterations the number of iterations.
  34883. * @param func the function to run each iteration
  34884. * @param successCallback the callback that will be called upon succesful execution
  34885. * @param offset starting offset.
  34886. */
  34887. constructor(
  34888. /**
  34889. * Defines the number of iterations for the loop
  34890. */
  34891. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34892. /**
  34893. * Execute the next iteration. Must be called after the last iteration was finished.
  34894. */
  34895. executeNext(): void;
  34896. /**
  34897. * Break the loop and run the success callback.
  34898. */
  34899. breakLoop(): void;
  34900. /**
  34901. * Create and run an async loop.
  34902. * @param iterations the number of iterations.
  34903. * @param fn the function to run each iteration
  34904. * @param successCallback the callback that will be called upon succesful execution
  34905. * @param offset starting offset.
  34906. * @returns the created async loop object
  34907. */
  34908. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34909. /**
  34910. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34911. * @param iterations total number of iterations
  34912. * @param syncedIterations number of synchronous iterations in each async iteration.
  34913. * @param fn the function to call each iteration.
  34914. * @param callback a success call back that will be called when iterating stops.
  34915. * @param breakFunction a break condition (optional)
  34916. * @param timeout timeout settings for the setTimeout function. default - 0.
  34917. * @returns the created async loop object
  34918. */
  34919. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34920. }
  34921. }
  34922. declare module BABYLON {
  34923. /**
  34924. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34925. * The underlying implementation relies on an associative array to ensure the best performances.
  34926. * The value can be anything including 'null' but except 'undefined'
  34927. */
  34928. export class StringDictionary<T> {
  34929. /**
  34930. * This will clear this dictionary and copy the content from the 'source' one.
  34931. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34932. * @param source the dictionary to take the content from and copy to this dictionary
  34933. */
  34934. copyFrom(source: StringDictionary<T>): void;
  34935. /**
  34936. * Get a value based from its key
  34937. * @param key the given key to get the matching value from
  34938. * @return the value if found, otherwise undefined is returned
  34939. */
  34940. get(key: string): T | undefined;
  34941. /**
  34942. * Get a value from its key or add it if it doesn't exist.
  34943. * This method will ensure you that a given key/data will be present in the dictionary.
  34944. * @param key the given key to get the matching value from
  34945. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34946. * The factory will only be invoked if there's no data for the given key.
  34947. * @return the value corresponding to the key.
  34948. */
  34949. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34950. /**
  34951. * Get a value from its key if present in the dictionary otherwise add it
  34952. * @param key the key to get the value from
  34953. * @param val if there's no such key/value pair in the dictionary add it with this value
  34954. * @return the value corresponding to the key
  34955. */
  34956. getOrAdd(key: string, val: T): T;
  34957. /**
  34958. * Check if there's a given key in the dictionary
  34959. * @param key the key to check for
  34960. * @return true if the key is present, false otherwise
  34961. */
  34962. contains(key: string): boolean;
  34963. /**
  34964. * Add a new key and its corresponding value
  34965. * @param key the key to add
  34966. * @param value the value corresponding to the key
  34967. * @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
  34968. */
  34969. add(key: string, value: T): boolean;
  34970. /**
  34971. * Update a specific value associated to a key
  34972. * @param key defines the key to use
  34973. * @param value defines the value to store
  34974. * @returns true if the value was updated (or false if the key was not found)
  34975. */
  34976. set(key: string, value: T): boolean;
  34977. /**
  34978. * Get the element of the given key and remove it from the dictionary
  34979. * @param key defines the key to search
  34980. * @returns the value associated with the key or null if not found
  34981. */
  34982. getAndRemove(key: string): Nullable<T>;
  34983. /**
  34984. * Remove a key/value from the dictionary.
  34985. * @param key the key to remove
  34986. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34987. */
  34988. remove(key: string): boolean;
  34989. /**
  34990. * Clear the whole content of the dictionary
  34991. */
  34992. clear(): void;
  34993. /**
  34994. * Gets the current count
  34995. */
  34996. get count(): number;
  34997. /**
  34998. * Execute a callback on each key/val of the dictionary.
  34999. * Note that you can remove any element in this dictionary in the callback implementation
  35000. * @param callback the callback to execute on a given key/value pair
  35001. */
  35002. forEach(callback: (key: string, val: T) => void): void;
  35003. /**
  35004. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35005. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35006. * Note that you can remove any element in this dictionary in the callback implementation
  35007. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35008. * @returns the first item
  35009. */
  35010. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35011. private _count;
  35012. private _data;
  35013. }
  35014. }
  35015. declare module BABYLON {
  35016. /** @hidden */
  35017. export interface ICollisionCoordinator {
  35018. createCollider(): Collider;
  35019. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35020. init(scene: Scene): void;
  35021. }
  35022. /** @hidden */
  35023. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35024. private _scene;
  35025. private _scaledPosition;
  35026. private _scaledVelocity;
  35027. private _finalPosition;
  35028. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35029. createCollider(): Collider;
  35030. init(scene: Scene): void;
  35031. private _collideWithWorld;
  35032. }
  35033. }
  35034. declare module BABYLON {
  35035. /**
  35036. * Class used to manage all inputs for the scene.
  35037. */
  35038. export class InputManager {
  35039. /** The distance in pixel that you have to move to prevent some events */
  35040. static DragMovementThreshold: number;
  35041. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35042. static LongPressDelay: number;
  35043. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35044. static DoubleClickDelay: number;
  35045. /** If you need to check double click without raising a single click at first click, enable this flag */
  35046. static ExclusiveDoubleClickMode: boolean;
  35047. private _wheelEventName;
  35048. private _onPointerMove;
  35049. private _onPointerDown;
  35050. private _onPointerUp;
  35051. private _initClickEvent;
  35052. private _initActionManager;
  35053. private _delayedSimpleClick;
  35054. private _delayedSimpleClickTimeout;
  35055. private _previousDelayedSimpleClickTimeout;
  35056. private _meshPickProceed;
  35057. private _previousButtonPressed;
  35058. private _currentPickResult;
  35059. private _previousPickResult;
  35060. private _totalPointersPressed;
  35061. private _doubleClickOccured;
  35062. private _pointerOverMesh;
  35063. private _pickedDownMesh;
  35064. private _pickedUpMesh;
  35065. private _pointerX;
  35066. private _pointerY;
  35067. private _unTranslatedPointerX;
  35068. private _unTranslatedPointerY;
  35069. private _startingPointerPosition;
  35070. private _previousStartingPointerPosition;
  35071. private _startingPointerTime;
  35072. private _previousStartingPointerTime;
  35073. private _pointerCaptures;
  35074. private _onKeyDown;
  35075. private _onKeyUp;
  35076. private _onCanvasFocusObserver;
  35077. private _onCanvasBlurObserver;
  35078. private _scene;
  35079. /**
  35080. * Creates a new InputManager
  35081. * @param scene defines the hosting scene
  35082. */
  35083. constructor(scene: Scene);
  35084. /**
  35085. * Gets the mesh that is currently under the pointer
  35086. */
  35087. get meshUnderPointer(): Nullable<AbstractMesh>;
  35088. /**
  35089. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35090. */
  35091. get unTranslatedPointer(): Vector2;
  35092. /**
  35093. * Gets or sets the current on-screen X position of the pointer
  35094. */
  35095. get pointerX(): number;
  35096. set pointerX(value: number);
  35097. /**
  35098. * Gets or sets the current on-screen Y position of the pointer
  35099. */
  35100. get pointerY(): number;
  35101. set pointerY(value: number);
  35102. private _updatePointerPosition;
  35103. private _processPointerMove;
  35104. private _setRayOnPointerInfo;
  35105. private _checkPrePointerObservable;
  35106. /**
  35107. * Use this method to simulate a pointer move on a mesh
  35108. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35109. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35110. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35111. */
  35112. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35113. /**
  35114. * Use this method to simulate a pointer down on a mesh
  35115. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35116. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35117. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35118. */
  35119. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35120. private _processPointerDown;
  35121. /** @hidden */
  35122. _isPointerSwiping(): boolean;
  35123. /**
  35124. * Use this method to simulate a pointer up on a mesh
  35125. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35126. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35127. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35128. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35129. */
  35130. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35131. private _processPointerUp;
  35132. /**
  35133. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35134. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35135. * @returns true if the pointer was captured
  35136. */
  35137. isPointerCaptured(pointerId?: number): boolean;
  35138. /**
  35139. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35140. * @param attachUp defines if you want to attach events to pointerup
  35141. * @param attachDown defines if you want to attach events to pointerdown
  35142. * @param attachMove defines if you want to attach events to pointermove
  35143. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35144. */
  35145. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35146. /**
  35147. * Detaches all event handlers
  35148. */
  35149. detachControl(): void;
  35150. /**
  35151. * Force the value of meshUnderPointer
  35152. * @param mesh defines the mesh to use
  35153. */
  35154. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35155. /**
  35156. * Gets the mesh under the pointer
  35157. * @returns a Mesh or null if no mesh is under the pointer
  35158. */
  35159. getPointerOverMesh(): Nullable<AbstractMesh>;
  35160. }
  35161. }
  35162. declare module BABYLON {
  35163. /**
  35164. * Helper class used to generate session unique ID
  35165. */
  35166. export class UniqueIdGenerator {
  35167. private static _UniqueIdCounter;
  35168. /**
  35169. * Gets an unique (relatively to the current scene) Id
  35170. */
  35171. static get UniqueId(): number;
  35172. }
  35173. }
  35174. declare module BABYLON {
  35175. /**
  35176. * This class defines the direct association between an animation and a target
  35177. */
  35178. export class TargetedAnimation {
  35179. /**
  35180. * Animation to perform
  35181. */
  35182. animation: Animation;
  35183. /**
  35184. * Target to animate
  35185. */
  35186. target: any;
  35187. /**
  35188. * Serialize the object
  35189. * @returns the JSON object representing the current entity
  35190. */
  35191. serialize(): any;
  35192. }
  35193. /**
  35194. * Use this class to create coordinated animations on multiple targets
  35195. */
  35196. export class AnimationGroup implements IDisposable {
  35197. /** The name of the animation group */
  35198. name: string;
  35199. private _scene;
  35200. private _targetedAnimations;
  35201. private _animatables;
  35202. private _from;
  35203. private _to;
  35204. private _isStarted;
  35205. private _isPaused;
  35206. private _speedRatio;
  35207. private _loopAnimation;
  35208. private _isAdditive;
  35209. /**
  35210. * Gets or sets the unique id of the node
  35211. */
  35212. uniqueId: number;
  35213. /**
  35214. * This observable will notify when one animation have ended
  35215. */
  35216. onAnimationEndObservable: Observable<TargetedAnimation>;
  35217. /**
  35218. * Observer raised when one animation loops
  35219. */
  35220. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35221. /**
  35222. * Observer raised when all animations have looped
  35223. */
  35224. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35225. /**
  35226. * This observable will notify when all animations have ended.
  35227. */
  35228. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35229. /**
  35230. * This observable will notify when all animations have paused.
  35231. */
  35232. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35233. /**
  35234. * This observable will notify when all animations are playing.
  35235. */
  35236. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35237. /**
  35238. * Gets the first frame
  35239. */
  35240. get from(): number;
  35241. /**
  35242. * Gets the last frame
  35243. */
  35244. get to(): number;
  35245. /**
  35246. * Define if the animations are started
  35247. */
  35248. get isStarted(): boolean;
  35249. /**
  35250. * Gets a value indicating that the current group is playing
  35251. */
  35252. get isPlaying(): boolean;
  35253. /**
  35254. * Gets or sets the speed ratio to use for all animations
  35255. */
  35256. get speedRatio(): number;
  35257. /**
  35258. * Gets or sets the speed ratio to use for all animations
  35259. */
  35260. set speedRatio(value: number);
  35261. /**
  35262. * Gets or sets if all animations should loop or not
  35263. */
  35264. get loopAnimation(): boolean;
  35265. set loopAnimation(value: boolean);
  35266. /**
  35267. * Gets or sets if all animations should be evaluated additively
  35268. */
  35269. get isAdditive(): boolean;
  35270. set isAdditive(value: boolean);
  35271. /**
  35272. * Gets the targeted animations for this animation group
  35273. */
  35274. get targetedAnimations(): Array<TargetedAnimation>;
  35275. /**
  35276. * returning the list of animatables controlled by this animation group.
  35277. */
  35278. get animatables(): Array<Animatable>;
  35279. /**
  35280. * Instantiates a new Animation Group.
  35281. * This helps managing several animations at once.
  35282. * @see http://doc.babylonjs.com/how_to/group
  35283. * @param name Defines the name of the group
  35284. * @param scene Defines the scene the group belongs to
  35285. */
  35286. constructor(
  35287. /** The name of the animation group */
  35288. name: string, scene?: Nullable<Scene>);
  35289. /**
  35290. * Add an animation (with its target) in the group
  35291. * @param animation defines the animation we want to add
  35292. * @param target defines the target of the animation
  35293. * @returns the TargetedAnimation object
  35294. */
  35295. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35296. /**
  35297. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35298. * It can add constant keys at begin or end
  35299. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35300. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35301. * @returns the animation group
  35302. */
  35303. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35304. private _animationLoopCount;
  35305. private _animationLoopFlags;
  35306. private _processLoop;
  35307. /**
  35308. * Start all animations on given targets
  35309. * @param loop defines if animations must loop
  35310. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35311. * @param from defines the from key (optional)
  35312. * @param to defines the to key (optional)
  35313. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35314. * @returns the current animation group
  35315. */
  35316. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35317. /**
  35318. * Pause all animations
  35319. * @returns the animation group
  35320. */
  35321. pause(): AnimationGroup;
  35322. /**
  35323. * Play all animations to initial state
  35324. * This function will start() the animations if they were not started or will restart() them if they were paused
  35325. * @param loop defines if animations must loop
  35326. * @returns the animation group
  35327. */
  35328. play(loop?: boolean): AnimationGroup;
  35329. /**
  35330. * Reset all animations to initial state
  35331. * @returns the animation group
  35332. */
  35333. reset(): AnimationGroup;
  35334. /**
  35335. * Restart animations from key 0
  35336. * @returns the animation group
  35337. */
  35338. restart(): AnimationGroup;
  35339. /**
  35340. * Stop all animations
  35341. * @returns the animation group
  35342. */
  35343. stop(): AnimationGroup;
  35344. /**
  35345. * Set animation weight for all animatables
  35346. * @param weight defines the weight to use
  35347. * @return the animationGroup
  35348. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35349. */
  35350. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35351. /**
  35352. * Synchronize and normalize all animatables with a source animatable
  35353. * @param root defines the root animatable to synchronize with
  35354. * @return the animationGroup
  35355. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35356. */
  35357. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35358. /**
  35359. * Goes to a specific frame in this animation group
  35360. * @param frame the frame number to go to
  35361. * @return the animationGroup
  35362. */
  35363. goToFrame(frame: number): AnimationGroup;
  35364. /**
  35365. * Dispose all associated resources
  35366. */
  35367. dispose(): void;
  35368. private _checkAnimationGroupEnded;
  35369. /**
  35370. * Clone the current animation group and returns a copy
  35371. * @param newName defines the name of the new group
  35372. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35373. * @returns the new aniamtion group
  35374. */
  35375. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35376. /**
  35377. * Serializes the animationGroup to an object
  35378. * @returns Serialized object
  35379. */
  35380. serialize(): any;
  35381. /**
  35382. * Returns a new AnimationGroup object parsed from the source provided.
  35383. * @param parsedAnimationGroup defines the source
  35384. * @param scene defines the scene that will receive the animationGroup
  35385. * @returns a new AnimationGroup
  35386. */
  35387. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35388. /**
  35389. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35390. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35391. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35392. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35393. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35394. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35395. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35396. */
  35397. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35398. /**
  35399. * Returns the string "AnimationGroup"
  35400. * @returns "AnimationGroup"
  35401. */
  35402. getClassName(): string;
  35403. /**
  35404. * Creates a detailled string about the object
  35405. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35406. * @returns a string representing the object
  35407. */
  35408. toString(fullDetails?: boolean): string;
  35409. }
  35410. }
  35411. declare module BABYLON {
  35412. /**
  35413. * Define an interface for all classes that will hold resources
  35414. */
  35415. export interface IDisposable {
  35416. /**
  35417. * Releases all held resources
  35418. */
  35419. dispose(): void;
  35420. }
  35421. /** Interface defining initialization parameters for Scene class */
  35422. export interface SceneOptions {
  35423. /**
  35424. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35425. * It will improve performance when the number of geometries becomes important.
  35426. */
  35427. useGeometryUniqueIdsMap?: boolean;
  35428. /**
  35429. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35430. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35431. */
  35432. useMaterialMeshMap?: boolean;
  35433. /**
  35434. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35435. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35436. */
  35437. useClonedMeshMap?: boolean;
  35438. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35439. virtual?: boolean;
  35440. }
  35441. /**
  35442. * Represents a scene to be rendered by the engine.
  35443. * @see http://doc.babylonjs.com/features/scene
  35444. */
  35445. export class Scene extends AbstractScene implements IAnimatable {
  35446. /** The fog is deactivated */
  35447. static readonly FOGMODE_NONE: number;
  35448. /** The fog density is following an exponential function */
  35449. static readonly FOGMODE_EXP: number;
  35450. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35451. static readonly FOGMODE_EXP2: number;
  35452. /** The fog density is following a linear function. */
  35453. static readonly FOGMODE_LINEAR: number;
  35454. /**
  35455. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35456. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35457. */
  35458. static MinDeltaTime: number;
  35459. /**
  35460. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35461. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35462. */
  35463. static MaxDeltaTime: number;
  35464. /**
  35465. * Factory used to create the default material.
  35466. * @param name The name of the material to create
  35467. * @param scene The scene to create the material for
  35468. * @returns The default material
  35469. */
  35470. static DefaultMaterialFactory(scene: Scene): Material;
  35471. /**
  35472. * Factory used to create the a collision coordinator.
  35473. * @returns The collision coordinator
  35474. */
  35475. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35476. /** @hidden */
  35477. _inputManager: InputManager;
  35478. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35479. cameraToUseForPointers: Nullable<Camera>;
  35480. /** @hidden */
  35481. readonly _isScene: boolean;
  35482. /** @hidden */
  35483. _blockEntityCollection: boolean;
  35484. /**
  35485. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35486. */
  35487. autoClear: boolean;
  35488. /**
  35489. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35490. */
  35491. autoClearDepthAndStencil: boolean;
  35492. /**
  35493. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35494. */
  35495. clearColor: Color4;
  35496. /**
  35497. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35498. */
  35499. ambientColor: Color3;
  35500. /**
  35501. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35502. * It should only be one of the following (if not the default embedded one):
  35503. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35504. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35505. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35506. * The material properties need to be setup according to the type of texture in use.
  35507. */
  35508. environmentBRDFTexture: BaseTexture;
  35509. /** @hidden */
  35510. protected _environmentTexture: Nullable<BaseTexture>;
  35511. /**
  35512. * Texture used in all pbr material as the reflection texture.
  35513. * As in the majority of the scene they are the same (exception for multi room and so on),
  35514. * this is easier to reference from here than from all the materials.
  35515. */
  35516. get environmentTexture(): Nullable<BaseTexture>;
  35517. /**
  35518. * Texture used in all pbr material as the reflection texture.
  35519. * As in the majority of the scene they are the same (exception for multi room and so on),
  35520. * this is easier to set here than in all the materials.
  35521. */
  35522. set environmentTexture(value: Nullable<BaseTexture>);
  35523. /** @hidden */
  35524. protected _environmentIntensity: number;
  35525. /**
  35526. * Intensity of the environment in all pbr material.
  35527. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35528. * As in the majority of the scene they are the same (exception for multi room and so on),
  35529. * this is easier to reference from here than from all the materials.
  35530. */
  35531. get environmentIntensity(): number;
  35532. /**
  35533. * Intensity of the environment in all pbr material.
  35534. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35535. * As in the majority of the scene they are the same (exception for multi room and so on),
  35536. * this is easier to set here than in all the materials.
  35537. */
  35538. set environmentIntensity(value: number);
  35539. /** @hidden */
  35540. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35541. /**
  35542. * Default image processing configuration used either in the rendering
  35543. * Forward main pass or through the imageProcessingPostProcess if present.
  35544. * As in the majority of the scene they are the same (exception for multi camera),
  35545. * this is easier to reference from here than from all the materials and post process.
  35546. *
  35547. * No setter as we it is a shared configuration, you can set the values instead.
  35548. */
  35549. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35550. private _forceWireframe;
  35551. /**
  35552. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35553. */
  35554. set forceWireframe(value: boolean);
  35555. get forceWireframe(): boolean;
  35556. private _skipFrustumClipping;
  35557. /**
  35558. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35559. */
  35560. set skipFrustumClipping(value: boolean);
  35561. get skipFrustumClipping(): boolean;
  35562. private _forcePointsCloud;
  35563. /**
  35564. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35565. */
  35566. set forcePointsCloud(value: boolean);
  35567. get forcePointsCloud(): boolean;
  35568. /**
  35569. * Gets or sets the active clipplane 1
  35570. */
  35571. clipPlane: Nullable<Plane>;
  35572. /**
  35573. * Gets or sets the active clipplane 2
  35574. */
  35575. clipPlane2: Nullable<Plane>;
  35576. /**
  35577. * Gets or sets the active clipplane 3
  35578. */
  35579. clipPlane3: Nullable<Plane>;
  35580. /**
  35581. * Gets or sets the active clipplane 4
  35582. */
  35583. clipPlane4: Nullable<Plane>;
  35584. /**
  35585. * Gets or sets the active clipplane 5
  35586. */
  35587. clipPlane5: Nullable<Plane>;
  35588. /**
  35589. * Gets or sets the active clipplane 6
  35590. */
  35591. clipPlane6: Nullable<Plane>;
  35592. /**
  35593. * Gets or sets a boolean indicating if animations are enabled
  35594. */
  35595. animationsEnabled: boolean;
  35596. private _animationPropertiesOverride;
  35597. /**
  35598. * Gets or sets the animation properties override
  35599. */
  35600. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35601. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35602. /**
  35603. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35604. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35605. */
  35606. useConstantAnimationDeltaTime: boolean;
  35607. /**
  35608. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35609. * Please note that it requires to run a ray cast through the scene on every frame
  35610. */
  35611. constantlyUpdateMeshUnderPointer: boolean;
  35612. /**
  35613. * Defines the HTML cursor to use when hovering over interactive elements
  35614. */
  35615. hoverCursor: string;
  35616. /**
  35617. * Defines the HTML default cursor to use (empty by default)
  35618. */
  35619. defaultCursor: string;
  35620. /**
  35621. * Defines whether cursors are handled by the scene.
  35622. */
  35623. doNotHandleCursors: boolean;
  35624. /**
  35625. * This is used to call preventDefault() on pointer down
  35626. * in order to block unwanted artifacts like system double clicks
  35627. */
  35628. preventDefaultOnPointerDown: boolean;
  35629. /**
  35630. * This is used to call preventDefault() on pointer up
  35631. * in order to block unwanted artifacts like system double clicks
  35632. */
  35633. preventDefaultOnPointerUp: boolean;
  35634. /**
  35635. * Gets or sets user defined metadata
  35636. */
  35637. metadata: any;
  35638. /**
  35639. * For internal use only. Please do not use.
  35640. */
  35641. reservedDataStore: any;
  35642. /**
  35643. * Gets the name of the plugin used to load this scene (null by default)
  35644. */
  35645. loadingPluginName: string;
  35646. /**
  35647. * Use this array to add regular expressions used to disable offline support for specific urls
  35648. */
  35649. disableOfflineSupportExceptionRules: RegExp[];
  35650. /**
  35651. * An event triggered when the scene is disposed.
  35652. */
  35653. onDisposeObservable: Observable<Scene>;
  35654. private _onDisposeObserver;
  35655. /** Sets a function to be executed when this scene is disposed. */
  35656. set onDispose(callback: () => void);
  35657. /**
  35658. * An event triggered before rendering the scene (right after animations and physics)
  35659. */
  35660. onBeforeRenderObservable: Observable<Scene>;
  35661. private _onBeforeRenderObserver;
  35662. /** Sets a function to be executed before rendering this scene */
  35663. set beforeRender(callback: Nullable<() => void>);
  35664. /**
  35665. * An event triggered after rendering the scene
  35666. */
  35667. onAfterRenderObservable: Observable<Scene>;
  35668. /**
  35669. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35670. */
  35671. onAfterRenderCameraObservable: Observable<Camera>;
  35672. private _onAfterRenderObserver;
  35673. /** Sets a function to be executed after rendering this scene */
  35674. set afterRender(callback: Nullable<() => void>);
  35675. /**
  35676. * An event triggered before animating the scene
  35677. */
  35678. onBeforeAnimationsObservable: Observable<Scene>;
  35679. /**
  35680. * An event triggered after animations processing
  35681. */
  35682. onAfterAnimationsObservable: Observable<Scene>;
  35683. /**
  35684. * An event triggered before draw calls are ready to be sent
  35685. */
  35686. onBeforeDrawPhaseObservable: Observable<Scene>;
  35687. /**
  35688. * An event triggered after draw calls have been sent
  35689. */
  35690. onAfterDrawPhaseObservable: Observable<Scene>;
  35691. /**
  35692. * An event triggered when the scene is ready
  35693. */
  35694. onReadyObservable: Observable<Scene>;
  35695. /**
  35696. * An event triggered before rendering a camera
  35697. */
  35698. onBeforeCameraRenderObservable: Observable<Camera>;
  35699. private _onBeforeCameraRenderObserver;
  35700. /** Sets a function to be executed before rendering a camera*/
  35701. set beforeCameraRender(callback: () => void);
  35702. /**
  35703. * An event triggered after rendering a camera
  35704. */
  35705. onAfterCameraRenderObservable: Observable<Camera>;
  35706. private _onAfterCameraRenderObserver;
  35707. /** Sets a function to be executed after rendering a camera*/
  35708. set afterCameraRender(callback: () => void);
  35709. /**
  35710. * An event triggered when active meshes evaluation is about to start
  35711. */
  35712. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35713. /**
  35714. * An event triggered when active meshes evaluation is done
  35715. */
  35716. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35717. /**
  35718. * An event triggered when particles rendering is about to start
  35719. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35720. */
  35721. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35722. /**
  35723. * An event triggered when particles rendering is done
  35724. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35725. */
  35726. onAfterParticlesRenderingObservable: Observable<Scene>;
  35727. /**
  35728. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35729. */
  35730. onDataLoadedObservable: Observable<Scene>;
  35731. /**
  35732. * An event triggered when a camera is created
  35733. */
  35734. onNewCameraAddedObservable: Observable<Camera>;
  35735. /**
  35736. * An event triggered when a camera is removed
  35737. */
  35738. onCameraRemovedObservable: Observable<Camera>;
  35739. /**
  35740. * An event triggered when a light is created
  35741. */
  35742. onNewLightAddedObservable: Observable<Light>;
  35743. /**
  35744. * An event triggered when a light is removed
  35745. */
  35746. onLightRemovedObservable: Observable<Light>;
  35747. /**
  35748. * An event triggered when a geometry is created
  35749. */
  35750. onNewGeometryAddedObservable: Observable<Geometry>;
  35751. /**
  35752. * An event triggered when a geometry is removed
  35753. */
  35754. onGeometryRemovedObservable: Observable<Geometry>;
  35755. /**
  35756. * An event triggered when a transform node is created
  35757. */
  35758. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35759. /**
  35760. * An event triggered when a transform node is removed
  35761. */
  35762. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35763. /**
  35764. * An event triggered when a mesh is created
  35765. */
  35766. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35767. /**
  35768. * An event triggered when a mesh is removed
  35769. */
  35770. onMeshRemovedObservable: Observable<AbstractMesh>;
  35771. /**
  35772. * An event triggered when a skeleton is created
  35773. */
  35774. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35775. /**
  35776. * An event triggered when a skeleton is removed
  35777. */
  35778. onSkeletonRemovedObservable: Observable<Skeleton>;
  35779. /**
  35780. * An event triggered when a material is created
  35781. */
  35782. onNewMaterialAddedObservable: Observable<Material>;
  35783. /**
  35784. * An event triggered when a material is removed
  35785. */
  35786. onMaterialRemovedObservable: Observable<Material>;
  35787. /**
  35788. * An event triggered when a texture is created
  35789. */
  35790. onNewTextureAddedObservable: Observable<BaseTexture>;
  35791. /**
  35792. * An event triggered when a texture is removed
  35793. */
  35794. onTextureRemovedObservable: Observable<BaseTexture>;
  35795. /**
  35796. * An event triggered when render targets are about to be rendered
  35797. * Can happen multiple times per frame.
  35798. */
  35799. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35800. /**
  35801. * An event triggered when render targets were rendered.
  35802. * Can happen multiple times per frame.
  35803. */
  35804. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35805. /**
  35806. * An event triggered before calculating deterministic simulation step
  35807. */
  35808. onBeforeStepObservable: Observable<Scene>;
  35809. /**
  35810. * An event triggered after calculating deterministic simulation step
  35811. */
  35812. onAfterStepObservable: Observable<Scene>;
  35813. /**
  35814. * An event triggered when the activeCamera property is updated
  35815. */
  35816. onActiveCameraChanged: Observable<Scene>;
  35817. /**
  35818. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35819. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35820. * 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)
  35821. */
  35822. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35823. /**
  35824. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35825. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35826. * 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)
  35827. */
  35828. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35829. /**
  35830. * This Observable will when a mesh has been imported into the scene.
  35831. */
  35832. onMeshImportedObservable: Observable<AbstractMesh>;
  35833. /**
  35834. * This Observable will when an animation file has been imported into the scene.
  35835. */
  35836. onAnimationFileImportedObservable: Observable<Scene>;
  35837. /**
  35838. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35839. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35840. */
  35841. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35842. /** @hidden */
  35843. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35844. /**
  35845. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35846. */
  35847. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35848. /**
  35849. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35850. */
  35851. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35852. /**
  35853. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35854. */
  35855. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35856. /** Callback called when a pointer move is detected */
  35857. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35858. /** Callback called when a pointer down is detected */
  35859. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35860. /** Callback called when a pointer up is detected */
  35861. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35862. /** Callback called when a pointer pick is detected */
  35863. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35864. /**
  35865. * 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).
  35866. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35867. */
  35868. onPrePointerObservable: Observable<PointerInfoPre>;
  35869. /**
  35870. * Observable event triggered each time an input event is received from the rendering canvas
  35871. */
  35872. onPointerObservable: Observable<PointerInfo>;
  35873. /**
  35874. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35875. */
  35876. get unTranslatedPointer(): Vector2;
  35877. /**
  35878. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35879. */
  35880. static get DragMovementThreshold(): number;
  35881. static set DragMovementThreshold(value: number);
  35882. /**
  35883. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35884. */
  35885. static get LongPressDelay(): number;
  35886. static set LongPressDelay(value: number);
  35887. /**
  35888. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35889. */
  35890. static get DoubleClickDelay(): number;
  35891. static set DoubleClickDelay(value: number);
  35892. /** If you need to check double click without raising a single click at first click, enable this flag */
  35893. static get ExclusiveDoubleClickMode(): boolean;
  35894. static set ExclusiveDoubleClickMode(value: boolean);
  35895. /** @hidden */
  35896. _mirroredCameraPosition: Nullable<Vector3>;
  35897. /**
  35898. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35899. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35900. */
  35901. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35902. /**
  35903. * Observable event triggered each time an keyboard event is received from the hosting window
  35904. */
  35905. onKeyboardObservable: Observable<KeyboardInfo>;
  35906. private _useRightHandedSystem;
  35907. /**
  35908. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35909. */
  35910. set useRightHandedSystem(value: boolean);
  35911. get useRightHandedSystem(): boolean;
  35912. private _timeAccumulator;
  35913. private _currentStepId;
  35914. private _currentInternalStep;
  35915. /**
  35916. * Sets the step Id used by deterministic lock step
  35917. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35918. * @param newStepId defines the step Id
  35919. */
  35920. setStepId(newStepId: number): void;
  35921. /**
  35922. * Gets the step Id used by deterministic lock step
  35923. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35924. * @returns the step Id
  35925. */
  35926. getStepId(): number;
  35927. /**
  35928. * Gets the internal step used by deterministic lock step
  35929. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35930. * @returns the internal step
  35931. */
  35932. getInternalStep(): number;
  35933. private _fogEnabled;
  35934. /**
  35935. * Gets or sets a boolean indicating if fog is enabled on this scene
  35936. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35937. * (Default is true)
  35938. */
  35939. set fogEnabled(value: boolean);
  35940. get fogEnabled(): boolean;
  35941. private _fogMode;
  35942. /**
  35943. * Gets or sets the fog mode to use
  35944. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35945. * | mode | value |
  35946. * | --- | --- |
  35947. * | FOGMODE_NONE | 0 |
  35948. * | FOGMODE_EXP | 1 |
  35949. * | FOGMODE_EXP2 | 2 |
  35950. * | FOGMODE_LINEAR | 3 |
  35951. */
  35952. set fogMode(value: number);
  35953. get fogMode(): number;
  35954. /**
  35955. * Gets or sets the fog color to use
  35956. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35957. * (Default is Color3(0.2, 0.2, 0.3))
  35958. */
  35959. fogColor: Color3;
  35960. /**
  35961. * Gets or sets the fog density to use
  35962. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35963. * (Default is 0.1)
  35964. */
  35965. fogDensity: number;
  35966. /**
  35967. * Gets or sets the fog start distance to use
  35968. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35969. * (Default is 0)
  35970. */
  35971. fogStart: number;
  35972. /**
  35973. * Gets or sets the fog end distance to use
  35974. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35975. * (Default is 1000)
  35976. */
  35977. fogEnd: number;
  35978. private _shadowsEnabled;
  35979. /**
  35980. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35981. */
  35982. set shadowsEnabled(value: boolean);
  35983. get shadowsEnabled(): boolean;
  35984. private _lightsEnabled;
  35985. /**
  35986. * Gets or sets a boolean indicating if lights are enabled on this scene
  35987. */
  35988. set lightsEnabled(value: boolean);
  35989. get lightsEnabled(): boolean;
  35990. /** All of the active cameras added to this scene. */
  35991. activeCameras: Camera[];
  35992. /** @hidden */
  35993. _activeCamera: Nullable<Camera>;
  35994. /** Gets or sets the current active camera */
  35995. get activeCamera(): Nullable<Camera>;
  35996. set activeCamera(value: Nullable<Camera>);
  35997. private _defaultMaterial;
  35998. /** The default material used on meshes when no material is affected */
  35999. get defaultMaterial(): Material;
  36000. /** The default material used on meshes when no material is affected */
  36001. set defaultMaterial(value: Material);
  36002. private _texturesEnabled;
  36003. /**
  36004. * Gets or sets a boolean indicating if textures are enabled on this scene
  36005. */
  36006. set texturesEnabled(value: boolean);
  36007. get texturesEnabled(): boolean;
  36008. /**
  36009. * Gets or sets a boolean indicating if particles are enabled on this scene
  36010. */
  36011. particlesEnabled: boolean;
  36012. /**
  36013. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36014. */
  36015. spritesEnabled: boolean;
  36016. private _skeletonsEnabled;
  36017. /**
  36018. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36019. */
  36020. set skeletonsEnabled(value: boolean);
  36021. get skeletonsEnabled(): boolean;
  36022. /**
  36023. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36024. */
  36025. lensFlaresEnabled: boolean;
  36026. /**
  36027. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36028. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36029. */
  36030. collisionsEnabled: boolean;
  36031. private _collisionCoordinator;
  36032. /** @hidden */
  36033. get collisionCoordinator(): ICollisionCoordinator;
  36034. /**
  36035. * Defines the gravity applied to this scene (used only for collisions)
  36036. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36037. */
  36038. gravity: Vector3;
  36039. /**
  36040. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36041. */
  36042. postProcessesEnabled: boolean;
  36043. /**
  36044. * The list of postprocesses added to the scene
  36045. */
  36046. postProcesses: PostProcess[];
  36047. /**
  36048. * Gets the current postprocess manager
  36049. */
  36050. postProcessManager: PostProcessManager;
  36051. /**
  36052. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36053. */
  36054. renderTargetsEnabled: boolean;
  36055. /**
  36056. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36057. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36058. */
  36059. dumpNextRenderTargets: boolean;
  36060. /**
  36061. * The list of user defined render targets added to the scene
  36062. */
  36063. customRenderTargets: RenderTargetTexture[];
  36064. /**
  36065. * Defines if texture loading must be delayed
  36066. * If true, textures will only be loaded when they need to be rendered
  36067. */
  36068. useDelayedTextureLoading: boolean;
  36069. /**
  36070. * Gets the list of meshes imported to the scene through SceneLoader
  36071. */
  36072. importedMeshesFiles: String[];
  36073. /**
  36074. * Gets or sets a boolean indicating if probes are enabled on this scene
  36075. */
  36076. probesEnabled: boolean;
  36077. /**
  36078. * Gets or sets the current offline provider to use to store scene data
  36079. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36080. */
  36081. offlineProvider: IOfflineProvider;
  36082. /**
  36083. * Gets or sets the action manager associated with the scene
  36084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36085. */
  36086. actionManager: AbstractActionManager;
  36087. private _meshesForIntersections;
  36088. /**
  36089. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36090. */
  36091. proceduralTexturesEnabled: boolean;
  36092. private _engine;
  36093. private _totalVertices;
  36094. /** @hidden */
  36095. _activeIndices: PerfCounter;
  36096. /** @hidden */
  36097. _activeParticles: PerfCounter;
  36098. /** @hidden */
  36099. _activeBones: PerfCounter;
  36100. private _animationRatio;
  36101. /** @hidden */
  36102. _animationTimeLast: number;
  36103. /** @hidden */
  36104. _animationTime: number;
  36105. /**
  36106. * Gets or sets a general scale for animation speed
  36107. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36108. */
  36109. animationTimeScale: number;
  36110. /** @hidden */
  36111. _cachedMaterial: Nullable<Material>;
  36112. /** @hidden */
  36113. _cachedEffect: Nullable<Effect>;
  36114. /** @hidden */
  36115. _cachedVisibility: Nullable<number>;
  36116. private _renderId;
  36117. private _frameId;
  36118. private _executeWhenReadyTimeoutId;
  36119. private _intermediateRendering;
  36120. private _viewUpdateFlag;
  36121. private _projectionUpdateFlag;
  36122. /** @hidden */
  36123. _toBeDisposed: Nullable<IDisposable>[];
  36124. private _activeRequests;
  36125. /** @hidden */
  36126. _pendingData: any[];
  36127. private _isDisposed;
  36128. /**
  36129. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36130. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36131. */
  36132. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36133. private _activeMeshes;
  36134. private _processedMaterials;
  36135. private _renderTargets;
  36136. /** @hidden */
  36137. _activeParticleSystems: SmartArray<IParticleSystem>;
  36138. private _activeSkeletons;
  36139. private _softwareSkinnedMeshes;
  36140. private _renderingManager;
  36141. /** @hidden */
  36142. _activeAnimatables: Animatable[];
  36143. private _transformMatrix;
  36144. private _sceneUbo;
  36145. /** @hidden */
  36146. _viewMatrix: Matrix;
  36147. private _projectionMatrix;
  36148. /** @hidden */
  36149. _forcedViewPosition: Nullable<Vector3>;
  36150. /** @hidden */
  36151. _frustumPlanes: Plane[];
  36152. /**
  36153. * Gets the list of frustum planes (built from the active camera)
  36154. */
  36155. get frustumPlanes(): Plane[];
  36156. /**
  36157. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36158. * This is useful if there are more lights that the maximum simulteanous authorized
  36159. */
  36160. requireLightSorting: boolean;
  36161. /** @hidden */
  36162. readonly useMaterialMeshMap: boolean;
  36163. /** @hidden */
  36164. readonly useClonedMeshMap: boolean;
  36165. private _externalData;
  36166. private _uid;
  36167. /**
  36168. * @hidden
  36169. * Backing store of defined scene components.
  36170. */
  36171. _components: ISceneComponent[];
  36172. /**
  36173. * @hidden
  36174. * Backing store of defined scene components.
  36175. */
  36176. _serializableComponents: ISceneSerializableComponent[];
  36177. /**
  36178. * List of components to register on the next registration step.
  36179. */
  36180. private _transientComponents;
  36181. /**
  36182. * Registers the transient components if needed.
  36183. */
  36184. private _registerTransientComponents;
  36185. /**
  36186. * @hidden
  36187. * Add a component to the scene.
  36188. * Note that the ccomponent could be registered on th next frame if this is called after
  36189. * the register component stage.
  36190. * @param component Defines the component to add to the scene
  36191. */
  36192. _addComponent(component: ISceneComponent): void;
  36193. /**
  36194. * @hidden
  36195. * Gets a component from the scene.
  36196. * @param name defines the name of the component to retrieve
  36197. * @returns the component or null if not present
  36198. */
  36199. _getComponent(name: string): Nullable<ISceneComponent>;
  36200. /**
  36201. * @hidden
  36202. * Defines the actions happening before camera updates.
  36203. */
  36204. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36205. /**
  36206. * @hidden
  36207. * Defines the actions happening before clear the canvas.
  36208. */
  36209. _beforeClearStage: Stage<SimpleStageAction>;
  36210. /**
  36211. * @hidden
  36212. * Defines the actions when collecting render targets for the frame.
  36213. */
  36214. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36215. /**
  36216. * @hidden
  36217. * Defines the actions happening for one camera in the frame.
  36218. */
  36219. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36220. /**
  36221. * @hidden
  36222. * Defines the actions happening during the per mesh ready checks.
  36223. */
  36224. _isReadyForMeshStage: Stage<MeshStageAction>;
  36225. /**
  36226. * @hidden
  36227. * Defines the actions happening before evaluate active mesh checks.
  36228. */
  36229. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36230. /**
  36231. * @hidden
  36232. * Defines the actions happening during the evaluate sub mesh checks.
  36233. */
  36234. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36235. /**
  36236. * @hidden
  36237. * Defines the actions happening during the active mesh stage.
  36238. */
  36239. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36240. /**
  36241. * @hidden
  36242. * Defines the actions happening during the per camera render target step.
  36243. */
  36244. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36245. /**
  36246. * @hidden
  36247. * Defines the actions happening just before the active camera is drawing.
  36248. */
  36249. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36250. /**
  36251. * @hidden
  36252. * Defines the actions happening just before a render target is drawing.
  36253. */
  36254. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36255. /**
  36256. * @hidden
  36257. * Defines the actions happening just before a rendering group is drawing.
  36258. */
  36259. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36260. /**
  36261. * @hidden
  36262. * Defines the actions happening just before a mesh is drawing.
  36263. */
  36264. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36265. /**
  36266. * @hidden
  36267. * Defines the actions happening just after a mesh has been drawn.
  36268. */
  36269. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36270. /**
  36271. * @hidden
  36272. * Defines the actions happening just after a rendering group has been drawn.
  36273. */
  36274. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36275. /**
  36276. * @hidden
  36277. * Defines the actions happening just after the active camera has been drawn.
  36278. */
  36279. _afterCameraDrawStage: Stage<CameraStageAction>;
  36280. /**
  36281. * @hidden
  36282. * Defines the actions happening just after a render target has been drawn.
  36283. */
  36284. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36285. /**
  36286. * @hidden
  36287. * Defines the actions happening just after rendering all cameras and computing intersections.
  36288. */
  36289. _afterRenderStage: Stage<SimpleStageAction>;
  36290. /**
  36291. * @hidden
  36292. * Defines the actions happening when a pointer move event happens.
  36293. */
  36294. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36295. /**
  36296. * @hidden
  36297. * Defines the actions happening when a pointer down event happens.
  36298. */
  36299. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36300. /**
  36301. * @hidden
  36302. * Defines the actions happening when a pointer up event happens.
  36303. */
  36304. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36305. /**
  36306. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36307. */
  36308. private geometriesByUniqueId;
  36309. /**
  36310. * Creates a new Scene
  36311. * @param engine defines the engine to use to render this scene
  36312. * @param options defines the scene options
  36313. */
  36314. constructor(engine: Engine, options?: SceneOptions);
  36315. /**
  36316. * Gets a string idenfifying the name of the class
  36317. * @returns "Scene" string
  36318. */
  36319. getClassName(): string;
  36320. private _defaultMeshCandidates;
  36321. /**
  36322. * @hidden
  36323. */
  36324. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36325. private _defaultSubMeshCandidates;
  36326. /**
  36327. * @hidden
  36328. */
  36329. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36330. /**
  36331. * Sets the default candidate providers for the scene.
  36332. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36333. * and getCollidingSubMeshCandidates to their default function
  36334. */
  36335. setDefaultCandidateProviders(): void;
  36336. /**
  36337. * Gets the mesh that is currently under the pointer
  36338. */
  36339. get meshUnderPointer(): Nullable<AbstractMesh>;
  36340. /**
  36341. * Gets or sets the current on-screen X position of the pointer
  36342. */
  36343. get pointerX(): number;
  36344. set pointerX(value: number);
  36345. /**
  36346. * Gets or sets the current on-screen Y position of the pointer
  36347. */
  36348. get pointerY(): number;
  36349. set pointerY(value: number);
  36350. /**
  36351. * Gets the cached material (ie. the latest rendered one)
  36352. * @returns the cached material
  36353. */
  36354. getCachedMaterial(): Nullable<Material>;
  36355. /**
  36356. * Gets the cached effect (ie. the latest rendered one)
  36357. * @returns the cached effect
  36358. */
  36359. getCachedEffect(): Nullable<Effect>;
  36360. /**
  36361. * Gets the cached visibility state (ie. the latest rendered one)
  36362. * @returns the cached visibility state
  36363. */
  36364. getCachedVisibility(): Nullable<number>;
  36365. /**
  36366. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36367. * @param material defines the current material
  36368. * @param effect defines the current effect
  36369. * @param visibility defines the current visibility state
  36370. * @returns true if one parameter is not cached
  36371. */
  36372. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36373. /**
  36374. * Gets the engine associated with the scene
  36375. * @returns an Engine
  36376. */
  36377. getEngine(): Engine;
  36378. /**
  36379. * Gets the total number of vertices rendered per frame
  36380. * @returns the total number of vertices rendered per frame
  36381. */
  36382. getTotalVertices(): number;
  36383. /**
  36384. * Gets the performance counter for total vertices
  36385. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36386. */
  36387. get totalVerticesPerfCounter(): PerfCounter;
  36388. /**
  36389. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36390. * @returns the total number of active indices rendered per frame
  36391. */
  36392. getActiveIndices(): number;
  36393. /**
  36394. * Gets the performance counter for active indices
  36395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36396. */
  36397. get totalActiveIndicesPerfCounter(): PerfCounter;
  36398. /**
  36399. * Gets the total number of active particles rendered per frame
  36400. * @returns the total number of active particles rendered per frame
  36401. */
  36402. getActiveParticles(): number;
  36403. /**
  36404. * Gets the performance counter for active particles
  36405. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36406. */
  36407. get activeParticlesPerfCounter(): PerfCounter;
  36408. /**
  36409. * Gets the total number of active bones rendered per frame
  36410. * @returns the total number of active bones rendered per frame
  36411. */
  36412. getActiveBones(): number;
  36413. /**
  36414. * Gets the performance counter for active bones
  36415. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36416. */
  36417. get activeBonesPerfCounter(): PerfCounter;
  36418. /**
  36419. * Gets the array of active meshes
  36420. * @returns an array of AbstractMesh
  36421. */
  36422. getActiveMeshes(): SmartArray<AbstractMesh>;
  36423. /**
  36424. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36425. * @returns a number
  36426. */
  36427. getAnimationRatio(): number;
  36428. /**
  36429. * Gets an unique Id for the current render phase
  36430. * @returns a number
  36431. */
  36432. getRenderId(): number;
  36433. /**
  36434. * Gets an unique Id for the current frame
  36435. * @returns a number
  36436. */
  36437. getFrameId(): number;
  36438. /** Call this function if you want to manually increment the render Id*/
  36439. incrementRenderId(): void;
  36440. private _createUbo;
  36441. /**
  36442. * Use this method to simulate a pointer move on a mesh
  36443. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36444. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36445. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36446. * @returns the current scene
  36447. */
  36448. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36449. /**
  36450. * Use this method to simulate a pointer down on a mesh
  36451. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36452. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36453. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36454. * @returns the current scene
  36455. */
  36456. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36457. /**
  36458. * Use this method to simulate a pointer up on a mesh
  36459. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36460. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36461. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36462. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36463. * @returns the current scene
  36464. */
  36465. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36466. /**
  36467. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36468. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36469. * @returns true if the pointer was captured
  36470. */
  36471. isPointerCaptured(pointerId?: number): boolean;
  36472. /**
  36473. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36474. * @param attachUp defines if you want to attach events to pointerup
  36475. * @param attachDown defines if you want to attach events to pointerdown
  36476. * @param attachMove defines if you want to attach events to pointermove
  36477. */
  36478. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36479. /** Detaches all event handlers*/
  36480. detachControl(): void;
  36481. /**
  36482. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36483. * Delay loaded resources are not taking in account
  36484. * @return true if all required resources are ready
  36485. */
  36486. isReady(): boolean;
  36487. /** Resets all cached information relative to material (including effect and visibility) */
  36488. resetCachedMaterial(): void;
  36489. /**
  36490. * Registers a function to be called before every frame render
  36491. * @param func defines the function to register
  36492. */
  36493. registerBeforeRender(func: () => void): void;
  36494. /**
  36495. * Unregisters a function called before every frame render
  36496. * @param func defines the function to unregister
  36497. */
  36498. unregisterBeforeRender(func: () => void): void;
  36499. /**
  36500. * Registers a function to be called after every frame render
  36501. * @param func defines the function to register
  36502. */
  36503. registerAfterRender(func: () => void): void;
  36504. /**
  36505. * Unregisters a function called after every frame render
  36506. * @param func defines the function to unregister
  36507. */
  36508. unregisterAfterRender(func: () => void): void;
  36509. private _executeOnceBeforeRender;
  36510. /**
  36511. * The provided function will run before render once and will be disposed afterwards.
  36512. * A timeout delay can be provided so that the function will be executed in N ms.
  36513. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36514. * @param func The function to be executed.
  36515. * @param timeout optional delay in ms
  36516. */
  36517. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36518. /** @hidden */
  36519. _addPendingData(data: any): void;
  36520. /** @hidden */
  36521. _removePendingData(data: any): void;
  36522. /**
  36523. * Returns the number of items waiting to be loaded
  36524. * @returns the number of items waiting to be loaded
  36525. */
  36526. getWaitingItemsCount(): number;
  36527. /**
  36528. * Returns a boolean indicating if the scene is still loading data
  36529. */
  36530. get isLoading(): boolean;
  36531. /**
  36532. * Registers a function to be executed when the scene is ready
  36533. * @param {Function} func - the function to be executed
  36534. */
  36535. executeWhenReady(func: () => void): void;
  36536. /**
  36537. * Returns a promise that resolves when the scene is ready
  36538. * @returns A promise that resolves when the scene is ready
  36539. */
  36540. whenReadyAsync(): Promise<void>;
  36541. /** @hidden */
  36542. _checkIsReady(): void;
  36543. /**
  36544. * Gets all animatable attached to the scene
  36545. */
  36546. get animatables(): Animatable[];
  36547. /**
  36548. * Resets the last animation time frame.
  36549. * Useful to override when animations start running when loading a scene for the first time.
  36550. */
  36551. resetLastAnimationTimeFrame(): void;
  36552. /**
  36553. * Gets the current view matrix
  36554. * @returns a Matrix
  36555. */
  36556. getViewMatrix(): Matrix;
  36557. /**
  36558. * Gets the current projection matrix
  36559. * @returns a Matrix
  36560. */
  36561. getProjectionMatrix(): Matrix;
  36562. /**
  36563. * Gets the current transform matrix
  36564. * @returns a Matrix made of View * Projection
  36565. */
  36566. getTransformMatrix(): Matrix;
  36567. /**
  36568. * Sets the current transform matrix
  36569. * @param viewL defines the View matrix to use
  36570. * @param projectionL defines the Projection matrix to use
  36571. * @param viewR defines the right View matrix to use (if provided)
  36572. * @param projectionR defines the right Projection matrix to use (if provided)
  36573. */
  36574. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36575. /**
  36576. * Gets the uniform buffer used to store scene data
  36577. * @returns a UniformBuffer
  36578. */
  36579. getSceneUniformBuffer(): UniformBuffer;
  36580. /**
  36581. * Gets an unique (relatively to the current scene) Id
  36582. * @returns an unique number for the scene
  36583. */
  36584. getUniqueId(): number;
  36585. /**
  36586. * Add a mesh to the list of scene's meshes
  36587. * @param newMesh defines the mesh to add
  36588. * @param recursive if all child meshes should also be added to the scene
  36589. */
  36590. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36591. /**
  36592. * Remove a mesh for the list of scene's meshes
  36593. * @param toRemove defines the mesh to remove
  36594. * @param recursive if all child meshes should also be removed from the scene
  36595. * @returns the index where the mesh was in the mesh list
  36596. */
  36597. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36598. /**
  36599. * Add a transform node to the list of scene's transform nodes
  36600. * @param newTransformNode defines the transform node to add
  36601. */
  36602. addTransformNode(newTransformNode: TransformNode): void;
  36603. /**
  36604. * Remove a transform node for the list of scene's transform nodes
  36605. * @param toRemove defines the transform node to remove
  36606. * @returns the index where the transform node was in the transform node list
  36607. */
  36608. removeTransformNode(toRemove: TransformNode): number;
  36609. /**
  36610. * Remove a skeleton for the list of scene's skeletons
  36611. * @param toRemove defines the skeleton to remove
  36612. * @returns the index where the skeleton was in the skeleton list
  36613. */
  36614. removeSkeleton(toRemove: Skeleton): number;
  36615. /**
  36616. * Remove a morph target for the list of scene's morph targets
  36617. * @param toRemove defines the morph target to remove
  36618. * @returns the index where the morph target was in the morph target list
  36619. */
  36620. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36621. /**
  36622. * Remove a light for the list of scene's lights
  36623. * @param toRemove defines the light to remove
  36624. * @returns the index where the light was in the light list
  36625. */
  36626. removeLight(toRemove: Light): number;
  36627. /**
  36628. * Remove a camera for the list of scene's cameras
  36629. * @param toRemove defines the camera to remove
  36630. * @returns the index where the camera was in the camera list
  36631. */
  36632. removeCamera(toRemove: Camera): number;
  36633. /**
  36634. * Remove a particle system for the list of scene's particle systems
  36635. * @param toRemove defines the particle system to remove
  36636. * @returns the index where the particle system was in the particle system list
  36637. */
  36638. removeParticleSystem(toRemove: IParticleSystem): number;
  36639. /**
  36640. * Remove a animation for the list of scene's animations
  36641. * @param toRemove defines the animation to remove
  36642. * @returns the index where the animation was in the animation list
  36643. */
  36644. removeAnimation(toRemove: Animation): number;
  36645. /**
  36646. * Will stop the animation of the given target
  36647. * @param target - the target
  36648. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36649. * @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)
  36650. */
  36651. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36652. /**
  36653. * Removes the given animation group from this scene.
  36654. * @param toRemove The animation group to remove
  36655. * @returns The index of the removed animation group
  36656. */
  36657. removeAnimationGroup(toRemove: AnimationGroup): number;
  36658. /**
  36659. * Removes the given multi-material from this scene.
  36660. * @param toRemove The multi-material to remove
  36661. * @returns The index of the removed multi-material
  36662. */
  36663. removeMultiMaterial(toRemove: MultiMaterial): number;
  36664. /**
  36665. * Removes the given material from this scene.
  36666. * @param toRemove The material to remove
  36667. * @returns The index of the removed material
  36668. */
  36669. removeMaterial(toRemove: Material): number;
  36670. /**
  36671. * Removes the given action manager from this scene.
  36672. * @param toRemove The action manager to remove
  36673. * @returns The index of the removed action manager
  36674. */
  36675. removeActionManager(toRemove: AbstractActionManager): number;
  36676. /**
  36677. * Removes the given texture from this scene.
  36678. * @param toRemove The texture to remove
  36679. * @returns The index of the removed texture
  36680. */
  36681. removeTexture(toRemove: BaseTexture): number;
  36682. /**
  36683. * Adds the given light to this scene
  36684. * @param newLight The light to add
  36685. */
  36686. addLight(newLight: Light): void;
  36687. /**
  36688. * Sorts the list list based on light priorities
  36689. */
  36690. sortLightsByPriority(): void;
  36691. /**
  36692. * Adds the given camera to this scene
  36693. * @param newCamera The camera to add
  36694. */
  36695. addCamera(newCamera: Camera): void;
  36696. /**
  36697. * Adds the given skeleton to this scene
  36698. * @param newSkeleton The skeleton to add
  36699. */
  36700. addSkeleton(newSkeleton: Skeleton): void;
  36701. /**
  36702. * Adds the given particle system to this scene
  36703. * @param newParticleSystem The particle system to add
  36704. */
  36705. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36706. /**
  36707. * Adds the given animation to this scene
  36708. * @param newAnimation The animation to add
  36709. */
  36710. addAnimation(newAnimation: Animation): void;
  36711. /**
  36712. * Adds the given animation group to this scene.
  36713. * @param newAnimationGroup The animation group to add
  36714. */
  36715. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36716. /**
  36717. * Adds the given multi-material to this scene
  36718. * @param newMultiMaterial The multi-material to add
  36719. */
  36720. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36721. /**
  36722. * Adds the given material to this scene
  36723. * @param newMaterial The material to add
  36724. */
  36725. addMaterial(newMaterial: Material): void;
  36726. /**
  36727. * Adds the given morph target to this scene
  36728. * @param newMorphTargetManager The morph target to add
  36729. */
  36730. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36731. /**
  36732. * Adds the given geometry to this scene
  36733. * @param newGeometry The geometry to add
  36734. */
  36735. addGeometry(newGeometry: Geometry): void;
  36736. /**
  36737. * Adds the given action manager to this scene
  36738. * @param newActionManager The action manager to add
  36739. */
  36740. addActionManager(newActionManager: AbstractActionManager): void;
  36741. /**
  36742. * Adds the given texture to this scene.
  36743. * @param newTexture The texture to add
  36744. */
  36745. addTexture(newTexture: BaseTexture): void;
  36746. /**
  36747. * Switch active camera
  36748. * @param newCamera defines the new active camera
  36749. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36750. */
  36751. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36752. /**
  36753. * sets the active camera of the scene using its ID
  36754. * @param id defines the camera's ID
  36755. * @return the new active camera or null if none found.
  36756. */
  36757. setActiveCameraByID(id: string): Nullable<Camera>;
  36758. /**
  36759. * sets the active camera of the scene using its name
  36760. * @param name defines the camera's name
  36761. * @returns the new active camera or null if none found.
  36762. */
  36763. setActiveCameraByName(name: string): Nullable<Camera>;
  36764. /**
  36765. * get an animation group using its name
  36766. * @param name defines the material's name
  36767. * @return the animation group or null if none found.
  36768. */
  36769. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36770. /**
  36771. * Get a material using its unique id
  36772. * @param uniqueId defines the material's unique id
  36773. * @return the material or null if none found.
  36774. */
  36775. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36776. /**
  36777. * get a material using its id
  36778. * @param id defines the material's ID
  36779. * @return the material or null if none found.
  36780. */
  36781. getMaterialByID(id: string): Nullable<Material>;
  36782. /**
  36783. * Gets a the last added material using a given id
  36784. * @param id defines the material's ID
  36785. * @return the last material with the given id or null if none found.
  36786. */
  36787. getLastMaterialByID(id: string): Nullable<Material>;
  36788. /**
  36789. * Gets a material using its name
  36790. * @param name defines the material's name
  36791. * @return the material or null if none found.
  36792. */
  36793. getMaterialByName(name: string): Nullable<Material>;
  36794. /**
  36795. * Get a texture using its unique id
  36796. * @param uniqueId defines the texture's unique id
  36797. * @return the texture or null if none found.
  36798. */
  36799. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36800. /**
  36801. * Gets a camera using its id
  36802. * @param id defines the id to look for
  36803. * @returns the camera or null if not found
  36804. */
  36805. getCameraByID(id: string): Nullable<Camera>;
  36806. /**
  36807. * Gets a camera using its unique id
  36808. * @param uniqueId defines the unique id to look for
  36809. * @returns the camera or null if not found
  36810. */
  36811. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36812. /**
  36813. * Gets a camera using its name
  36814. * @param name defines the camera's name
  36815. * @return the camera or null if none found.
  36816. */
  36817. getCameraByName(name: string): Nullable<Camera>;
  36818. /**
  36819. * Gets a bone using its id
  36820. * @param id defines the bone's id
  36821. * @return the bone or null if not found
  36822. */
  36823. getBoneByID(id: string): Nullable<Bone>;
  36824. /**
  36825. * Gets a bone using its id
  36826. * @param name defines the bone's name
  36827. * @return the bone or null if not found
  36828. */
  36829. getBoneByName(name: string): Nullable<Bone>;
  36830. /**
  36831. * Gets a light node using its name
  36832. * @param name defines the the light's name
  36833. * @return the light or null if none found.
  36834. */
  36835. getLightByName(name: string): Nullable<Light>;
  36836. /**
  36837. * Gets a light node using its id
  36838. * @param id defines the light's id
  36839. * @return the light or null if none found.
  36840. */
  36841. getLightByID(id: string): Nullable<Light>;
  36842. /**
  36843. * Gets a light node using its scene-generated unique ID
  36844. * @param uniqueId defines the light's unique id
  36845. * @return the light or null if none found.
  36846. */
  36847. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36848. /**
  36849. * Gets a particle system by id
  36850. * @param id defines the particle system id
  36851. * @return the corresponding system or null if none found
  36852. */
  36853. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36854. /**
  36855. * Gets a geometry using its ID
  36856. * @param id defines the geometry's id
  36857. * @return the geometry or null if none found.
  36858. */
  36859. getGeometryByID(id: string): Nullable<Geometry>;
  36860. private _getGeometryByUniqueID;
  36861. /**
  36862. * Add a new geometry to this scene
  36863. * @param geometry defines the geometry to be added to the scene.
  36864. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36865. * @return a boolean defining if the geometry was added or not
  36866. */
  36867. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36868. /**
  36869. * Removes an existing geometry
  36870. * @param geometry defines the geometry to be removed from the scene
  36871. * @return a boolean defining if the geometry was removed or not
  36872. */
  36873. removeGeometry(geometry: Geometry): boolean;
  36874. /**
  36875. * Gets the list of geometries attached to the scene
  36876. * @returns an array of Geometry
  36877. */
  36878. getGeometries(): Geometry[];
  36879. /**
  36880. * Gets the first added mesh found of a given ID
  36881. * @param id defines the id to search for
  36882. * @return the mesh found or null if not found at all
  36883. */
  36884. getMeshByID(id: string): Nullable<AbstractMesh>;
  36885. /**
  36886. * Gets a list of meshes using their id
  36887. * @param id defines the id to search for
  36888. * @returns a list of meshes
  36889. */
  36890. getMeshesByID(id: string): Array<AbstractMesh>;
  36891. /**
  36892. * Gets the first added transform node found of a given ID
  36893. * @param id defines the id to search for
  36894. * @return the found transform node or null if not found at all.
  36895. */
  36896. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36897. /**
  36898. * Gets a transform node with its auto-generated unique id
  36899. * @param uniqueId efines the unique id to search for
  36900. * @return the found transform node or null if not found at all.
  36901. */
  36902. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36903. /**
  36904. * Gets a list of transform nodes using their id
  36905. * @param id defines the id to search for
  36906. * @returns a list of transform nodes
  36907. */
  36908. getTransformNodesByID(id: string): Array<TransformNode>;
  36909. /**
  36910. * Gets a mesh with its auto-generated unique id
  36911. * @param uniqueId defines the unique id to search for
  36912. * @return the found mesh or null if not found at all.
  36913. */
  36914. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36915. /**
  36916. * Gets a the last added mesh using a given id
  36917. * @param id defines the id to search for
  36918. * @return the found mesh or null if not found at all.
  36919. */
  36920. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36921. /**
  36922. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36923. * @param id defines the id to search for
  36924. * @return the found node or null if not found at all
  36925. */
  36926. getLastEntryByID(id: string): Nullable<Node>;
  36927. /**
  36928. * Gets a node (Mesh, Camera, Light) using a given id
  36929. * @param id defines the id to search for
  36930. * @return the found node or null if not found at all
  36931. */
  36932. getNodeByID(id: string): Nullable<Node>;
  36933. /**
  36934. * Gets a node (Mesh, Camera, Light) using a given name
  36935. * @param name defines the name to search for
  36936. * @return the found node or null if not found at all.
  36937. */
  36938. getNodeByName(name: string): Nullable<Node>;
  36939. /**
  36940. * Gets a mesh using a given name
  36941. * @param name defines the name to search for
  36942. * @return the found mesh or null if not found at all.
  36943. */
  36944. getMeshByName(name: string): Nullable<AbstractMesh>;
  36945. /**
  36946. * Gets a transform node using a given name
  36947. * @param name defines the name to search for
  36948. * @return the found transform node or null if not found at all.
  36949. */
  36950. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36951. /**
  36952. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36953. * @param id defines the id to search for
  36954. * @return the found skeleton or null if not found at all.
  36955. */
  36956. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36957. /**
  36958. * Gets a skeleton using a given auto generated unique id
  36959. * @param uniqueId defines the unique id to search for
  36960. * @return the found skeleton or null if not found at all.
  36961. */
  36962. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36963. /**
  36964. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36965. * @param id defines the id to search for
  36966. * @return the found skeleton or null if not found at all.
  36967. */
  36968. getSkeletonById(id: string): Nullable<Skeleton>;
  36969. /**
  36970. * Gets a skeleton using a given name
  36971. * @param name defines the name to search for
  36972. * @return the found skeleton or null if not found at all.
  36973. */
  36974. getSkeletonByName(name: string): Nullable<Skeleton>;
  36975. /**
  36976. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36977. * @param id defines the id to search for
  36978. * @return the found morph target manager or null if not found at all.
  36979. */
  36980. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36981. /**
  36982. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36983. * @param id defines the id to search for
  36984. * @return the found morph target or null if not found at all.
  36985. */
  36986. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36987. /**
  36988. * Gets a boolean indicating if the given mesh is active
  36989. * @param mesh defines the mesh to look for
  36990. * @returns true if the mesh is in the active list
  36991. */
  36992. isActiveMesh(mesh: AbstractMesh): boolean;
  36993. /**
  36994. * Return a unique id as a string which can serve as an identifier for the scene
  36995. */
  36996. get uid(): string;
  36997. /**
  36998. * Add an externaly attached data from its key.
  36999. * This method call will fail and return false, if such key already exists.
  37000. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37001. * @param key the unique key that identifies the data
  37002. * @param data the data object to associate to the key for this Engine instance
  37003. * @return true if no such key were already present and the data was added successfully, false otherwise
  37004. */
  37005. addExternalData<T>(key: string, data: T): boolean;
  37006. /**
  37007. * Get an externaly attached data from its key
  37008. * @param key the unique key that identifies the data
  37009. * @return the associated data, if present (can be null), or undefined if not present
  37010. */
  37011. getExternalData<T>(key: string): Nullable<T>;
  37012. /**
  37013. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37014. * @param key the unique key that identifies the data
  37015. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37016. * @return the associated data, can be null if the factory returned null.
  37017. */
  37018. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37019. /**
  37020. * Remove an externaly attached data from the Engine instance
  37021. * @param key the unique key that identifies the data
  37022. * @return true if the data was successfully removed, false if it doesn't exist
  37023. */
  37024. removeExternalData(key: string): boolean;
  37025. private _evaluateSubMesh;
  37026. /**
  37027. * Clear the processed materials smart array preventing retention point in material dispose.
  37028. */
  37029. freeProcessedMaterials(): void;
  37030. private _preventFreeActiveMeshesAndRenderingGroups;
  37031. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37032. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37033. * when disposing several meshes in a row or a hierarchy of meshes.
  37034. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37035. */
  37036. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37037. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37038. /**
  37039. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37040. */
  37041. freeActiveMeshes(): void;
  37042. /**
  37043. * Clear the info related to rendering groups preventing retention points during dispose.
  37044. */
  37045. freeRenderingGroups(): void;
  37046. /** @hidden */
  37047. _isInIntermediateRendering(): boolean;
  37048. /**
  37049. * Lambda returning the list of potentially active meshes.
  37050. */
  37051. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37052. /**
  37053. * Lambda returning the list of potentially active sub meshes.
  37054. */
  37055. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37056. /**
  37057. * Lambda returning the list of potentially intersecting sub meshes.
  37058. */
  37059. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37060. /**
  37061. * Lambda returning the list of potentially colliding sub meshes.
  37062. */
  37063. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37064. private _activeMeshesFrozen;
  37065. private _skipEvaluateActiveMeshesCompletely;
  37066. /**
  37067. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37068. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37069. * @returns the current scene
  37070. */
  37071. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37072. /**
  37073. * Use this function to restart evaluating active meshes on every frame
  37074. * @returns the current scene
  37075. */
  37076. unfreezeActiveMeshes(): Scene;
  37077. private _evaluateActiveMeshes;
  37078. private _activeMesh;
  37079. /**
  37080. * Update the transform matrix to update from the current active camera
  37081. * @param force defines a boolean used to force the update even if cache is up to date
  37082. */
  37083. updateTransformMatrix(force?: boolean): void;
  37084. private _bindFrameBuffer;
  37085. /** @hidden */
  37086. _allowPostProcessClearColor: boolean;
  37087. /** @hidden */
  37088. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37089. private _processSubCameras;
  37090. private _checkIntersections;
  37091. /** @hidden */
  37092. _advancePhysicsEngineStep(step: number): void;
  37093. /**
  37094. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37095. */
  37096. getDeterministicFrameTime: () => number;
  37097. /** @hidden */
  37098. _animate(): void;
  37099. /** Execute all animations (for a frame) */
  37100. animate(): void;
  37101. /**
  37102. * Render the scene
  37103. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37104. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37105. */
  37106. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37107. /**
  37108. * Freeze all materials
  37109. * A frozen material will not be updatable but should be faster to render
  37110. */
  37111. freezeMaterials(): void;
  37112. /**
  37113. * Unfreeze all materials
  37114. * A frozen material will not be updatable but should be faster to render
  37115. */
  37116. unfreezeMaterials(): void;
  37117. /**
  37118. * Releases all held ressources
  37119. */
  37120. dispose(): void;
  37121. /**
  37122. * Gets if the scene is already disposed
  37123. */
  37124. get isDisposed(): boolean;
  37125. /**
  37126. * Call this function to reduce memory footprint of the scene.
  37127. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37128. */
  37129. clearCachedVertexData(): void;
  37130. /**
  37131. * This function will remove the local cached buffer data from texture.
  37132. * It will save memory but will prevent the texture from being rebuilt
  37133. */
  37134. cleanCachedTextureBuffer(): void;
  37135. /**
  37136. * Get the world extend vectors with an optional filter
  37137. *
  37138. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37139. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37140. */
  37141. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37142. min: Vector3;
  37143. max: Vector3;
  37144. };
  37145. /**
  37146. * Creates a ray that can be used to pick in the scene
  37147. * @param x defines the x coordinate of the origin (on-screen)
  37148. * @param y defines the y coordinate of the origin (on-screen)
  37149. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37150. * @param camera defines the camera to use for the picking
  37151. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37152. * @returns a Ray
  37153. */
  37154. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37155. /**
  37156. * Creates a ray that can be used to pick in the scene
  37157. * @param x defines the x coordinate of the origin (on-screen)
  37158. * @param y defines the y coordinate of the origin (on-screen)
  37159. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37160. * @param result defines the ray where to store the picking ray
  37161. * @param camera defines the camera to use for the picking
  37162. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37163. * @returns the current scene
  37164. */
  37165. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37166. /**
  37167. * Creates a ray that can be used to pick in the scene
  37168. * @param x defines the x coordinate of the origin (on-screen)
  37169. * @param y defines the y coordinate of the origin (on-screen)
  37170. * @param camera defines the camera to use for the picking
  37171. * @returns a Ray
  37172. */
  37173. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): 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 result defines the ray where to store the picking ray
  37179. * @param camera defines the camera to use for the picking
  37180. * @returns the current scene
  37181. */
  37182. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37183. /** Launch a ray to try to pick a mesh in the scene
  37184. * @param x position on screen
  37185. * @param y position on screen
  37186. * @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
  37187. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37188. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37189. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37190. * @returns a PickingInfo
  37191. */
  37192. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37193. /** Use the given ray to pick a mesh in the scene
  37194. * @param ray The ray to use to pick meshes
  37195. * @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
  37196. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37197. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37198. * @returns a PickingInfo
  37199. */
  37200. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37201. /**
  37202. * Launch a ray to try to pick a mesh in the scene
  37203. * @param x X position on screen
  37204. * @param y 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 camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37207. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37208. * @returns an array of PickingInfo
  37209. */
  37210. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37211. /**
  37212. * Launch a ray to try to pick a mesh in the scene
  37213. * @param ray Ray to use
  37214. * @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
  37215. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37216. * @returns an array of PickingInfo
  37217. */
  37218. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37219. /**
  37220. * Force the value of meshUnderPointer
  37221. * @param mesh defines the mesh to use
  37222. */
  37223. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37224. /**
  37225. * Gets the mesh under the pointer
  37226. * @returns a Mesh or null if no mesh is under the pointer
  37227. */
  37228. getPointerOverMesh(): Nullable<AbstractMesh>;
  37229. /** @hidden */
  37230. _rebuildGeometries(): void;
  37231. /** @hidden */
  37232. _rebuildTextures(): void;
  37233. private _getByTags;
  37234. /**
  37235. * Get a list of meshes by tags
  37236. * @param tagsQuery defines the tags query to use
  37237. * @param forEach defines a predicate used to filter results
  37238. * @returns an array of Mesh
  37239. */
  37240. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37241. /**
  37242. * Get a list of cameras by tags
  37243. * @param tagsQuery defines the tags query to use
  37244. * @param forEach defines a predicate used to filter results
  37245. * @returns an array of Camera
  37246. */
  37247. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37248. /**
  37249. * Get a list of lights by tags
  37250. * @param tagsQuery defines the tags query to use
  37251. * @param forEach defines a predicate used to filter results
  37252. * @returns an array of Light
  37253. */
  37254. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37255. /**
  37256. * Get a list of materials by tags
  37257. * @param tagsQuery defines the tags query to use
  37258. * @param forEach defines a predicate used to filter results
  37259. * @returns an array of Material
  37260. */
  37261. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37262. /**
  37263. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37264. * This allowed control for front to back rendering or reversly depending of the special needs.
  37265. *
  37266. * @param renderingGroupId The rendering group id corresponding to its index
  37267. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37268. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37269. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37270. */
  37271. 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;
  37272. /**
  37273. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37274. *
  37275. * @param renderingGroupId The rendering group id corresponding to its index
  37276. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37277. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37278. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37279. */
  37280. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37281. /**
  37282. * Gets the current auto clear configuration for one rendering group of the rendering
  37283. * manager.
  37284. * @param index the rendering group index to get the information for
  37285. * @returns The auto clear setup for the requested rendering group
  37286. */
  37287. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37288. private _blockMaterialDirtyMechanism;
  37289. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37290. get blockMaterialDirtyMechanism(): boolean;
  37291. set blockMaterialDirtyMechanism(value: boolean);
  37292. /**
  37293. * Will flag all materials as dirty to trigger new shader compilation
  37294. * @param flag defines the flag used to specify which material part must be marked as dirty
  37295. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37296. */
  37297. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37298. /** @hidden */
  37299. _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;
  37300. /** @hidden */
  37301. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37302. /** @hidden */
  37303. _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;
  37304. /** @hidden */
  37305. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37306. /** @hidden */
  37307. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37308. /** @hidden */
  37309. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37310. }
  37311. }
  37312. declare module BABYLON {
  37313. /**
  37314. * Set of assets to keep when moving a scene into an asset container.
  37315. */
  37316. export class KeepAssets extends AbstractScene {
  37317. }
  37318. /**
  37319. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37320. */
  37321. export class InstantiatedEntries {
  37322. /**
  37323. * List of new root nodes (eg. nodes with no parent)
  37324. */
  37325. rootNodes: TransformNode[];
  37326. /**
  37327. * List of new skeletons
  37328. */
  37329. skeletons: Skeleton[];
  37330. /**
  37331. * List of new animation groups
  37332. */
  37333. animationGroups: AnimationGroup[];
  37334. }
  37335. /**
  37336. * Container with a set of assets that can be added or removed from a scene.
  37337. */
  37338. export class AssetContainer extends AbstractScene {
  37339. private _wasAddedToScene;
  37340. /**
  37341. * The scene the AssetContainer belongs to.
  37342. */
  37343. scene: Scene;
  37344. /**
  37345. * Instantiates an AssetContainer.
  37346. * @param scene The scene the AssetContainer belongs to.
  37347. */
  37348. constructor(scene: Scene);
  37349. /**
  37350. * Instantiate or clone all meshes and add the new ones to the scene.
  37351. * Skeletons and animation groups will all be cloned
  37352. * @param nameFunction defines an optional function used to get new names for clones
  37353. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37354. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37355. */
  37356. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37357. /**
  37358. * Adds all the assets from the container to the scene.
  37359. */
  37360. addAllToScene(): void;
  37361. /**
  37362. * Removes all the assets in the container from the scene
  37363. */
  37364. removeAllFromScene(): void;
  37365. /**
  37366. * Disposes all the assets in the container
  37367. */
  37368. dispose(): void;
  37369. private _moveAssets;
  37370. /**
  37371. * Removes all the assets contained in the scene and adds them to the container.
  37372. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37373. */
  37374. moveAllFromScene(keepAssets?: KeepAssets): void;
  37375. /**
  37376. * 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.
  37377. * @returns the root mesh
  37378. */
  37379. createRootMesh(): Mesh;
  37380. /**
  37381. * Merge animations from this asset container into a scene
  37382. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37383. * @param animatables set of animatables to retarget to a node from the scene
  37384. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37385. */
  37386. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37387. }
  37388. }
  37389. declare module BABYLON {
  37390. /**
  37391. * Defines how the parser contract is defined.
  37392. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37393. */
  37394. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37395. /**
  37396. * Defines how the individual parser contract is defined.
  37397. * These parser can parse an individual asset
  37398. */
  37399. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37400. /**
  37401. * Base class of the scene acting as a container for the different elements composing a scene.
  37402. * This class is dynamically extended by the different components of the scene increasing
  37403. * flexibility and reducing coupling
  37404. */
  37405. export abstract class AbstractScene {
  37406. /**
  37407. * Stores the list of available parsers in the application.
  37408. */
  37409. private static _BabylonFileParsers;
  37410. /**
  37411. * Stores the list of available individual parsers in the application.
  37412. */
  37413. private static _IndividualBabylonFileParsers;
  37414. /**
  37415. * Adds a parser in the list of available ones
  37416. * @param name Defines the name of the parser
  37417. * @param parser Defines the parser to add
  37418. */
  37419. static AddParser(name: string, parser: BabylonFileParser): void;
  37420. /**
  37421. * Gets a general parser from the list of avaialble ones
  37422. * @param name Defines the name of the parser
  37423. * @returns the requested parser or null
  37424. */
  37425. static GetParser(name: string): Nullable<BabylonFileParser>;
  37426. /**
  37427. * Adds n individual parser in the list of available ones
  37428. * @param name Defines the name of the parser
  37429. * @param parser Defines the parser to add
  37430. */
  37431. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37432. /**
  37433. * Gets an individual parser from the list of avaialble ones
  37434. * @param name Defines the name of the parser
  37435. * @returns the requested parser or null
  37436. */
  37437. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37438. /**
  37439. * Parser json data and populate both a scene and its associated container object
  37440. * @param jsonData Defines the data to parse
  37441. * @param scene Defines the scene to parse the data for
  37442. * @param container Defines the container attached to the parsing sequence
  37443. * @param rootUrl Defines the root url of the data
  37444. */
  37445. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37446. /**
  37447. * Gets the list of root nodes (ie. nodes with no parent)
  37448. */
  37449. rootNodes: Node[];
  37450. /** All of the cameras added to this scene
  37451. * @see http://doc.babylonjs.com/babylon101/cameras
  37452. */
  37453. cameras: Camera[];
  37454. /**
  37455. * All of the lights added to this scene
  37456. * @see http://doc.babylonjs.com/babylon101/lights
  37457. */
  37458. lights: Light[];
  37459. /**
  37460. * All of the (abstract) meshes added to this scene
  37461. */
  37462. meshes: AbstractMesh[];
  37463. /**
  37464. * The list of skeletons added to the scene
  37465. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37466. */
  37467. skeletons: Skeleton[];
  37468. /**
  37469. * All of the particle systems added to this scene
  37470. * @see http://doc.babylonjs.com/babylon101/particles
  37471. */
  37472. particleSystems: IParticleSystem[];
  37473. /**
  37474. * Gets a list of Animations associated with the scene
  37475. */
  37476. animations: Animation[];
  37477. /**
  37478. * All of the animation groups added to this scene
  37479. * @see http://doc.babylonjs.com/how_to/group
  37480. */
  37481. animationGroups: AnimationGroup[];
  37482. /**
  37483. * All of the multi-materials added to this scene
  37484. * @see http://doc.babylonjs.com/how_to/multi_materials
  37485. */
  37486. multiMaterials: MultiMaterial[];
  37487. /**
  37488. * All of the materials added to this scene
  37489. * In the context of a Scene, it is not supposed to be modified manually.
  37490. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37491. * Note also that the order of the Material within the array is not significant and might change.
  37492. * @see http://doc.babylonjs.com/babylon101/materials
  37493. */
  37494. materials: Material[];
  37495. /**
  37496. * The list of morph target managers added to the scene
  37497. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37498. */
  37499. morphTargetManagers: MorphTargetManager[];
  37500. /**
  37501. * The list of geometries used in the scene.
  37502. */
  37503. geometries: Geometry[];
  37504. /**
  37505. * All of the tranform nodes added to this scene
  37506. * In the context of a Scene, it is not supposed to be modified manually.
  37507. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37508. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37509. * @see http://doc.babylonjs.com/how_to/transformnode
  37510. */
  37511. transformNodes: TransformNode[];
  37512. /**
  37513. * ActionManagers available on the scene.
  37514. */
  37515. actionManagers: AbstractActionManager[];
  37516. /**
  37517. * Textures to keep.
  37518. */
  37519. textures: BaseTexture[];
  37520. /**
  37521. * Environment texture for the scene
  37522. */
  37523. environmentTexture: Nullable<BaseTexture>;
  37524. /**
  37525. * @returns all meshes, lights, cameras, transformNodes and bones
  37526. */
  37527. getNodes(): Array<Node>;
  37528. }
  37529. }
  37530. declare module BABYLON {
  37531. /**
  37532. * Interface used to define options for Sound class
  37533. */
  37534. export interface ISoundOptions {
  37535. /**
  37536. * Does the sound autoplay once loaded.
  37537. */
  37538. autoplay?: boolean;
  37539. /**
  37540. * Does the sound loop after it finishes playing once.
  37541. */
  37542. loop?: boolean;
  37543. /**
  37544. * Sound's volume
  37545. */
  37546. volume?: number;
  37547. /**
  37548. * Is it a spatial sound?
  37549. */
  37550. spatialSound?: boolean;
  37551. /**
  37552. * Maximum distance to hear that sound
  37553. */
  37554. maxDistance?: number;
  37555. /**
  37556. * Uses user defined attenuation function
  37557. */
  37558. useCustomAttenuation?: boolean;
  37559. /**
  37560. * Define the roll off factor of spatial sounds.
  37561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37562. */
  37563. rolloffFactor?: number;
  37564. /**
  37565. * Define the reference distance the sound should be heard perfectly.
  37566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37567. */
  37568. refDistance?: number;
  37569. /**
  37570. * Define the distance attenuation model the sound will follow.
  37571. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37572. */
  37573. distanceModel?: string;
  37574. /**
  37575. * Defines the playback speed (1 by default)
  37576. */
  37577. playbackRate?: number;
  37578. /**
  37579. * Defines if the sound is from a streaming source
  37580. */
  37581. streaming?: boolean;
  37582. /**
  37583. * Defines an optional length (in seconds) inside the sound file
  37584. */
  37585. length?: number;
  37586. /**
  37587. * Defines an optional offset (in seconds) inside the sound file
  37588. */
  37589. offset?: number;
  37590. /**
  37591. * If true, URLs will not be required to state the audio file codec to use.
  37592. */
  37593. skipCodecCheck?: boolean;
  37594. }
  37595. /**
  37596. * Defines a sound that can be played in the application.
  37597. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37599. */
  37600. export class Sound {
  37601. /**
  37602. * The name of the sound in the scene.
  37603. */
  37604. name: string;
  37605. /**
  37606. * Does the sound autoplay once loaded.
  37607. */
  37608. autoplay: boolean;
  37609. /**
  37610. * Does the sound loop after it finishes playing once.
  37611. */
  37612. loop: boolean;
  37613. /**
  37614. * Does the sound use a custom attenuation curve to simulate the falloff
  37615. * happening when the source gets further away from the camera.
  37616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37617. */
  37618. useCustomAttenuation: boolean;
  37619. /**
  37620. * The sound track id this sound belongs to.
  37621. */
  37622. soundTrackId: number;
  37623. /**
  37624. * Is this sound currently played.
  37625. */
  37626. isPlaying: boolean;
  37627. /**
  37628. * Is this sound currently paused.
  37629. */
  37630. isPaused: boolean;
  37631. /**
  37632. * Does this sound enables spatial sound.
  37633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37634. */
  37635. spatialSound: boolean;
  37636. /**
  37637. * Define the reference distance the sound should be heard perfectly.
  37638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37639. */
  37640. refDistance: number;
  37641. /**
  37642. * Define the roll off factor of spatial sounds.
  37643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37644. */
  37645. rolloffFactor: number;
  37646. /**
  37647. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37649. */
  37650. maxDistance: number;
  37651. /**
  37652. * Define the distance attenuation model the sound will follow.
  37653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37654. */
  37655. distanceModel: string;
  37656. /**
  37657. * @hidden
  37658. * Back Compat
  37659. **/
  37660. onended: () => any;
  37661. /**
  37662. * Observable event when the current playing sound finishes.
  37663. */
  37664. onEndedObservable: Observable<Sound>;
  37665. private _panningModel;
  37666. private _playbackRate;
  37667. private _streaming;
  37668. private _startTime;
  37669. private _startOffset;
  37670. private _position;
  37671. /** @hidden */
  37672. _positionInEmitterSpace: boolean;
  37673. private _localDirection;
  37674. private _volume;
  37675. private _isReadyToPlay;
  37676. private _isDirectional;
  37677. private _readyToPlayCallback;
  37678. private _audioBuffer;
  37679. private _soundSource;
  37680. private _streamingSource;
  37681. private _soundPanner;
  37682. private _soundGain;
  37683. private _inputAudioNode;
  37684. private _outputAudioNode;
  37685. private _coneInnerAngle;
  37686. private _coneOuterAngle;
  37687. private _coneOuterGain;
  37688. private _scene;
  37689. private _connectedTransformNode;
  37690. private _customAttenuationFunction;
  37691. private _registerFunc;
  37692. private _isOutputConnected;
  37693. private _htmlAudioElement;
  37694. private _urlType;
  37695. private _length?;
  37696. private _offset?;
  37697. /** @hidden */
  37698. static _SceneComponentInitialization: (scene: Scene) => void;
  37699. /**
  37700. * Create a sound and attach it to a scene
  37701. * @param name Name of your sound
  37702. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37703. * @param scene defines the scene the sound belongs to
  37704. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37705. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37706. */
  37707. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37708. /**
  37709. * Release the sound and its associated resources
  37710. */
  37711. dispose(): void;
  37712. /**
  37713. * Gets if the sounds is ready to be played or not.
  37714. * @returns true if ready, otherwise false
  37715. */
  37716. isReady(): boolean;
  37717. private _soundLoaded;
  37718. /**
  37719. * Sets the data of the sound from an audiobuffer
  37720. * @param audioBuffer The audioBuffer containing the data
  37721. */
  37722. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37723. /**
  37724. * Updates the current sounds options such as maxdistance, loop...
  37725. * @param options A JSON object containing values named as the object properties
  37726. */
  37727. updateOptions(options: ISoundOptions): void;
  37728. private _createSpatialParameters;
  37729. private _updateSpatialParameters;
  37730. /**
  37731. * Switch the panning model to HRTF:
  37732. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37734. */
  37735. switchPanningModelToHRTF(): void;
  37736. /**
  37737. * Switch the panning model to Equal Power:
  37738. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37740. */
  37741. switchPanningModelToEqualPower(): void;
  37742. private _switchPanningModel;
  37743. /**
  37744. * Connect this sound to a sound track audio node like gain...
  37745. * @param soundTrackAudioNode the sound track audio node to connect to
  37746. */
  37747. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37748. /**
  37749. * Transform this sound into a directional source
  37750. * @param coneInnerAngle Size of the inner cone in degree
  37751. * @param coneOuterAngle Size of the outer cone in degree
  37752. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37753. */
  37754. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37755. /**
  37756. * Gets or sets the inner angle for the directional cone.
  37757. */
  37758. get directionalConeInnerAngle(): number;
  37759. /**
  37760. * Gets or sets the inner angle for the directional cone.
  37761. */
  37762. set directionalConeInnerAngle(value: number);
  37763. /**
  37764. * Gets or sets the outer angle for the directional cone.
  37765. */
  37766. get directionalConeOuterAngle(): number;
  37767. /**
  37768. * Gets or sets the outer angle for the directional cone.
  37769. */
  37770. set directionalConeOuterAngle(value: number);
  37771. /**
  37772. * Sets the position of the emitter if spatial sound is enabled
  37773. * @param newPosition Defines the new posisiton
  37774. */
  37775. setPosition(newPosition: Vector3): void;
  37776. /**
  37777. * Sets the local direction of the emitter if spatial sound is enabled
  37778. * @param newLocalDirection Defines the new local direction
  37779. */
  37780. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37781. private _updateDirection;
  37782. /** @hidden */
  37783. updateDistanceFromListener(): void;
  37784. /**
  37785. * Sets a new custom attenuation function for the sound.
  37786. * @param callback Defines the function used for the attenuation
  37787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37788. */
  37789. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37790. /**
  37791. * Play the sound
  37792. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37793. * @param offset (optional) Start the sound at a specific time in seconds
  37794. * @param length (optional) Sound duration (in seconds)
  37795. */
  37796. play(time?: number, offset?: number, length?: number): void;
  37797. private _onended;
  37798. /**
  37799. * Stop the sound
  37800. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37801. */
  37802. stop(time?: number): void;
  37803. /**
  37804. * Put the sound in pause
  37805. */
  37806. pause(): void;
  37807. /**
  37808. * Sets a dedicated volume for this sounds
  37809. * @param newVolume Define the new volume of the sound
  37810. * @param time Define time for gradual change to new volume
  37811. */
  37812. setVolume(newVolume: number, time?: number): void;
  37813. /**
  37814. * Set the sound play back rate
  37815. * @param newPlaybackRate Define the playback rate the sound should be played at
  37816. */
  37817. setPlaybackRate(newPlaybackRate: number): void;
  37818. /**
  37819. * Gets the volume of the sound.
  37820. * @returns the volume of the sound
  37821. */
  37822. getVolume(): number;
  37823. /**
  37824. * Attach the sound to a dedicated mesh
  37825. * @param transformNode The transform node to connect the sound with
  37826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37827. */
  37828. attachToMesh(transformNode: TransformNode): void;
  37829. /**
  37830. * Detach the sound from the previously attached mesh
  37831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37832. */
  37833. detachFromMesh(): void;
  37834. private _onRegisterAfterWorldMatrixUpdate;
  37835. /**
  37836. * Clone the current sound in the scene.
  37837. * @returns the new sound clone
  37838. */
  37839. clone(): Nullable<Sound>;
  37840. /**
  37841. * Gets the current underlying audio buffer containing the data
  37842. * @returns the audio buffer
  37843. */
  37844. getAudioBuffer(): Nullable<AudioBuffer>;
  37845. /**
  37846. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37847. * @returns the source node
  37848. */
  37849. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37850. /**
  37851. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37852. * @returns the gain node
  37853. */
  37854. getSoundGain(): Nullable<GainNode>;
  37855. /**
  37856. * Serializes the Sound in a JSON representation
  37857. * @returns the JSON representation of the sound
  37858. */
  37859. serialize(): any;
  37860. /**
  37861. * Parse a JSON representation of a sound to innstantiate in a given scene
  37862. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37863. * @param scene Define the scene the new parsed sound should be created in
  37864. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37865. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37866. * @returns the newly parsed sound
  37867. */
  37868. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37869. }
  37870. }
  37871. declare module BABYLON {
  37872. /**
  37873. * This defines an action helpful to play a defined sound on a triggered action.
  37874. */
  37875. export class PlaySoundAction extends Action {
  37876. private _sound;
  37877. /**
  37878. * Instantiate the action
  37879. * @param triggerOptions defines the trigger options
  37880. * @param sound defines the sound to play
  37881. * @param condition defines the trigger related conditions
  37882. */
  37883. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37884. /** @hidden */
  37885. _prepare(): void;
  37886. /**
  37887. * Execute the action and play the sound.
  37888. */
  37889. execute(): void;
  37890. /**
  37891. * Serializes the actions and its related information.
  37892. * @param parent defines the object to serialize in
  37893. * @returns the serialized object
  37894. */
  37895. serialize(parent: any): any;
  37896. }
  37897. /**
  37898. * This defines an action helpful to stop a defined sound on a triggered action.
  37899. */
  37900. export class StopSoundAction extends Action {
  37901. private _sound;
  37902. /**
  37903. * Instantiate the action
  37904. * @param triggerOptions defines the trigger options
  37905. * @param sound defines the sound to stop
  37906. * @param condition defines the trigger related conditions
  37907. */
  37908. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37909. /** @hidden */
  37910. _prepare(): void;
  37911. /**
  37912. * Execute the action and stop the sound.
  37913. */
  37914. execute(): void;
  37915. /**
  37916. * Serializes the actions and its related information.
  37917. * @param parent defines the object to serialize in
  37918. * @returns the serialized object
  37919. */
  37920. serialize(parent: any): any;
  37921. }
  37922. }
  37923. declare module BABYLON {
  37924. /**
  37925. * This defines an action responsible to change the value of a property
  37926. * by interpolating between its current value and the newly set one once triggered.
  37927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37928. */
  37929. export class InterpolateValueAction extends Action {
  37930. /**
  37931. * Defines the path of the property where the value should be interpolated
  37932. */
  37933. propertyPath: string;
  37934. /**
  37935. * Defines the target value at the end of the interpolation.
  37936. */
  37937. value: any;
  37938. /**
  37939. * Defines the time it will take for the property to interpolate to the value.
  37940. */
  37941. duration: number;
  37942. /**
  37943. * Defines if the other scene animations should be stopped when the action has been triggered
  37944. */
  37945. stopOtherAnimations?: boolean;
  37946. /**
  37947. * Defines a callback raised once the interpolation animation has been done.
  37948. */
  37949. onInterpolationDone?: () => void;
  37950. /**
  37951. * Observable triggered once the interpolation animation has been done.
  37952. */
  37953. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37954. private _target;
  37955. private _effectiveTarget;
  37956. private _property;
  37957. /**
  37958. * Instantiate the action
  37959. * @param triggerOptions defines the trigger options
  37960. * @param target defines the object containing the value to interpolate
  37961. * @param propertyPath defines the path to the property in the target object
  37962. * @param value defines the target value at the end of the interpolation
  37963. * @param duration deines the time it will take for the property to interpolate to the value.
  37964. * @param condition defines the trigger related conditions
  37965. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37966. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37967. */
  37968. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37969. /** @hidden */
  37970. _prepare(): void;
  37971. /**
  37972. * Execute the action starts the value interpolation.
  37973. */
  37974. execute(): void;
  37975. /**
  37976. * Serializes the actions and its related information.
  37977. * @param parent defines the object to serialize in
  37978. * @returns the serialized object
  37979. */
  37980. serialize(parent: any): any;
  37981. }
  37982. }
  37983. declare module BABYLON {
  37984. /**
  37985. * Options allowed during the creation of a sound track.
  37986. */
  37987. export interface ISoundTrackOptions {
  37988. /**
  37989. * The volume the sound track should take during creation
  37990. */
  37991. volume?: number;
  37992. /**
  37993. * Define if the sound track is the main sound track of the scene
  37994. */
  37995. mainTrack?: boolean;
  37996. }
  37997. /**
  37998. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37999. * It will be also used in a future release to apply effects on a specific track.
  38000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38001. */
  38002. export class SoundTrack {
  38003. /**
  38004. * The unique identifier of the sound track in the scene.
  38005. */
  38006. id: number;
  38007. /**
  38008. * The list of sounds included in the sound track.
  38009. */
  38010. soundCollection: Array<Sound>;
  38011. private _outputAudioNode;
  38012. private _scene;
  38013. private _connectedAnalyser;
  38014. private _options;
  38015. private _isInitialized;
  38016. /**
  38017. * Creates a new sound track.
  38018. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38019. * @param scene Define the scene the sound track belongs to
  38020. * @param options
  38021. */
  38022. constructor(scene: Scene, options?: ISoundTrackOptions);
  38023. private _initializeSoundTrackAudioGraph;
  38024. /**
  38025. * Release the sound track and its associated resources
  38026. */
  38027. dispose(): void;
  38028. /**
  38029. * Adds a sound to this sound track
  38030. * @param sound define the cound to add
  38031. * @ignoreNaming
  38032. */
  38033. AddSound(sound: Sound): void;
  38034. /**
  38035. * Removes a sound to this sound track
  38036. * @param sound define the cound to remove
  38037. * @ignoreNaming
  38038. */
  38039. RemoveSound(sound: Sound): void;
  38040. /**
  38041. * Set a global volume for the full sound track.
  38042. * @param newVolume Define the new volume of the sound track
  38043. */
  38044. setVolume(newVolume: number): void;
  38045. /**
  38046. * Switch the panning model to HRTF:
  38047. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38049. */
  38050. switchPanningModelToHRTF(): void;
  38051. /**
  38052. * Switch the panning model to Equal Power:
  38053. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38055. */
  38056. switchPanningModelToEqualPower(): void;
  38057. /**
  38058. * Connect the sound track to an audio analyser allowing some amazing
  38059. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38061. * @param analyser The analyser to connect to the engine
  38062. */
  38063. connectToAnalyser(analyser: Analyser): void;
  38064. }
  38065. }
  38066. declare module BABYLON {
  38067. interface AbstractScene {
  38068. /**
  38069. * The list of sounds used in the scene.
  38070. */
  38071. sounds: Nullable<Array<Sound>>;
  38072. }
  38073. interface Scene {
  38074. /**
  38075. * @hidden
  38076. * Backing field
  38077. */
  38078. _mainSoundTrack: SoundTrack;
  38079. /**
  38080. * The main sound track played by the scene.
  38081. * It cotains your primary collection of sounds.
  38082. */
  38083. mainSoundTrack: SoundTrack;
  38084. /**
  38085. * The list of sound tracks added to the scene
  38086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38087. */
  38088. soundTracks: Nullable<Array<SoundTrack>>;
  38089. /**
  38090. * Gets a sound using a given name
  38091. * @param name defines the name to search for
  38092. * @return the found sound or null if not found at all.
  38093. */
  38094. getSoundByName(name: string): Nullable<Sound>;
  38095. /**
  38096. * Gets or sets if audio support is enabled
  38097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38098. */
  38099. audioEnabled: boolean;
  38100. /**
  38101. * Gets or sets if audio will be output to headphones
  38102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38103. */
  38104. headphone: boolean;
  38105. /**
  38106. * Gets or sets custom audio listener position provider
  38107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38108. */
  38109. audioListenerPositionProvider: Nullable<() => Vector3>;
  38110. /**
  38111. * Gets or sets a refresh rate when using 3D audio positioning
  38112. */
  38113. audioPositioningRefreshRate: number;
  38114. }
  38115. /**
  38116. * Defines the sound scene component responsible to manage any sounds
  38117. * in a given scene.
  38118. */
  38119. export class AudioSceneComponent implements ISceneSerializableComponent {
  38120. /**
  38121. * The component name helpfull to identify the component in the list of scene components.
  38122. */
  38123. readonly name: string;
  38124. /**
  38125. * The scene the component belongs to.
  38126. */
  38127. scene: Scene;
  38128. private _audioEnabled;
  38129. /**
  38130. * Gets whether audio is enabled or not.
  38131. * Please use related enable/disable method to switch state.
  38132. */
  38133. get audioEnabled(): boolean;
  38134. private _headphone;
  38135. /**
  38136. * Gets whether audio is outputing to headphone or not.
  38137. * Please use the according Switch methods to change output.
  38138. */
  38139. get headphone(): boolean;
  38140. /**
  38141. * Gets or sets a refresh rate when using 3D audio positioning
  38142. */
  38143. audioPositioningRefreshRate: number;
  38144. private _audioListenerPositionProvider;
  38145. /**
  38146. * Gets the current audio listener position provider
  38147. */
  38148. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38149. /**
  38150. * Sets a custom listener position for all sounds in the scene
  38151. * By default, this is the position of the first active camera
  38152. */
  38153. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38154. /**
  38155. * Creates a new instance of the component for the given scene
  38156. * @param scene Defines the scene to register the component in
  38157. */
  38158. constructor(scene: Scene);
  38159. /**
  38160. * Registers the component in a given scene
  38161. */
  38162. register(): void;
  38163. /**
  38164. * Rebuilds the elements related to this component in case of
  38165. * context lost for instance.
  38166. */
  38167. rebuild(): void;
  38168. /**
  38169. * Serializes the component data to the specified json object
  38170. * @param serializationObject The object to serialize to
  38171. */
  38172. serialize(serializationObject: any): void;
  38173. /**
  38174. * Adds all the elements from the container to the scene
  38175. * @param container the container holding the elements
  38176. */
  38177. addFromContainer(container: AbstractScene): void;
  38178. /**
  38179. * Removes all the elements in the container from the scene
  38180. * @param container contains the elements to remove
  38181. * @param dispose if the removed element should be disposed (default: false)
  38182. */
  38183. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38184. /**
  38185. * Disposes the component and the associated ressources.
  38186. */
  38187. dispose(): void;
  38188. /**
  38189. * Disables audio in the associated scene.
  38190. */
  38191. disableAudio(): void;
  38192. /**
  38193. * Enables audio in the associated scene.
  38194. */
  38195. enableAudio(): void;
  38196. /**
  38197. * Switch audio to headphone output.
  38198. */
  38199. switchAudioModeForHeadphones(): void;
  38200. /**
  38201. * Switch audio to normal speakers.
  38202. */
  38203. switchAudioModeForNormalSpeakers(): void;
  38204. private _cachedCameraDirection;
  38205. private _cachedCameraPosition;
  38206. private _lastCheck;
  38207. private _afterRender;
  38208. }
  38209. }
  38210. declare module BABYLON {
  38211. /**
  38212. * Wraps one or more Sound objects and selects one with random weight for playback.
  38213. */
  38214. export class WeightedSound {
  38215. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38216. loop: boolean;
  38217. private _coneInnerAngle;
  38218. private _coneOuterAngle;
  38219. private _volume;
  38220. /** A Sound is currently playing. */
  38221. isPlaying: boolean;
  38222. /** A Sound is currently paused. */
  38223. isPaused: boolean;
  38224. private _sounds;
  38225. private _weights;
  38226. private _currentIndex?;
  38227. /**
  38228. * Creates a new WeightedSound from the list of sounds given.
  38229. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38230. * @param sounds Array of Sounds that will be selected from.
  38231. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38232. */
  38233. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38234. /**
  38235. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38236. */
  38237. get directionalConeInnerAngle(): number;
  38238. /**
  38239. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38240. */
  38241. set directionalConeInnerAngle(value: number);
  38242. /**
  38243. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38244. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38245. */
  38246. get directionalConeOuterAngle(): number;
  38247. /**
  38248. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38249. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38250. */
  38251. set directionalConeOuterAngle(value: number);
  38252. /**
  38253. * Playback volume.
  38254. */
  38255. get volume(): number;
  38256. /**
  38257. * Playback volume.
  38258. */
  38259. set volume(value: number);
  38260. private _onended;
  38261. /**
  38262. * Suspend playback
  38263. */
  38264. pause(): void;
  38265. /**
  38266. * Stop playback
  38267. */
  38268. stop(): void;
  38269. /**
  38270. * Start playback.
  38271. * @param startOffset Position the clip head at a specific time in seconds.
  38272. */
  38273. play(startOffset?: number): void;
  38274. }
  38275. }
  38276. declare module BABYLON {
  38277. /**
  38278. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38279. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38280. */
  38281. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38282. /**
  38283. * Gets the name of the behavior.
  38284. */
  38285. get name(): string;
  38286. /**
  38287. * The easing function used by animations
  38288. */
  38289. static EasingFunction: BackEase;
  38290. /**
  38291. * The easing mode used by animations
  38292. */
  38293. static EasingMode: number;
  38294. /**
  38295. * The duration of the animation, in milliseconds
  38296. */
  38297. transitionDuration: number;
  38298. /**
  38299. * Length of the distance animated by the transition when lower radius is reached
  38300. */
  38301. lowerRadiusTransitionRange: number;
  38302. /**
  38303. * Length of the distance animated by the transition when upper radius is reached
  38304. */
  38305. upperRadiusTransitionRange: number;
  38306. private _autoTransitionRange;
  38307. /**
  38308. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38309. */
  38310. get autoTransitionRange(): boolean;
  38311. /**
  38312. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38313. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38314. */
  38315. set autoTransitionRange(value: boolean);
  38316. private _attachedCamera;
  38317. private _onAfterCheckInputsObserver;
  38318. private _onMeshTargetChangedObserver;
  38319. /**
  38320. * Initializes the behavior.
  38321. */
  38322. init(): void;
  38323. /**
  38324. * Attaches the behavior to its arc rotate camera.
  38325. * @param camera Defines the camera to attach the behavior to
  38326. */
  38327. attach(camera: ArcRotateCamera): void;
  38328. /**
  38329. * Detaches the behavior from its current arc rotate camera.
  38330. */
  38331. detach(): void;
  38332. private _radiusIsAnimating;
  38333. private _radiusBounceTransition;
  38334. private _animatables;
  38335. private _cachedWheelPrecision;
  38336. /**
  38337. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38338. * @param radiusLimit The limit to check against.
  38339. * @return Bool to indicate if at limit.
  38340. */
  38341. private _isRadiusAtLimit;
  38342. /**
  38343. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38344. * @param radiusDelta The delta by which to animate to. Can be negative.
  38345. */
  38346. private _applyBoundRadiusAnimation;
  38347. /**
  38348. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38349. */
  38350. protected _clearAnimationLocks(): void;
  38351. /**
  38352. * Stops and removes all animations that have been applied to the camera
  38353. */
  38354. stopAllAnimations(): void;
  38355. }
  38356. }
  38357. declare module BABYLON {
  38358. /**
  38359. * 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.
  38360. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38361. */
  38362. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38363. /**
  38364. * Gets the name of the behavior.
  38365. */
  38366. get name(): string;
  38367. private _mode;
  38368. private _radiusScale;
  38369. private _positionScale;
  38370. private _defaultElevation;
  38371. private _elevationReturnTime;
  38372. private _elevationReturnWaitTime;
  38373. private _zoomStopsAnimation;
  38374. private _framingTime;
  38375. /**
  38376. * The easing function used by animations
  38377. */
  38378. static EasingFunction: ExponentialEase;
  38379. /**
  38380. * The easing mode used by animations
  38381. */
  38382. static EasingMode: number;
  38383. /**
  38384. * Sets the current mode used by the behavior
  38385. */
  38386. set mode(mode: number);
  38387. /**
  38388. * Gets current mode used by the behavior.
  38389. */
  38390. get mode(): number;
  38391. /**
  38392. * Sets the scale applied to the radius (1 by default)
  38393. */
  38394. set radiusScale(radius: number);
  38395. /**
  38396. * Gets the scale applied to the radius
  38397. */
  38398. get radiusScale(): number;
  38399. /**
  38400. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38401. */
  38402. set positionScale(scale: number);
  38403. /**
  38404. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38405. */
  38406. get positionScale(): number;
  38407. /**
  38408. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38409. * behaviour is triggered, in radians.
  38410. */
  38411. set defaultElevation(elevation: number);
  38412. /**
  38413. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38414. * behaviour is triggered, in radians.
  38415. */
  38416. get defaultElevation(): number;
  38417. /**
  38418. * Sets the time (in milliseconds) taken to return to the default beta position.
  38419. * Negative value indicates camera should not return to default.
  38420. */
  38421. set elevationReturnTime(speed: number);
  38422. /**
  38423. * Gets the time (in milliseconds) taken to return to the default beta position.
  38424. * Negative value indicates camera should not return to default.
  38425. */
  38426. get elevationReturnTime(): number;
  38427. /**
  38428. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38429. */
  38430. set elevationReturnWaitTime(time: number);
  38431. /**
  38432. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38433. */
  38434. get elevationReturnWaitTime(): number;
  38435. /**
  38436. * Sets the flag that indicates if user zooming should stop animation.
  38437. */
  38438. set zoomStopsAnimation(flag: boolean);
  38439. /**
  38440. * Gets the flag that indicates if user zooming should stop animation.
  38441. */
  38442. get zoomStopsAnimation(): boolean;
  38443. /**
  38444. * Sets the transition time when framing the mesh, in milliseconds
  38445. */
  38446. set framingTime(time: number);
  38447. /**
  38448. * Gets the transition time when framing the mesh, in milliseconds
  38449. */
  38450. get framingTime(): number;
  38451. /**
  38452. * Define if the behavior should automatically change the configured
  38453. * camera limits and sensibilities.
  38454. */
  38455. autoCorrectCameraLimitsAndSensibility: boolean;
  38456. private _onPrePointerObservableObserver;
  38457. private _onAfterCheckInputsObserver;
  38458. private _onMeshTargetChangedObserver;
  38459. private _attachedCamera;
  38460. private _isPointerDown;
  38461. private _lastInteractionTime;
  38462. /**
  38463. * Initializes the behavior.
  38464. */
  38465. init(): void;
  38466. /**
  38467. * Attaches the behavior to its arc rotate camera.
  38468. * @param camera Defines the camera to attach the behavior to
  38469. */
  38470. attach(camera: ArcRotateCamera): void;
  38471. /**
  38472. * Detaches the behavior from its current arc rotate camera.
  38473. */
  38474. detach(): void;
  38475. private _animatables;
  38476. private _betaIsAnimating;
  38477. private _betaTransition;
  38478. private _radiusTransition;
  38479. private _vectorTransition;
  38480. /**
  38481. * Targets the given mesh and updates zoom level accordingly.
  38482. * @param mesh The mesh to target.
  38483. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38484. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38485. */
  38486. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38487. /**
  38488. * Targets the given mesh with its children and updates zoom level accordingly.
  38489. * @param mesh The mesh to target.
  38490. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38491. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38492. */
  38493. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38494. /**
  38495. * Targets the given meshes with their children and updates zoom level accordingly.
  38496. * @param meshes The mesh to target.
  38497. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38498. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38499. */
  38500. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38501. /**
  38502. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38503. * @param minimumWorld Determines the smaller position of the bounding box extend
  38504. * @param maximumWorld Determines the bigger position of the bounding box extend
  38505. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38506. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38507. */
  38508. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38509. /**
  38510. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38511. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38512. * frustum width.
  38513. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38514. * to fully enclose the mesh in the viewing frustum.
  38515. */
  38516. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38517. /**
  38518. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38519. * is automatically returned to its default position (expected to be above ground plane).
  38520. */
  38521. private _maintainCameraAboveGround;
  38522. /**
  38523. * Returns the frustum slope based on the canvas ratio and camera FOV
  38524. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38525. */
  38526. private _getFrustumSlope;
  38527. /**
  38528. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38529. */
  38530. private _clearAnimationLocks;
  38531. /**
  38532. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38533. */
  38534. private _applyUserInteraction;
  38535. /**
  38536. * Stops and removes all animations that have been applied to the camera
  38537. */
  38538. stopAllAnimations(): void;
  38539. /**
  38540. * Gets a value indicating if the user is moving the camera
  38541. */
  38542. get isUserIsMoving(): boolean;
  38543. /**
  38544. * The camera can move all the way towards the mesh.
  38545. */
  38546. static IgnoreBoundsSizeMode: number;
  38547. /**
  38548. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38549. */
  38550. static FitFrustumSidesMode: number;
  38551. }
  38552. }
  38553. declare module BABYLON {
  38554. /**
  38555. * Base class for Camera Pointer Inputs.
  38556. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38557. * for example usage.
  38558. */
  38559. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38560. /**
  38561. * Defines the camera the input is attached to.
  38562. */
  38563. abstract camera: Camera;
  38564. /**
  38565. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38566. */
  38567. protected _altKey: boolean;
  38568. protected _ctrlKey: boolean;
  38569. protected _metaKey: boolean;
  38570. protected _shiftKey: boolean;
  38571. /**
  38572. * Which mouse buttons were pressed at time of last mouse event.
  38573. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38574. */
  38575. protected _buttonsPressed: number;
  38576. /**
  38577. * Defines the buttons associated with the input to handle camera move.
  38578. */
  38579. buttons: number[];
  38580. /**
  38581. * Attach the input controls to a specific dom element to get the input from.
  38582. * @param element Defines the element the controls should be listened from
  38583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38584. */
  38585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38586. /**
  38587. * Detach the current controls from the specified dom element.
  38588. * @param element Defines the element to stop listening the inputs from
  38589. */
  38590. detachControl(element: Nullable<HTMLElement>): void;
  38591. /**
  38592. * Gets the class name of the current input.
  38593. * @returns the class name
  38594. */
  38595. getClassName(): string;
  38596. /**
  38597. * Get the friendly name associated with the input class.
  38598. * @returns the input friendly name
  38599. */
  38600. getSimpleName(): string;
  38601. /**
  38602. * Called on pointer POINTERDOUBLETAP event.
  38603. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38604. */
  38605. protected onDoubleTap(type: string): void;
  38606. /**
  38607. * Called on pointer POINTERMOVE event if only a single touch is active.
  38608. * Override this method to provide functionality.
  38609. */
  38610. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38611. /**
  38612. * Called on pointer POINTERMOVE event if multiple touches are active.
  38613. * Override this method to provide functionality.
  38614. */
  38615. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38616. /**
  38617. * Called on JS contextmenu event.
  38618. * Override this method to provide functionality.
  38619. */
  38620. protected onContextMenu(evt: PointerEvent): void;
  38621. /**
  38622. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38623. * press.
  38624. * Override this method to provide functionality.
  38625. */
  38626. protected onButtonDown(evt: PointerEvent): void;
  38627. /**
  38628. * Called each time a new POINTERUP event occurs. Ie, for each button
  38629. * release.
  38630. * Override this method to provide functionality.
  38631. */
  38632. protected onButtonUp(evt: PointerEvent): void;
  38633. /**
  38634. * Called when window becomes inactive.
  38635. * Override this method to provide functionality.
  38636. */
  38637. protected onLostFocus(): void;
  38638. private _pointerInput;
  38639. private _observer;
  38640. private _onLostFocus;
  38641. private pointA;
  38642. private pointB;
  38643. }
  38644. }
  38645. declare module BABYLON {
  38646. /**
  38647. * Manage the pointers inputs to control an arc rotate camera.
  38648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38649. */
  38650. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38651. /**
  38652. * Defines the camera the input is attached to.
  38653. */
  38654. camera: ArcRotateCamera;
  38655. /**
  38656. * Gets the class name of the current input.
  38657. * @returns the class name
  38658. */
  38659. getClassName(): string;
  38660. /**
  38661. * Defines the buttons associated with the input to handle camera move.
  38662. */
  38663. buttons: number[];
  38664. /**
  38665. * Defines the pointer angular sensibility along the X axis or how fast is
  38666. * the camera rotating.
  38667. */
  38668. angularSensibilityX: number;
  38669. /**
  38670. * Defines the pointer angular sensibility along the Y axis or how fast is
  38671. * the camera rotating.
  38672. */
  38673. angularSensibilityY: number;
  38674. /**
  38675. * Defines the pointer pinch precision or how fast is the camera zooming.
  38676. */
  38677. pinchPrecision: number;
  38678. /**
  38679. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38680. * from 0.
  38681. * It defines the percentage of current camera.radius to use as delta when
  38682. * pinch zoom is used.
  38683. */
  38684. pinchDeltaPercentage: number;
  38685. /**
  38686. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38687. * that any object in the plane at the camera's target point will scale
  38688. * perfectly with finger motion.
  38689. * Overrides pinchDeltaPercentage and pinchPrecision.
  38690. */
  38691. useNaturalPinchZoom: boolean;
  38692. /**
  38693. * Defines the pointer panning sensibility or how fast is the camera moving.
  38694. */
  38695. panningSensibility: number;
  38696. /**
  38697. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38698. */
  38699. multiTouchPanning: boolean;
  38700. /**
  38701. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38702. * zoom (pinch) through multitouch.
  38703. */
  38704. multiTouchPanAndZoom: boolean;
  38705. /**
  38706. * Revers pinch action direction.
  38707. */
  38708. pinchInwards: boolean;
  38709. private _isPanClick;
  38710. private _twoFingerActivityCount;
  38711. private _isPinching;
  38712. /**
  38713. * Called on pointer POINTERMOVE event if only a single touch is active.
  38714. */
  38715. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38716. /**
  38717. * Called on pointer POINTERDOUBLETAP event.
  38718. */
  38719. protected onDoubleTap(type: string): void;
  38720. /**
  38721. * Called on pointer POINTERMOVE event if multiple touches are active.
  38722. */
  38723. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38724. /**
  38725. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38726. * press.
  38727. */
  38728. protected onButtonDown(evt: PointerEvent): void;
  38729. /**
  38730. * Called each time a new POINTERUP event occurs. Ie, for each button
  38731. * release.
  38732. */
  38733. protected onButtonUp(evt: PointerEvent): void;
  38734. /**
  38735. * Called when window becomes inactive.
  38736. */
  38737. protected onLostFocus(): void;
  38738. }
  38739. }
  38740. declare module BABYLON {
  38741. /**
  38742. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38744. */
  38745. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38746. /**
  38747. * Defines the camera the input is attached to.
  38748. */
  38749. camera: ArcRotateCamera;
  38750. /**
  38751. * Defines the list of key codes associated with the up action (increase alpha)
  38752. */
  38753. keysUp: number[];
  38754. /**
  38755. * Defines the list of key codes associated with the down action (decrease alpha)
  38756. */
  38757. keysDown: number[];
  38758. /**
  38759. * Defines the list of key codes associated with the left action (increase beta)
  38760. */
  38761. keysLeft: number[];
  38762. /**
  38763. * Defines the list of key codes associated with the right action (decrease beta)
  38764. */
  38765. keysRight: number[];
  38766. /**
  38767. * Defines the list of key codes associated with the reset action.
  38768. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38769. */
  38770. keysReset: number[];
  38771. /**
  38772. * Defines the panning sensibility of the inputs.
  38773. * (How fast is the camera panning)
  38774. */
  38775. panningSensibility: number;
  38776. /**
  38777. * Defines the zooming sensibility of the inputs.
  38778. * (How fast is the camera zooming)
  38779. */
  38780. zoomingSensibility: number;
  38781. /**
  38782. * Defines whether maintaining the alt key down switch the movement mode from
  38783. * orientation to zoom.
  38784. */
  38785. useAltToZoom: boolean;
  38786. /**
  38787. * Rotation speed of the camera
  38788. */
  38789. angularSpeed: number;
  38790. private _keys;
  38791. private _ctrlPressed;
  38792. private _altPressed;
  38793. private _onCanvasBlurObserver;
  38794. private _onKeyboardObserver;
  38795. private _engine;
  38796. private _scene;
  38797. /**
  38798. * Attach the input controls to a specific dom element to get the input from.
  38799. * @param element Defines the element the controls should be listened from
  38800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38801. */
  38802. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38803. /**
  38804. * Detach the current controls from the specified dom element.
  38805. * @param element Defines the element to stop listening the inputs from
  38806. */
  38807. detachControl(element: Nullable<HTMLElement>): void;
  38808. /**
  38809. * Update the current camera state depending on the inputs that have been used this frame.
  38810. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38811. */
  38812. checkInputs(): void;
  38813. /**
  38814. * Gets the class name of the current intput.
  38815. * @returns the class name
  38816. */
  38817. getClassName(): string;
  38818. /**
  38819. * Get the friendly name associated with the input class.
  38820. * @returns the input friendly name
  38821. */
  38822. getSimpleName(): string;
  38823. }
  38824. }
  38825. declare module BABYLON {
  38826. /**
  38827. * Manage the mouse wheel inputs to control an arc rotate camera.
  38828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38829. */
  38830. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38831. /**
  38832. * Defines the camera the input is attached to.
  38833. */
  38834. camera: ArcRotateCamera;
  38835. /**
  38836. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38837. */
  38838. wheelPrecision: number;
  38839. /**
  38840. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38841. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38842. */
  38843. wheelDeltaPercentage: number;
  38844. private _wheel;
  38845. private _observer;
  38846. private computeDeltaFromMouseWheelLegacyEvent;
  38847. /**
  38848. * Attach the input controls to a specific dom element to get the input from.
  38849. * @param element Defines the element the controls should be listened from
  38850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38851. */
  38852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38853. /**
  38854. * Detach the current controls from the specified dom element.
  38855. * @param element Defines the element to stop listening the inputs from
  38856. */
  38857. detachControl(element: Nullable<HTMLElement>): void;
  38858. /**
  38859. * Gets the class name of the current intput.
  38860. * @returns the class name
  38861. */
  38862. getClassName(): string;
  38863. /**
  38864. * Get the friendly name associated with the input class.
  38865. * @returns the input friendly name
  38866. */
  38867. getSimpleName(): string;
  38868. }
  38869. }
  38870. declare module BABYLON {
  38871. /**
  38872. * Default Inputs manager for the ArcRotateCamera.
  38873. * It groups all the default supported inputs for ease of use.
  38874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38875. */
  38876. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38877. /**
  38878. * Instantiates a new ArcRotateCameraInputsManager.
  38879. * @param camera Defines the camera the inputs belong to
  38880. */
  38881. constructor(camera: ArcRotateCamera);
  38882. /**
  38883. * Add mouse wheel input support to the input manager.
  38884. * @returns the current input manager
  38885. */
  38886. addMouseWheel(): ArcRotateCameraInputsManager;
  38887. /**
  38888. * Add pointers input support to the input manager.
  38889. * @returns the current input manager
  38890. */
  38891. addPointers(): ArcRotateCameraInputsManager;
  38892. /**
  38893. * Add keyboard input support to the input manager.
  38894. * @returns the current input manager
  38895. */
  38896. addKeyboard(): ArcRotateCameraInputsManager;
  38897. }
  38898. }
  38899. declare module BABYLON {
  38900. /**
  38901. * This represents an orbital type of camera.
  38902. *
  38903. * 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.
  38904. * 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.
  38905. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38906. */
  38907. export class ArcRotateCamera extends TargetCamera {
  38908. /**
  38909. * Defines the rotation angle of the camera along the longitudinal axis.
  38910. */
  38911. alpha: number;
  38912. /**
  38913. * Defines the rotation angle of the camera along the latitudinal axis.
  38914. */
  38915. beta: number;
  38916. /**
  38917. * Defines the radius of the camera from it s target point.
  38918. */
  38919. radius: number;
  38920. protected _target: Vector3;
  38921. protected _targetHost: Nullable<AbstractMesh>;
  38922. /**
  38923. * Defines the target point of the camera.
  38924. * The camera looks towards it form the radius distance.
  38925. */
  38926. get target(): Vector3;
  38927. set target(value: Vector3);
  38928. /**
  38929. * Define the current local position of the camera in the scene
  38930. */
  38931. get position(): Vector3;
  38932. set position(newPosition: Vector3);
  38933. protected _upVector: Vector3;
  38934. protected _upToYMatrix: Matrix;
  38935. protected _YToUpMatrix: Matrix;
  38936. /**
  38937. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38938. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38939. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38940. */
  38941. set upVector(vec: Vector3);
  38942. get upVector(): Vector3;
  38943. /**
  38944. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38945. */
  38946. setMatUp(): void;
  38947. /**
  38948. * Current inertia value on the longitudinal axis.
  38949. * The bigger this number the longer it will take for the camera to stop.
  38950. */
  38951. inertialAlphaOffset: number;
  38952. /**
  38953. * Current inertia value on the latitudinal axis.
  38954. * The bigger this number the longer it will take for the camera to stop.
  38955. */
  38956. inertialBetaOffset: number;
  38957. /**
  38958. * Current inertia value on the radius axis.
  38959. * The bigger this number the longer it will take for the camera to stop.
  38960. */
  38961. inertialRadiusOffset: number;
  38962. /**
  38963. * Minimum allowed angle on the longitudinal axis.
  38964. * This can help limiting how the Camera is able to move in the scene.
  38965. */
  38966. lowerAlphaLimit: Nullable<number>;
  38967. /**
  38968. * Maximum allowed angle on the longitudinal axis.
  38969. * This can help limiting how the Camera is able to move in the scene.
  38970. */
  38971. upperAlphaLimit: Nullable<number>;
  38972. /**
  38973. * Minimum allowed angle on the latitudinal axis.
  38974. * This can help limiting how the Camera is able to move in the scene.
  38975. */
  38976. lowerBetaLimit: number;
  38977. /**
  38978. * Maximum allowed angle on the latitudinal axis.
  38979. * This can help limiting how the Camera is able to move in the scene.
  38980. */
  38981. upperBetaLimit: number;
  38982. /**
  38983. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38984. * This can help limiting how the Camera is able to move in the scene.
  38985. */
  38986. lowerRadiusLimit: Nullable<number>;
  38987. /**
  38988. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38989. * This can help limiting how the Camera is able to move in the scene.
  38990. */
  38991. upperRadiusLimit: Nullable<number>;
  38992. /**
  38993. * Defines the current inertia value used during panning of the camera along the X axis.
  38994. */
  38995. inertialPanningX: number;
  38996. /**
  38997. * Defines the current inertia value used during panning of the camera along the Y axis.
  38998. */
  38999. inertialPanningY: number;
  39000. /**
  39001. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39002. * Basically if your fingers moves away from more than this distance you will be considered
  39003. * in pinch mode.
  39004. */
  39005. pinchToPanMaxDistance: number;
  39006. /**
  39007. * Defines the maximum distance the camera can pan.
  39008. * This could help keeping the cammera always in your scene.
  39009. */
  39010. panningDistanceLimit: Nullable<number>;
  39011. /**
  39012. * Defines the target of the camera before paning.
  39013. */
  39014. panningOriginTarget: Vector3;
  39015. /**
  39016. * Defines the value of the inertia used during panning.
  39017. * 0 would mean stop inertia and one would mean no decelleration at all.
  39018. */
  39019. panningInertia: number;
  39020. /**
  39021. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39022. */
  39023. get angularSensibilityX(): number;
  39024. set angularSensibilityX(value: number);
  39025. /**
  39026. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39027. */
  39028. get angularSensibilityY(): number;
  39029. set angularSensibilityY(value: number);
  39030. /**
  39031. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39032. */
  39033. get pinchPrecision(): number;
  39034. set pinchPrecision(value: number);
  39035. /**
  39036. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39037. * It will be used instead of pinchDeltaPrecision if different from 0.
  39038. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39039. */
  39040. get pinchDeltaPercentage(): number;
  39041. set pinchDeltaPercentage(value: number);
  39042. /**
  39043. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39044. * and pinch delta percentage.
  39045. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39046. * that any object in the plane at the camera's target point will scale
  39047. * perfectly with finger motion.
  39048. */
  39049. get useNaturalPinchZoom(): boolean;
  39050. set useNaturalPinchZoom(value: boolean);
  39051. /**
  39052. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39053. */
  39054. get panningSensibility(): number;
  39055. set panningSensibility(value: number);
  39056. /**
  39057. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39058. */
  39059. get keysUp(): number[];
  39060. set keysUp(value: number[]);
  39061. /**
  39062. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39063. */
  39064. get keysDown(): number[];
  39065. set keysDown(value: number[]);
  39066. /**
  39067. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39068. */
  39069. get keysLeft(): number[];
  39070. set keysLeft(value: number[]);
  39071. /**
  39072. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39073. */
  39074. get keysRight(): number[];
  39075. set keysRight(value: number[]);
  39076. /**
  39077. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39078. */
  39079. get wheelPrecision(): number;
  39080. set wheelPrecision(value: number);
  39081. /**
  39082. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39083. * It will be used instead of pinchDeltaPrecision if different from 0.
  39084. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39085. */
  39086. get wheelDeltaPercentage(): number;
  39087. set wheelDeltaPercentage(value: number);
  39088. /**
  39089. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39090. */
  39091. zoomOnFactor: number;
  39092. /**
  39093. * Defines a screen offset for the camera position.
  39094. */
  39095. targetScreenOffset: Vector2;
  39096. /**
  39097. * Allows the camera to be completely reversed.
  39098. * If false the camera can not arrive upside down.
  39099. */
  39100. allowUpsideDown: boolean;
  39101. /**
  39102. * Define if double tap/click is used to restore the previously saved state of the camera.
  39103. */
  39104. useInputToRestoreState: boolean;
  39105. /** @hidden */
  39106. _viewMatrix: Matrix;
  39107. /** @hidden */
  39108. _useCtrlForPanning: boolean;
  39109. /** @hidden */
  39110. _panningMouseButton: number;
  39111. /**
  39112. * Defines the input associated to the camera.
  39113. */
  39114. inputs: ArcRotateCameraInputsManager;
  39115. /** @hidden */
  39116. _reset: () => void;
  39117. /**
  39118. * Defines the allowed panning axis.
  39119. */
  39120. panningAxis: Vector3;
  39121. protected _localDirection: Vector3;
  39122. protected _transformedDirection: Vector3;
  39123. private _bouncingBehavior;
  39124. /**
  39125. * Gets the bouncing behavior of the camera if it has been enabled.
  39126. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39127. */
  39128. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39129. /**
  39130. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39131. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39132. */
  39133. get useBouncingBehavior(): boolean;
  39134. set useBouncingBehavior(value: boolean);
  39135. private _framingBehavior;
  39136. /**
  39137. * Gets the framing behavior of the camera if it has been enabled.
  39138. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39139. */
  39140. get framingBehavior(): Nullable<FramingBehavior>;
  39141. /**
  39142. * Defines if the framing behavior of the camera is enabled on the camera.
  39143. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39144. */
  39145. get useFramingBehavior(): boolean;
  39146. set useFramingBehavior(value: boolean);
  39147. private _autoRotationBehavior;
  39148. /**
  39149. * Gets the auto rotation behavior of the camera if it has been enabled.
  39150. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39151. */
  39152. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39153. /**
  39154. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39155. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39156. */
  39157. get useAutoRotationBehavior(): boolean;
  39158. set useAutoRotationBehavior(value: boolean);
  39159. /**
  39160. * Observable triggered when the mesh target has been changed on the camera.
  39161. */
  39162. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39163. /**
  39164. * Event raised when the camera is colliding with a mesh.
  39165. */
  39166. onCollide: (collidedMesh: AbstractMesh) => void;
  39167. /**
  39168. * Defines whether the camera should check collision with the objects oh the scene.
  39169. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39170. */
  39171. checkCollisions: boolean;
  39172. /**
  39173. * Defines the collision radius of the camera.
  39174. * This simulates a sphere around the camera.
  39175. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39176. */
  39177. collisionRadius: Vector3;
  39178. protected _collider: Collider;
  39179. protected _previousPosition: Vector3;
  39180. protected _collisionVelocity: Vector3;
  39181. protected _newPosition: Vector3;
  39182. protected _previousAlpha: number;
  39183. protected _previousBeta: number;
  39184. protected _previousRadius: number;
  39185. protected _collisionTriggered: boolean;
  39186. protected _targetBoundingCenter: Nullable<Vector3>;
  39187. private _computationVector;
  39188. /**
  39189. * Instantiates a new ArcRotateCamera in a given scene
  39190. * @param name Defines the name of the camera
  39191. * @param alpha Defines the camera rotation along the logitudinal axis
  39192. * @param beta Defines the camera rotation along the latitudinal axis
  39193. * @param radius Defines the camera distance from its target
  39194. * @param target Defines the camera target
  39195. * @param scene Defines the scene the camera belongs to
  39196. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39197. */
  39198. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39199. /** @hidden */
  39200. _initCache(): void;
  39201. /** @hidden */
  39202. _updateCache(ignoreParentClass?: boolean): void;
  39203. protected _getTargetPosition(): Vector3;
  39204. private _storedAlpha;
  39205. private _storedBeta;
  39206. private _storedRadius;
  39207. private _storedTarget;
  39208. private _storedTargetScreenOffset;
  39209. /**
  39210. * Stores the current state of the camera (alpha, beta, radius and target)
  39211. * @returns the camera itself
  39212. */
  39213. storeState(): Camera;
  39214. /**
  39215. * @hidden
  39216. * Restored camera state. You must call storeState() first
  39217. */
  39218. _restoreStateValues(): boolean;
  39219. /** @hidden */
  39220. _isSynchronizedViewMatrix(): boolean;
  39221. /**
  39222. * Attached controls to the current camera.
  39223. * @param element Defines the element the controls should be listened from
  39224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39225. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39226. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39227. */
  39228. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39229. /**
  39230. * Detach the current controls from the camera.
  39231. * The camera will stop reacting to inputs.
  39232. * @param element Defines the element to stop listening the inputs from
  39233. */
  39234. detachControl(element: HTMLElement): void;
  39235. /** @hidden */
  39236. _checkInputs(): void;
  39237. protected _checkLimits(): void;
  39238. /**
  39239. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39240. */
  39241. rebuildAnglesAndRadius(): void;
  39242. /**
  39243. * Use a position to define the current camera related information like alpha, beta and radius
  39244. * @param position Defines the position to set the camera at
  39245. */
  39246. setPosition(position: Vector3): void;
  39247. /**
  39248. * Defines the target the camera should look at.
  39249. * This will automatically adapt alpha beta and radius to fit within the new target.
  39250. * @param target Defines the new target as a Vector or a mesh
  39251. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39252. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39253. */
  39254. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39255. /** @hidden */
  39256. _getViewMatrix(): Matrix;
  39257. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39258. /**
  39259. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39260. * @param meshes Defines the mesh to zoom on
  39261. * @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)
  39262. */
  39263. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39264. /**
  39265. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39266. * The target will be changed but the radius
  39267. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39268. * @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)
  39269. */
  39270. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39271. min: Vector3;
  39272. max: Vector3;
  39273. distance: number;
  39274. }, doNotUpdateMaxZ?: boolean): void;
  39275. /**
  39276. * @override
  39277. * Override Camera.createRigCamera
  39278. */
  39279. createRigCamera(name: string, cameraIndex: number): Camera;
  39280. /**
  39281. * @hidden
  39282. * @override
  39283. * Override Camera._updateRigCameras
  39284. */
  39285. _updateRigCameras(): void;
  39286. /**
  39287. * Destroy the camera and release the current resources hold by it.
  39288. */
  39289. dispose(): void;
  39290. /**
  39291. * Gets the current object class name.
  39292. * @return the class name
  39293. */
  39294. getClassName(): string;
  39295. }
  39296. }
  39297. declare module BABYLON {
  39298. /**
  39299. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39300. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39301. */
  39302. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39303. /**
  39304. * Gets the name of the behavior.
  39305. */
  39306. get name(): string;
  39307. private _zoomStopsAnimation;
  39308. private _idleRotationSpeed;
  39309. private _idleRotationWaitTime;
  39310. private _idleRotationSpinupTime;
  39311. /**
  39312. * Sets the flag that indicates if user zooming should stop animation.
  39313. */
  39314. set zoomStopsAnimation(flag: boolean);
  39315. /**
  39316. * Gets the flag that indicates if user zooming should stop animation.
  39317. */
  39318. get zoomStopsAnimation(): boolean;
  39319. /**
  39320. * Sets the default speed at which the camera rotates around the model.
  39321. */
  39322. set idleRotationSpeed(speed: number);
  39323. /**
  39324. * Gets the default speed at which the camera rotates around the model.
  39325. */
  39326. get idleRotationSpeed(): number;
  39327. /**
  39328. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39329. */
  39330. set idleRotationWaitTime(time: number);
  39331. /**
  39332. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39333. */
  39334. get idleRotationWaitTime(): number;
  39335. /**
  39336. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39337. */
  39338. set idleRotationSpinupTime(time: number);
  39339. /**
  39340. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39341. */
  39342. get idleRotationSpinupTime(): number;
  39343. /**
  39344. * Gets a value indicating if the camera is currently rotating because of this behavior
  39345. */
  39346. get rotationInProgress(): boolean;
  39347. private _onPrePointerObservableObserver;
  39348. private _onAfterCheckInputsObserver;
  39349. private _attachedCamera;
  39350. private _isPointerDown;
  39351. private _lastFrameTime;
  39352. private _lastInteractionTime;
  39353. private _cameraRotationSpeed;
  39354. /**
  39355. * Initializes the behavior.
  39356. */
  39357. init(): void;
  39358. /**
  39359. * Attaches the behavior to its arc rotate camera.
  39360. * @param camera Defines the camera to attach the behavior to
  39361. */
  39362. attach(camera: ArcRotateCamera): void;
  39363. /**
  39364. * Detaches the behavior from its current arc rotate camera.
  39365. */
  39366. detach(): void;
  39367. /**
  39368. * Returns true if user is scrolling.
  39369. * @return true if user is scrolling.
  39370. */
  39371. private _userIsZooming;
  39372. private _lastFrameRadius;
  39373. private _shouldAnimationStopForInteraction;
  39374. /**
  39375. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39376. */
  39377. private _applyUserInteraction;
  39378. private _userIsMoving;
  39379. }
  39380. }
  39381. declare module BABYLON {
  39382. /**
  39383. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39384. */
  39385. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39386. private ui;
  39387. /**
  39388. * The name of the behavior
  39389. */
  39390. name: string;
  39391. /**
  39392. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39393. */
  39394. distanceAwayFromFace: number;
  39395. /**
  39396. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39397. */
  39398. distanceAwayFromBottomOfFace: number;
  39399. private _faceVectors;
  39400. private _target;
  39401. private _scene;
  39402. private _onRenderObserver;
  39403. private _tmpMatrix;
  39404. private _tmpVector;
  39405. /**
  39406. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39407. * @param ui The transform node that should be attched to the mesh
  39408. */
  39409. constructor(ui: TransformNode);
  39410. /**
  39411. * Initializes the behavior
  39412. */
  39413. init(): void;
  39414. private _closestFace;
  39415. private _zeroVector;
  39416. private _lookAtTmpMatrix;
  39417. private _lookAtToRef;
  39418. /**
  39419. * Attaches the AttachToBoxBehavior to the passed in mesh
  39420. * @param target The mesh that the specified node will be attached to
  39421. */
  39422. attach(target: Mesh): void;
  39423. /**
  39424. * Detaches the behavior from the mesh
  39425. */
  39426. detach(): void;
  39427. }
  39428. }
  39429. declare module BABYLON {
  39430. /**
  39431. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39432. */
  39433. export class FadeInOutBehavior implements Behavior<Mesh> {
  39434. /**
  39435. * Time in milliseconds to delay before fading in (Default: 0)
  39436. */
  39437. delay: number;
  39438. /**
  39439. * Time in milliseconds for the mesh to fade in (Default: 300)
  39440. */
  39441. fadeInTime: number;
  39442. private _millisecondsPerFrame;
  39443. private _hovered;
  39444. private _hoverValue;
  39445. private _ownerNode;
  39446. /**
  39447. * Instatiates the FadeInOutBehavior
  39448. */
  39449. constructor();
  39450. /**
  39451. * The name of the behavior
  39452. */
  39453. get name(): string;
  39454. /**
  39455. * Initializes the behavior
  39456. */
  39457. init(): void;
  39458. /**
  39459. * Attaches the fade behavior on the passed in mesh
  39460. * @param ownerNode The mesh that will be faded in/out once attached
  39461. */
  39462. attach(ownerNode: Mesh): void;
  39463. /**
  39464. * Detaches the behavior from the mesh
  39465. */
  39466. detach(): void;
  39467. /**
  39468. * Triggers the mesh to begin fading in or out
  39469. * @param value if the object should fade in or out (true to fade in)
  39470. */
  39471. fadeIn(value: boolean): void;
  39472. private _update;
  39473. private _setAllVisibility;
  39474. }
  39475. }
  39476. declare module BABYLON {
  39477. /**
  39478. * Class containing a set of static utilities functions for managing Pivots
  39479. * @hidden
  39480. */
  39481. export class PivotTools {
  39482. private static _PivotCached;
  39483. private static _OldPivotPoint;
  39484. private static _PivotTranslation;
  39485. private static _PivotTmpVector;
  39486. /** @hidden */
  39487. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39488. /** @hidden */
  39489. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39490. }
  39491. }
  39492. declare module BABYLON {
  39493. /**
  39494. * Class containing static functions to help procedurally build meshes
  39495. */
  39496. export class PlaneBuilder {
  39497. /**
  39498. * Creates a plane mesh
  39499. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39500. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39501. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39503. * * 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
  39504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39505. * @param name defines the name of the mesh
  39506. * @param options defines the options used to create the mesh
  39507. * @param scene defines the hosting scene
  39508. * @returns the plane mesh
  39509. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39510. */
  39511. static CreatePlane(name: string, options: {
  39512. size?: number;
  39513. width?: number;
  39514. height?: number;
  39515. sideOrientation?: number;
  39516. frontUVs?: Vector4;
  39517. backUVs?: Vector4;
  39518. updatable?: boolean;
  39519. sourcePlane?: Plane;
  39520. }, scene?: Nullable<Scene>): Mesh;
  39521. }
  39522. }
  39523. declare module BABYLON {
  39524. /**
  39525. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39526. */
  39527. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39528. private static _AnyMouseID;
  39529. /**
  39530. * Abstract mesh the behavior is set on
  39531. */
  39532. attachedNode: AbstractMesh;
  39533. private _dragPlane;
  39534. private _scene;
  39535. private _pointerObserver;
  39536. private _beforeRenderObserver;
  39537. private static _planeScene;
  39538. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39539. /**
  39540. * 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)
  39541. */
  39542. maxDragAngle: number;
  39543. /**
  39544. * @hidden
  39545. */
  39546. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39547. /**
  39548. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39549. */
  39550. currentDraggingPointerID: number;
  39551. /**
  39552. * The last position where the pointer hit the drag plane in world space
  39553. */
  39554. lastDragPosition: Vector3;
  39555. /**
  39556. * If the behavior is currently in a dragging state
  39557. */
  39558. dragging: boolean;
  39559. /**
  39560. * 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)
  39561. */
  39562. dragDeltaRatio: number;
  39563. /**
  39564. * If the drag plane orientation should be updated during the dragging (Default: true)
  39565. */
  39566. updateDragPlane: boolean;
  39567. private _debugMode;
  39568. private _moving;
  39569. /**
  39570. * Fires each time the attached mesh is dragged with the pointer
  39571. * * delta between last drag position and current drag position in world space
  39572. * * dragDistance along the drag axis
  39573. * * dragPlaneNormal normal of the current drag plane used during the drag
  39574. * * dragPlanePoint in world space where the drag intersects the drag plane
  39575. */
  39576. onDragObservable: Observable<{
  39577. delta: Vector3;
  39578. dragPlanePoint: Vector3;
  39579. dragPlaneNormal: Vector3;
  39580. dragDistance: number;
  39581. pointerId: number;
  39582. }>;
  39583. /**
  39584. * Fires each time a drag begins (eg. mouse down on mesh)
  39585. */
  39586. onDragStartObservable: Observable<{
  39587. dragPlanePoint: Vector3;
  39588. pointerId: number;
  39589. }>;
  39590. /**
  39591. * Fires each time a drag ends (eg. mouse release after drag)
  39592. */
  39593. onDragEndObservable: Observable<{
  39594. dragPlanePoint: Vector3;
  39595. pointerId: number;
  39596. }>;
  39597. /**
  39598. * If the attached mesh should be moved when dragged
  39599. */
  39600. moveAttached: boolean;
  39601. /**
  39602. * If the drag behavior will react to drag events (Default: true)
  39603. */
  39604. enabled: boolean;
  39605. /**
  39606. * If pointer events should start and release the drag (Default: true)
  39607. */
  39608. startAndReleaseDragOnPointerEvents: boolean;
  39609. /**
  39610. * If camera controls should be detached during the drag
  39611. */
  39612. detachCameraControls: boolean;
  39613. /**
  39614. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39615. */
  39616. useObjectOrientationForDragging: boolean;
  39617. private _options;
  39618. /**
  39619. * Gets the options used by the behavior
  39620. */
  39621. get options(): {
  39622. dragAxis?: Vector3;
  39623. dragPlaneNormal?: Vector3;
  39624. };
  39625. /**
  39626. * Sets the options used by the behavior
  39627. */
  39628. set options(options: {
  39629. dragAxis?: Vector3;
  39630. dragPlaneNormal?: Vector3;
  39631. });
  39632. /**
  39633. * Creates a pointer drag behavior that can be attached to a mesh
  39634. * @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)
  39635. */
  39636. constructor(options?: {
  39637. dragAxis?: Vector3;
  39638. dragPlaneNormal?: Vector3;
  39639. });
  39640. /**
  39641. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39642. */
  39643. validateDrag: (targetPosition: Vector3) => boolean;
  39644. /**
  39645. * The name of the behavior
  39646. */
  39647. get name(): string;
  39648. /**
  39649. * Initializes the behavior
  39650. */
  39651. init(): void;
  39652. private _tmpVector;
  39653. private _alternatePickedPoint;
  39654. private _worldDragAxis;
  39655. private _targetPosition;
  39656. private _attachedElement;
  39657. /**
  39658. * Attaches the drag behavior the passed in mesh
  39659. * @param ownerNode The mesh that will be dragged around once attached
  39660. * @param predicate Predicate to use for pick filtering
  39661. */
  39662. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39663. /**
  39664. * Force relase the drag action by code.
  39665. */
  39666. releaseDrag(): void;
  39667. private _startDragRay;
  39668. private _lastPointerRay;
  39669. /**
  39670. * Simulates the start of a pointer drag event on the behavior
  39671. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39672. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39673. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39674. */
  39675. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39676. private _startDrag;
  39677. private _dragDelta;
  39678. private _moveDrag;
  39679. private _pickWithRayOnDragPlane;
  39680. private _pointA;
  39681. private _pointB;
  39682. private _pointC;
  39683. private _lineA;
  39684. private _lineB;
  39685. private _localAxis;
  39686. private _lookAt;
  39687. private _updateDragPlanePosition;
  39688. /**
  39689. * Detaches the behavior from the mesh
  39690. */
  39691. detach(): void;
  39692. }
  39693. }
  39694. declare module BABYLON {
  39695. /**
  39696. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39697. */
  39698. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39699. private _dragBehaviorA;
  39700. private _dragBehaviorB;
  39701. private _startDistance;
  39702. private _initialScale;
  39703. private _targetScale;
  39704. private _ownerNode;
  39705. private _sceneRenderObserver;
  39706. /**
  39707. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39708. */
  39709. constructor();
  39710. /**
  39711. * The name of the behavior
  39712. */
  39713. get name(): string;
  39714. /**
  39715. * Initializes the behavior
  39716. */
  39717. init(): void;
  39718. private _getCurrentDistance;
  39719. /**
  39720. * Attaches the scale behavior the passed in mesh
  39721. * @param ownerNode The mesh that will be scaled around once attached
  39722. */
  39723. attach(ownerNode: Mesh): void;
  39724. /**
  39725. * Detaches the behavior from the mesh
  39726. */
  39727. detach(): void;
  39728. }
  39729. }
  39730. declare module BABYLON {
  39731. /**
  39732. * 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
  39733. */
  39734. export class SixDofDragBehavior implements Behavior<Mesh> {
  39735. private static _virtualScene;
  39736. private _ownerNode;
  39737. private _sceneRenderObserver;
  39738. private _scene;
  39739. private _targetPosition;
  39740. private _virtualOriginMesh;
  39741. private _virtualDragMesh;
  39742. private _pointerObserver;
  39743. private _moving;
  39744. private _startingOrientation;
  39745. private _attachedElement;
  39746. /**
  39747. * 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)
  39748. */
  39749. private zDragFactor;
  39750. /**
  39751. * If the object should rotate to face the drag origin
  39752. */
  39753. rotateDraggedObject: boolean;
  39754. /**
  39755. * If the behavior is currently in a dragging state
  39756. */
  39757. dragging: boolean;
  39758. /**
  39759. * 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)
  39760. */
  39761. dragDeltaRatio: number;
  39762. /**
  39763. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39764. */
  39765. currentDraggingPointerID: number;
  39766. /**
  39767. * If camera controls should be detached during the drag
  39768. */
  39769. detachCameraControls: boolean;
  39770. /**
  39771. * Fires each time a drag starts
  39772. */
  39773. onDragStartObservable: Observable<{}>;
  39774. /**
  39775. * Fires each time a drag ends (eg. mouse release after drag)
  39776. */
  39777. onDragEndObservable: Observable<{}>;
  39778. /**
  39779. * 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
  39780. */
  39781. constructor();
  39782. /**
  39783. * The name of the behavior
  39784. */
  39785. get name(): string;
  39786. /**
  39787. * Initializes the behavior
  39788. */
  39789. init(): void;
  39790. /**
  39791. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39792. */
  39793. private get _pointerCamera();
  39794. /**
  39795. * Attaches the scale behavior the passed in mesh
  39796. * @param ownerNode The mesh that will be scaled around once attached
  39797. */
  39798. attach(ownerNode: Mesh): void;
  39799. /**
  39800. * Detaches the behavior from the mesh
  39801. */
  39802. detach(): void;
  39803. }
  39804. }
  39805. declare module BABYLON {
  39806. /**
  39807. * Class used to apply inverse kinematics to bones
  39808. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39809. */
  39810. export class BoneIKController {
  39811. private static _tmpVecs;
  39812. private static _tmpQuat;
  39813. private static _tmpMats;
  39814. /**
  39815. * Gets or sets the target mesh
  39816. */
  39817. targetMesh: AbstractMesh;
  39818. /** Gets or sets the mesh used as pole */
  39819. poleTargetMesh: AbstractMesh;
  39820. /**
  39821. * Gets or sets the bone used as pole
  39822. */
  39823. poleTargetBone: Nullable<Bone>;
  39824. /**
  39825. * Gets or sets the target position
  39826. */
  39827. targetPosition: Vector3;
  39828. /**
  39829. * Gets or sets the pole target position
  39830. */
  39831. poleTargetPosition: Vector3;
  39832. /**
  39833. * Gets or sets the pole target local offset
  39834. */
  39835. poleTargetLocalOffset: Vector3;
  39836. /**
  39837. * Gets or sets the pole angle
  39838. */
  39839. poleAngle: number;
  39840. /**
  39841. * Gets or sets the mesh associated with the controller
  39842. */
  39843. mesh: AbstractMesh;
  39844. /**
  39845. * 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)
  39846. */
  39847. slerpAmount: number;
  39848. private _bone1Quat;
  39849. private _bone1Mat;
  39850. private _bone2Ang;
  39851. private _bone1;
  39852. private _bone2;
  39853. private _bone1Length;
  39854. private _bone2Length;
  39855. private _maxAngle;
  39856. private _maxReach;
  39857. private _rightHandedSystem;
  39858. private _bendAxis;
  39859. private _slerping;
  39860. private _adjustRoll;
  39861. /**
  39862. * Gets or sets maximum allowed angle
  39863. */
  39864. get maxAngle(): number;
  39865. set maxAngle(value: number);
  39866. /**
  39867. * Creates a new BoneIKController
  39868. * @param mesh defines the mesh to control
  39869. * @param bone defines the bone to control
  39870. * @param options defines options to set up the controller
  39871. */
  39872. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39873. targetMesh?: AbstractMesh;
  39874. poleTargetMesh?: AbstractMesh;
  39875. poleTargetBone?: Bone;
  39876. poleTargetLocalOffset?: Vector3;
  39877. poleAngle?: number;
  39878. bendAxis?: Vector3;
  39879. maxAngle?: number;
  39880. slerpAmount?: number;
  39881. });
  39882. private _setMaxAngle;
  39883. /**
  39884. * Force the controller to update the bones
  39885. */
  39886. update(): void;
  39887. }
  39888. }
  39889. declare module BABYLON {
  39890. /**
  39891. * Class used to make a bone look toward a point in space
  39892. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39893. */
  39894. export class BoneLookController {
  39895. private static _tmpVecs;
  39896. private static _tmpQuat;
  39897. private static _tmpMats;
  39898. /**
  39899. * The target Vector3 that the bone will look at
  39900. */
  39901. target: Vector3;
  39902. /**
  39903. * The mesh that the bone is attached to
  39904. */
  39905. mesh: AbstractMesh;
  39906. /**
  39907. * The bone that will be looking to the target
  39908. */
  39909. bone: Bone;
  39910. /**
  39911. * The up axis of the coordinate system that is used when the bone is rotated
  39912. */
  39913. upAxis: Vector3;
  39914. /**
  39915. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39916. */
  39917. upAxisSpace: Space;
  39918. /**
  39919. * Used to make an adjustment to the yaw of the bone
  39920. */
  39921. adjustYaw: number;
  39922. /**
  39923. * Used to make an adjustment to the pitch of the bone
  39924. */
  39925. adjustPitch: number;
  39926. /**
  39927. * Used to make an adjustment to the roll of the bone
  39928. */
  39929. adjustRoll: number;
  39930. /**
  39931. * 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)
  39932. */
  39933. slerpAmount: number;
  39934. private _minYaw;
  39935. private _maxYaw;
  39936. private _minPitch;
  39937. private _maxPitch;
  39938. private _minYawSin;
  39939. private _minYawCos;
  39940. private _maxYawSin;
  39941. private _maxYawCos;
  39942. private _midYawConstraint;
  39943. private _minPitchTan;
  39944. private _maxPitchTan;
  39945. private _boneQuat;
  39946. private _slerping;
  39947. private _transformYawPitch;
  39948. private _transformYawPitchInv;
  39949. private _firstFrameSkipped;
  39950. private _yawRange;
  39951. private _fowardAxis;
  39952. /**
  39953. * Gets or sets the minimum yaw angle that the bone can look to
  39954. */
  39955. get minYaw(): number;
  39956. set minYaw(value: number);
  39957. /**
  39958. * Gets or sets the maximum yaw angle that the bone can look to
  39959. */
  39960. get maxYaw(): number;
  39961. set maxYaw(value: number);
  39962. /**
  39963. * Gets or sets the minimum pitch angle that the bone can look to
  39964. */
  39965. get minPitch(): number;
  39966. set minPitch(value: number);
  39967. /**
  39968. * Gets or sets the maximum pitch angle that the bone can look to
  39969. */
  39970. get maxPitch(): number;
  39971. set maxPitch(value: number);
  39972. /**
  39973. * Create a BoneLookController
  39974. * @param mesh the mesh that the bone belongs to
  39975. * @param bone the bone that will be looking to the target
  39976. * @param target the target Vector3 to look at
  39977. * @param options optional settings:
  39978. * * maxYaw: the maximum angle the bone will yaw to
  39979. * * minYaw: the minimum angle the bone will yaw to
  39980. * * maxPitch: the maximum angle the bone will pitch to
  39981. * * minPitch: the minimum angle the bone will yaw to
  39982. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39983. * * upAxis: the up axis of the coordinate system
  39984. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39985. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39986. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39987. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39988. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39989. * * adjustRoll: used to make an adjustment to the roll of the bone
  39990. **/
  39991. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39992. maxYaw?: number;
  39993. minYaw?: number;
  39994. maxPitch?: number;
  39995. minPitch?: number;
  39996. slerpAmount?: number;
  39997. upAxis?: Vector3;
  39998. upAxisSpace?: Space;
  39999. yawAxis?: Vector3;
  40000. pitchAxis?: Vector3;
  40001. adjustYaw?: number;
  40002. adjustPitch?: number;
  40003. adjustRoll?: number;
  40004. });
  40005. /**
  40006. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40007. */
  40008. update(): void;
  40009. private _getAngleDiff;
  40010. private _getAngleBetween;
  40011. private _isAngleBetween;
  40012. }
  40013. }
  40014. declare module BABYLON {
  40015. /**
  40016. * Manage the gamepad inputs to control an arc rotate camera.
  40017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40018. */
  40019. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40020. /**
  40021. * Defines the camera the input is attached to.
  40022. */
  40023. camera: ArcRotateCamera;
  40024. /**
  40025. * Defines the gamepad the input is gathering event from.
  40026. */
  40027. gamepad: Nullable<Gamepad>;
  40028. /**
  40029. * Defines the gamepad rotation sensiblity.
  40030. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40031. */
  40032. gamepadRotationSensibility: number;
  40033. /**
  40034. * Defines the gamepad move sensiblity.
  40035. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40036. */
  40037. gamepadMoveSensibility: number;
  40038. private _yAxisScale;
  40039. /**
  40040. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40041. */
  40042. get invertYAxis(): boolean;
  40043. set invertYAxis(value: boolean);
  40044. private _onGamepadConnectedObserver;
  40045. private _onGamepadDisconnectedObserver;
  40046. /**
  40047. * Attach the input controls to a specific dom element to get the input from.
  40048. * @param element Defines the element the controls should be listened from
  40049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40050. */
  40051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40052. /**
  40053. * Detach the current controls from the specified dom element.
  40054. * @param element Defines the element to stop listening the inputs from
  40055. */
  40056. detachControl(element: Nullable<HTMLElement>): void;
  40057. /**
  40058. * Update the current camera state depending on the inputs that have been used this frame.
  40059. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40060. */
  40061. checkInputs(): void;
  40062. /**
  40063. * Gets the class name of the current intput.
  40064. * @returns the class name
  40065. */
  40066. getClassName(): string;
  40067. /**
  40068. * Get the friendly name associated with the input class.
  40069. * @returns the input friendly name
  40070. */
  40071. getSimpleName(): string;
  40072. }
  40073. }
  40074. declare module BABYLON {
  40075. interface ArcRotateCameraInputsManager {
  40076. /**
  40077. * Add orientation input support to the input manager.
  40078. * @returns the current input manager
  40079. */
  40080. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40081. }
  40082. /**
  40083. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40085. */
  40086. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40087. /**
  40088. * Defines the camera the input is attached to.
  40089. */
  40090. camera: ArcRotateCamera;
  40091. /**
  40092. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40093. */
  40094. alphaCorrection: number;
  40095. /**
  40096. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40097. */
  40098. gammaCorrection: number;
  40099. private _alpha;
  40100. private _gamma;
  40101. private _dirty;
  40102. private _deviceOrientationHandler;
  40103. /**
  40104. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40105. */
  40106. constructor();
  40107. /**
  40108. * Attach the input controls to a specific dom element to get the input from.
  40109. * @param element Defines the element the controls should be listened from
  40110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40111. */
  40112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40113. /** @hidden */
  40114. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40115. /**
  40116. * Update the current camera state depending on the inputs that have been used this frame.
  40117. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40118. */
  40119. checkInputs(): void;
  40120. /**
  40121. * Detach the current controls from the specified dom element.
  40122. * @param element Defines the element to stop listening the inputs from
  40123. */
  40124. detachControl(element: Nullable<HTMLElement>): void;
  40125. /**
  40126. * Gets the class name of the current intput.
  40127. * @returns the class name
  40128. */
  40129. getClassName(): string;
  40130. /**
  40131. * Get the friendly name associated with the input class.
  40132. * @returns the input friendly name
  40133. */
  40134. getSimpleName(): string;
  40135. }
  40136. }
  40137. declare module BABYLON {
  40138. /**
  40139. * Listen to mouse events to control the camera.
  40140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40141. */
  40142. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40143. /**
  40144. * Defines the camera the input is attached to.
  40145. */
  40146. camera: FlyCamera;
  40147. /**
  40148. * Defines if touch is enabled. (Default is true.)
  40149. */
  40150. touchEnabled: boolean;
  40151. /**
  40152. * Defines the buttons associated with the input to handle camera rotation.
  40153. */
  40154. buttons: number[];
  40155. /**
  40156. * Assign buttons for Yaw control.
  40157. */
  40158. buttonsYaw: number[];
  40159. /**
  40160. * Assign buttons for Pitch control.
  40161. */
  40162. buttonsPitch: number[];
  40163. /**
  40164. * Assign buttons for Roll control.
  40165. */
  40166. buttonsRoll: number[];
  40167. /**
  40168. * Detect if any button is being pressed while mouse is moved.
  40169. * -1 = Mouse locked.
  40170. * 0 = Left button.
  40171. * 1 = Middle Button.
  40172. * 2 = Right Button.
  40173. */
  40174. activeButton: number;
  40175. /**
  40176. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40177. * Higher values reduce its sensitivity.
  40178. */
  40179. angularSensibility: number;
  40180. private _mousemoveCallback;
  40181. private _observer;
  40182. private _rollObserver;
  40183. private previousPosition;
  40184. private noPreventDefault;
  40185. private element;
  40186. /**
  40187. * Listen to mouse events to control the camera.
  40188. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40190. */
  40191. constructor(touchEnabled?: boolean);
  40192. /**
  40193. * Attach the mouse control to the HTML DOM element.
  40194. * @param element Defines the element that listens to the input events.
  40195. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40196. */
  40197. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40198. /**
  40199. * Detach the current controls from the specified dom element.
  40200. * @param element Defines the element to stop listening the inputs from
  40201. */
  40202. detachControl(element: Nullable<HTMLElement>): void;
  40203. /**
  40204. * Gets the class name of the current input.
  40205. * @returns the class name.
  40206. */
  40207. getClassName(): string;
  40208. /**
  40209. * Get the friendly name associated with the input class.
  40210. * @returns the input's friendly name.
  40211. */
  40212. getSimpleName(): string;
  40213. private _pointerInput;
  40214. private _onMouseMove;
  40215. /**
  40216. * Rotate camera by mouse offset.
  40217. */
  40218. private rotateCamera;
  40219. }
  40220. }
  40221. declare module BABYLON {
  40222. /**
  40223. * Default Inputs manager for the FlyCamera.
  40224. * It groups all the default supported inputs for ease of use.
  40225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40226. */
  40227. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40228. /**
  40229. * Instantiates a new FlyCameraInputsManager.
  40230. * @param camera Defines the camera the inputs belong to.
  40231. */
  40232. constructor(camera: FlyCamera);
  40233. /**
  40234. * Add keyboard input support to the input manager.
  40235. * @returns the new FlyCameraKeyboardMoveInput().
  40236. */
  40237. addKeyboard(): FlyCameraInputsManager;
  40238. /**
  40239. * Add mouse input support to the input manager.
  40240. * @param touchEnabled Enable touch screen support.
  40241. * @returns the new FlyCameraMouseInput().
  40242. */
  40243. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40244. }
  40245. }
  40246. declare module BABYLON {
  40247. /**
  40248. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40249. * such as in a 3D Space Shooter or a Flight Simulator.
  40250. */
  40251. export class FlyCamera extends TargetCamera {
  40252. /**
  40253. * Define the collision ellipsoid of the camera.
  40254. * This is helpful for simulating a camera body, like a player's body.
  40255. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40256. */
  40257. ellipsoid: Vector3;
  40258. /**
  40259. * Define an offset for the position of the ellipsoid around the camera.
  40260. * This can be helpful if the camera is attached away from the player's body center,
  40261. * such as at its head.
  40262. */
  40263. ellipsoidOffset: Vector3;
  40264. /**
  40265. * Enable or disable collisions of the camera with the rest of the scene objects.
  40266. */
  40267. checkCollisions: boolean;
  40268. /**
  40269. * Enable or disable gravity on the camera.
  40270. */
  40271. applyGravity: boolean;
  40272. /**
  40273. * Define the current direction the camera is moving to.
  40274. */
  40275. cameraDirection: Vector3;
  40276. /**
  40277. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40278. * This overrides and empties cameraRotation.
  40279. */
  40280. rotationQuaternion: Quaternion;
  40281. /**
  40282. * Track Roll to maintain the wanted Rolling when looking around.
  40283. */
  40284. _trackRoll: number;
  40285. /**
  40286. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40287. */
  40288. rollCorrect: number;
  40289. /**
  40290. * Mimic a banked turn, Rolling the camera when Yawing.
  40291. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40292. */
  40293. bankedTurn: boolean;
  40294. /**
  40295. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40296. */
  40297. bankedTurnLimit: number;
  40298. /**
  40299. * Value of 0 disables the banked Roll.
  40300. * Value of 1 is equal to the Yaw angle in radians.
  40301. */
  40302. bankedTurnMultiplier: number;
  40303. /**
  40304. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40305. */
  40306. inputs: FlyCameraInputsManager;
  40307. /**
  40308. * Gets the input sensibility for mouse input.
  40309. * Higher values reduce sensitivity.
  40310. */
  40311. get angularSensibility(): number;
  40312. /**
  40313. * Sets the input sensibility for a mouse input.
  40314. * Higher values reduce sensitivity.
  40315. */
  40316. set angularSensibility(value: number);
  40317. /**
  40318. * Get the keys for camera movement forward.
  40319. */
  40320. get keysForward(): number[];
  40321. /**
  40322. * Set the keys for camera movement forward.
  40323. */
  40324. set keysForward(value: number[]);
  40325. /**
  40326. * Get the keys for camera movement backward.
  40327. */
  40328. get keysBackward(): number[];
  40329. set keysBackward(value: number[]);
  40330. /**
  40331. * Get the keys for camera movement up.
  40332. */
  40333. get keysUp(): number[];
  40334. /**
  40335. * Set the keys for camera movement up.
  40336. */
  40337. set keysUp(value: number[]);
  40338. /**
  40339. * Get the keys for camera movement down.
  40340. */
  40341. get keysDown(): number[];
  40342. /**
  40343. * Set the keys for camera movement down.
  40344. */
  40345. set keysDown(value: number[]);
  40346. /**
  40347. * Get the keys for camera movement left.
  40348. */
  40349. get keysLeft(): number[];
  40350. /**
  40351. * Set the keys for camera movement left.
  40352. */
  40353. set keysLeft(value: number[]);
  40354. /**
  40355. * Set the keys for camera movement right.
  40356. */
  40357. get keysRight(): number[];
  40358. /**
  40359. * Set the keys for camera movement right.
  40360. */
  40361. set keysRight(value: number[]);
  40362. /**
  40363. * Event raised when the camera collides with a mesh in the scene.
  40364. */
  40365. onCollide: (collidedMesh: AbstractMesh) => void;
  40366. private _collider;
  40367. private _needMoveForGravity;
  40368. private _oldPosition;
  40369. private _diffPosition;
  40370. private _newPosition;
  40371. /** @hidden */
  40372. _localDirection: Vector3;
  40373. /** @hidden */
  40374. _transformedDirection: Vector3;
  40375. /**
  40376. * Instantiates a FlyCamera.
  40377. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40378. * such as in a 3D Space Shooter or a Flight Simulator.
  40379. * @param name Define the name of the camera in the scene.
  40380. * @param position Define the starting position of the camera in the scene.
  40381. * @param scene Define the scene the camera belongs to.
  40382. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40383. */
  40384. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40385. /**
  40386. * Attach a control to the HTML DOM element.
  40387. * @param element Defines the element that listens to the input events.
  40388. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40389. */
  40390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40391. /**
  40392. * Detach a control from the HTML DOM element.
  40393. * The camera will stop reacting to that input.
  40394. * @param element Defines the element that listens to the input events.
  40395. */
  40396. detachControl(element: HTMLElement): void;
  40397. private _collisionMask;
  40398. /**
  40399. * Get the mask that the camera ignores in collision events.
  40400. */
  40401. get collisionMask(): number;
  40402. /**
  40403. * Set the mask that the camera ignores in collision events.
  40404. */
  40405. set collisionMask(mask: number);
  40406. /** @hidden */
  40407. _collideWithWorld(displacement: Vector3): void;
  40408. /** @hidden */
  40409. private _onCollisionPositionChange;
  40410. /** @hidden */
  40411. _checkInputs(): void;
  40412. /** @hidden */
  40413. _decideIfNeedsToMove(): boolean;
  40414. /** @hidden */
  40415. _updatePosition(): void;
  40416. /**
  40417. * Restore the Roll to its target value at the rate specified.
  40418. * @param rate - Higher means slower restoring.
  40419. * @hidden
  40420. */
  40421. restoreRoll(rate: number): void;
  40422. /**
  40423. * Destroy the camera and release the current resources held by it.
  40424. */
  40425. dispose(): void;
  40426. /**
  40427. * Get the current object class name.
  40428. * @returns the class name.
  40429. */
  40430. getClassName(): string;
  40431. }
  40432. }
  40433. declare module BABYLON {
  40434. /**
  40435. * Listen to keyboard events to control the camera.
  40436. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40437. */
  40438. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40439. /**
  40440. * Defines the camera the input is attached to.
  40441. */
  40442. camera: FlyCamera;
  40443. /**
  40444. * The list of keyboard keys used to control the forward move of the camera.
  40445. */
  40446. keysForward: number[];
  40447. /**
  40448. * The list of keyboard keys used to control the backward move of the camera.
  40449. */
  40450. keysBackward: number[];
  40451. /**
  40452. * The list of keyboard keys used to control the forward move of the camera.
  40453. */
  40454. keysUp: number[];
  40455. /**
  40456. * The list of keyboard keys used to control the backward move of the camera.
  40457. */
  40458. keysDown: number[];
  40459. /**
  40460. * The list of keyboard keys used to control the right strafe move of the camera.
  40461. */
  40462. keysRight: number[];
  40463. /**
  40464. * The list of keyboard keys used to control the left strafe move of the camera.
  40465. */
  40466. keysLeft: number[];
  40467. private _keys;
  40468. private _onCanvasBlurObserver;
  40469. private _onKeyboardObserver;
  40470. private _engine;
  40471. private _scene;
  40472. /**
  40473. * Attach the input controls to a specific dom element to get the input from.
  40474. * @param element Defines the element the controls should be listened from
  40475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40476. */
  40477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40478. /**
  40479. * Detach the current controls from the specified dom element.
  40480. * @param element Defines the element to stop listening the inputs from
  40481. */
  40482. detachControl(element: Nullable<HTMLElement>): void;
  40483. /**
  40484. * Gets the class name of the current intput.
  40485. * @returns the class name
  40486. */
  40487. getClassName(): string;
  40488. /** @hidden */
  40489. _onLostFocus(e: FocusEvent): void;
  40490. /**
  40491. * Get the friendly name associated with the input class.
  40492. * @returns the input friendly name
  40493. */
  40494. getSimpleName(): string;
  40495. /**
  40496. * Update the current camera state depending on the inputs that have been used this frame.
  40497. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40498. */
  40499. checkInputs(): void;
  40500. }
  40501. }
  40502. declare module BABYLON {
  40503. /**
  40504. * Manage the mouse wheel inputs to control a follow camera.
  40505. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40506. */
  40507. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40508. /**
  40509. * Defines the camera the input is attached to.
  40510. */
  40511. camera: FollowCamera;
  40512. /**
  40513. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40514. */
  40515. axisControlRadius: boolean;
  40516. /**
  40517. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40518. */
  40519. axisControlHeight: boolean;
  40520. /**
  40521. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40522. */
  40523. axisControlRotation: boolean;
  40524. /**
  40525. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40526. * relation to mouseWheel events.
  40527. */
  40528. wheelPrecision: number;
  40529. /**
  40530. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40531. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40532. */
  40533. wheelDeltaPercentage: number;
  40534. private _wheel;
  40535. private _observer;
  40536. /**
  40537. * Attach the input controls to a specific dom element to get the input from.
  40538. * @param element Defines the element the controls should be listened from
  40539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40540. */
  40541. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40542. /**
  40543. * Detach the current controls from the specified dom element.
  40544. * @param element Defines the element to stop listening the inputs from
  40545. */
  40546. detachControl(element: Nullable<HTMLElement>): void;
  40547. /**
  40548. * Gets the class name of the current intput.
  40549. * @returns the class name
  40550. */
  40551. getClassName(): string;
  40552. /**
  40553. * Get the friendly name associated with the input class.
  40554. * @returns the input friendly name
  40555. */
  40556. getSimpleName(): string;
  40557. }
  40558. }
  40559. declare module BABYLON {
  40560. /**
  40561. * Manage the pointers inputs to control an follow camera.
  40562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40563. */
  40564. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40565. /**
  40566. * Defines the camera the input is attached to.
  40567. */
  40568. camera: FollowCamera;
  40569. /**
  40570. * Gets the class name of the current input.
  40571. * @returns the class name
  40572. */
  40573. getClassName(): string;
  40574. /**
  40575. * Defines the pointer angular sensibility along the X axis or how fast is
  40576. * the camera rotating.
  40577. * A negative number will reverse the axis direction.
  40578. */
  40579. angularSensibilityX: number;
  40580. /**
  40581. * Defines the pointer angular sensibility along the Y axis or how fast is
  40582. * the camera rotating.
  40583. * A negative number will reverse the axis direction.
  40584. */
  40585. angularSensibilityY: number;
  40586. /**
  40587. * Defines the pointer pinch precision or how fast is the camera zooming.
  40588. * A negative number will reverse the axis direction.
  40589. */
  40590. pinchPrecision: number;
  40591. /**
  40592. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40593. * from 0.
  40594. * It defines the percentage of current camera.radius to use as delta when
  40595. * pinch zoom is used.
  40596. */
  40597. pinchDeltaPercentage: number;
  40598. /**
  40599. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40600. */
  40601. axisXControlRadius: boolean;
  40602. /**
  40603. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40604. */
  40605. axisXControlHeight: boolean;
  40606. /**
  40607. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40608. */
  40609. axisXControlRotation: boolean;
  40610. /**
  40611. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40612. */
  40613. axisYControlRadius: boolean;
  40614. /**
  40615. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40616. */
  40617. axisYControlHeight: boolean;
  40618. /**
  40619. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40620. */
  40621. axisYControlRotation: boolean;
  40622. /**
  40623. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40624. */
  40625. axisPinchControlRadius: boolean;
  40626. /**
  40627. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40628. */
  40629. axisPinchControlHeight: boolean;
  40630. /**
  40631. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40632. */
  40633. axisPinchControlRotation: boolean;
  40634. /**
  40635. * Log error messages if basic misconfiguration has occurred.
  40636. */
  40637. warningEnable: boolean;
  40638. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40639. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40640. private _warningCounter;
  40641. private _warning;
  40642. }
  40643. }
  40644. declare module BABYLON {
  40645. /**
  40646. * Default Inputs manager for the FollowCamera.
  40647. * It groups all the default supported inputs for ease of use.
  40648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40649. */
  40650. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40651. /**
  40652. * Instantiates a new FollowCameraInputsManager.
  40653. * @param camera Defines the camera the inputs belong to
  40654. */
  40655. constructor(camera: FollowCamera);
  40656. /**
  40657. * Add keyboard input support to the input manager.
  40658. * @returns the current input manager
  40659. */
  40660. addKeyboard(): FollowCameraInputsManager;
  40661. /**
  40662. * Add mouse wheel input support to the input manager.
  40663. * @returns the current input manager
  40664. */
  40665. addMouseWheel(): FollowCameraInputsManager;
  40666. /**
  40667. * Add pointers input support to the input manager.
  40668. * @returns the current input manager
  40669. */
  40670. addPointers(): FollowCameraInputsManager;
  40671. /**
  40672. * Add orientation input support to the input manager.
  40673. * @returns the current input manager
  40674. */
  40675. addVRDeviceOrientation(): FollowCameraInputsManager;
  40676. }
  40677. }
  40678. declare module BABYLON {
  40679. /**
  40680. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40681. * an arc rotate version arcFollowCamera are available.
  40682. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40683. */
  40684. export class FollowCamera extends TargetCamera {
  40685. /**
  40686. * Distance the follow camera should follow an object at
  40687. */
  40688. radius: number;
  40689. /**
  40690. * Minimum allowed distance of the camera to the axis of rotation
  40691. * (The camera can not get closer).
  40692. * This can help limiting how the Camera is able to move in the scene.
  40693. */
  40694. lowerRadiusLimit: Nullable<number>;
  40695. /**
  40696. * Maximum allowed distance of the camera to the axis of rotation
  40697. * (The camera can not get further).
  40698. * This can help limiting how the Camera is able to move in the scene.
  40699. */
  40700. upperRadiusLimit: Nullable<number>;
  40701. /**
  40702. * Define a rotation offset between the camera and the object it follows
  40703. */
  40704. rotationOffset: number;
  40705. /**
  40706. * Minimum allowed angle to camera position relative to target object.
  40707. * This can help limiting how the Camera is able to move in the scene.
  40708. */
  40709. lowerRotationOffsetLimit: Nullable<number>;
  40710. /**
  40711. * Maximum allowed angle to camera position relative to target object.
  40712. * This can help limiting how the Camera is able to move in the scene.
  40713. */
  40714. upperRotationOffsetLimit: Nullable<number>;
  40715. /**
  40716. * Define a height offset between the camera and the object it follows.
  40717. * It can help following an object from the top (like a car chaing a plane)
  40718. */
  40719. heightOffset: number;
  40720. /**
  40721. * Minimum allowed height of camera position relative to target object.
  40722. * This can help limiting how the Camera is able to move in the scene.
  40723. */
  40724. lowerHeightOffsetLimit: Nullable<number>;
  40725. /**
  40726. * Maximum allowed height of camera position relative to target object.
  40727. * This can help limiting how the Camera is able to move in the scene.
  40728. */
  40729. upperHeightOffsetLimit: Nullable<number>;
  40730. /**
  40731. * Define how fast the camera can accelerate to follow it s target.
  40732. */
  40733. cameraAcceleration: number;
  40734. /**
  40735. * Define the speed limit of the camera following an object.
  40736. */
  40737. maxCameraSpeed: number;
  40738. /**
  40739. * Define the target of the camera.
  40740. */
  40741. lockedTarget: Nullable<AbstractMesh>;
  40742. /**
  40743. * Defines the input associated with the camera.
  40744. */
  40745. inputs: FollowCameraInputsManager;
  40746. /**
  40747. * Instantiates the follow camera.
  40748. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40749. * @param name Define the name of the camera in the scene
  40750. * @param position Define the position of the camera
  40751. * @param scene Define the scene the camera belong to
  40752. * @param lockedTarget Define the target of the camera
  40753. */
  40754. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40755. private _follow;
  40756. /**
  40757. * Attached controls to the current camera.
  40758. * @param element Defines the element the controls should be listened from
  40759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40760. */
  40761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40762. /**
  40763. * Detach the current controls from the camera.
  40764. * The camera will stop reacting to inputs.
  40765. * @param element Defines the element to stop listening the inputs from
  40766. */
  40767. detachControl(element: HTMLElement): void;
  40768. /** @hidden */
  40769. _checkInputs(): void;
  40770. private _checkLimits;
  40771. /**
  40772. * Gets the camera class name.
  40773. * @returns the class name
  40774. */
  40775. getClassName(): string;
  40776. }
  40777. /**
  40778. * Arc Rotate version of the follow camera.
  40779. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40780. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40781. */
  40782. export class ArcFollowCamera extends TargetCamera {
  40783. /** The longitudinal angle of the camera */
  40784. alpha: number;
  40785. /** The latitudinal angle of the camera */
  40786. beta: number;
  40787. /** The radius of the camera from its target */
  40788. radius: number;
  40789. /** Define the camera target (the messh it should follow) */
  40790. target: Nullable<AbstractMesh>;
  40791. private _cartesianCoordinates;
  40792. /**
  40793. * Instantiates a new ArcFollowCamera
  40794. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40795. * @param name Define the name of the camera
  40796. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40797. * @param beta Define the rotation angle of the camera around the elevation axis
  40798. * @param radius Define the radius of the camera from its target point
  40799. * @param target Define the target of the camera
  40800. * @param scene Define the scene the camera belongs to
  40801. */
  40802. constructor(name: string,
  40803. /** The longitudinal angle of the camera */
  40804. alpha: number,
  40805. /** The latitudinal angle of the camera */
  40806. beta: number,
  40807. /** The radius of the camera from its target */
  40808. radius: number,
  40809. /** Define the camera target (the messh it should follow) */
  40810. target: Nullable<AbstractMesh>, scene: Scene);
  40811. private _follow;
  40812. /** @hidden */
  40813. _checkInputs(): void;
  40814. /**
  40815. * Returns the class name of the object.
  40816. * It is mostly used internally for serialization purposes.
  40817. */
  40818. getClassName(): string;
  40819. }
  40820. }
  40821. declare module BABYLON {
  40822. /**
  40823. * Manage the keyboard inputs to control the movement of a follow camera.
  40824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40825. */
  40826. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40827. /**
  40828. * Defines the camera the input is attached to.
  40829. */
  40830. camera: FollowCamera;
  40831. /**
  40832. * Defines the list of key codes associated with the up action (increase heightOffset)
  40833. */
  40834. keysHeightOffsetIncr: number[];
  40835. /**
  40836. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40837. */
  40838. keysHeightOffsetDecr: number[];
  40839. /**
  40840. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40841. */
  40842. keysHeightOffsetModifierAlt: boolean;
  40843. /**
  40844. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40845. */
  40846. keysHeightOffsetModifierCtrl: boolean;
  40847. /**
  40848. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40849. */
  40850. keysHeightOffsetModifierShift: boolean;
  40851. /**
  40852. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40853. */
  40854. keysRotationOffsetIncr: number[];
  40855. /**
  40856. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40857. */
  40858. keysRotationOffsetDecr: number[];
  40859. /**
  40860. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40861. */
  40862. keysRotationOffsetModifierAlt: boolean;
  40863. /**
  40864. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40865. */
  40866. keysRotationOffsetModifierCtrl: boolean;
  40867. /**
  40868. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40869. */
  40870. keysRotationOffsetModifierShift: boolean;
  40871. /**
  40872. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40873. */
  40874. keysRadiusIncr: number[];
  40875. /**
  40876. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40877. */
  40878. keysRadiusDecr: number[];
  40879. /**
  40880. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40881. */
  40882. keysRadiusModifierAlt: boolean;
  40883. /**
  40884. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40885. */
  40886. keysRadiusModifierCtrl: boolean;
  40887. /**
  40888. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40889. */
  40890. keysRadiusModifierShift: boolean;
  40891. /**
  40892. * Defines the rate of change of heightOffset.
  40893. */
  40894. heightSensibility: number;
  40895. /**
  40896. * Defines the rate of change of rotationOffset.
  40897. */
  40898. rotationSensibility: number;
  40899. /**
  40900. * Defines the rate of change of radius.
  40901. */
  40902. radiusSensibility: number;
  40903. private _keys;
  40904. private _ctrlPressed;
  40905. private _altPressed;
  40906. private _shiftPressed;
  40907. private _onCanvasBlurObserver;
  40908. private _onKeyboardObserver;
  40909. private _engine;
  40910. private _scene;
  40911. /**
  40912. * Attach the input controls to a specific dom element to get the input from.
  40913. * @param element Defines the element the controls should be listened from
  40914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40915. */
  40916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40917. /**
  40918. * Detach the current controls from the specified dom element.
  40919. * @param element Defines the element to stop listening the inputs from
  40920. */
  40921. detachControl(element: Nullable<HTMLElement>): void;
  40922. /**
  40923. * Update the current camera state depending on the inputs that have been used this frame.
  40924. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40925. */
  40926. checkInputs(): void;
  40927. /**
  40928. * Gets the class name of the current input.
  40929. * @returns the class name
  40930. */
  40931. getClassName(): string;
  40932. /**
  40933. * Get the friendly name associated with the input class.
  40934. * @returns the input friendly name
  40935. */
  40936. getSimpleName(): string;
  40937. /**
  40938. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40939. * allow modification of the heightOffset value.
  40940. */
  40941. private _modifierHeightOffset;
  40942. /**
  40943. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40944. * allow modification of the rotationOffset value.
  40945. */
  40946. private _modifierRotationOffset;
  40947. /**
  40948. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40949. * allow modification of the radius value.
  40950. */
  40951. private _modifierRadius;
  40952. }
  40953. }
  40954. declare module BABYLON {
  40955. interface FreeCameraInputsManager {
  40956. /**
  40957. * @hidden
  40958. */
  40959. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40960. /**
  40961. * Add orientation input support to the input manager.
  40962. * @returns the current input manager
  40963. */
  40964. addDeviceOrientation(): FreeCameraInputsManager;
  40965. }
  40966. /**
  40967. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40968. * Screen rotation is taken into account.
  40969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40970. */
  40971. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40972. private _camera;
  40973. private _screenOrientationAngle;
  40974. private _constantTranform;
  40975. private _screenQuaternion;
  40976. private _alpha;
  40977. private _beta;
  40978. private _gamma;
  40979. /**
  40980. * Can be used to detect if a device orientation sensor is available on a device
  40981. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40982. * @returns a promise that will resolve on orientation change
  40983. */
  40984. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40985. /**
  40986. * @hidden
  40987. */
  40988. _onDeviceOrientationChangedObservable: Observable<void>;
  40989. /**
  40990. * Instantiates a new input
  40991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40992. */
  40993. constructor();
  40994. /**
  40995. * Define the camera controlled by the input.
  40996. */
  40997. get camera(): FreeCamera;
  40998. set camera(camera: FreeCamera);
  40999. /**
  41000. * Attach the input controls to a specific dom element to get the input from.
  41001. * @param element Defines the element the controls should be listened from
  41002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41003. */
  41004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41005. private _orientationChanged;
  41006. private _deviceOrientation;
  41007. /**
  41008. * Detach the current controls from the specified dom element.
  41009. * @param element Defines the element to stop listening the inputs from
  41010. */
  41011. detachControl(element: Nullable<HTMLElement>): void;
  41012. /**
  41013. * Update the current camera state depending on the inputs that have been used this frame.
  41014. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41015. */
  41016. checkInputs(): void;
  41017. /**
  41018. * Gets the class name of the current intput.
  41019. * @returns the class name
  41020. */
  41021. getClassName(): string;
  41022. /**
  41023. * Get the friendly name associated with the input class.
  41024. * @returns the input friendly name
  41025. */
  41026. getSimpleName(): string;
  41027. }
  41028. }
  41029. declare module BABYLON {
  41030. /**
  41031. * Manage the gamepad inputs to control a free camera.
  41032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41033. */
  41034. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41035. /**
  41036. * Define the camera the input is attached to.
  41037. */
  41038. camera: FreeCamera;
  41039. /**
  41040. * Define the Gamepad controlling the input
  41041. */
  41042. gamepad: Nullable<Gamepad>;
  41043. /**
  41044. * Defines the gamepad rotation sensiblity.
  41045. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41046. */
  41047. gamepadAngularSensibility: number;
  41048. /**
  41049. * Defines the gamepad move sensiblity.
  41050. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41051. */
  41052. gamepadMoveSensibility: number;
  41053. private _yAxisScale;
  41054. /**
  41055. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41056. */
  41057. get invertYAxis(): boolean;
  41058. set invertYAxis(value: boolean);
  41059. private _onGamepadConnectedObserver;
  41060. private _onGamepadDisconnectedObserver;
  41061. private _cameraTransform;
  41062. private _deltaTransform;
  41063. private _vector3;
  41064. private _vector2;
  41065. /**
  41066. * Attach the input controls to a specific dom element to get the input from.
  41067. * @param element Defines the element the controls should be listened from
  41068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41069. */
  41070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41071. /**
  41072. * Detach the current controls from the specified dom element.
  41073. * @param element Defines the element to stop listening the inputs from
  41074. */
  41075. detachControl(element: Nullable<HTMLElement>): void;
  41076. /**
  41077. * Update the current camera state depending on the inputs that have been used this frame.
  41078. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41079. */
  41080. checkInputs(): void;
  41081. /**
  41082. * Gets the class name of the current intput.
  41083. * @returns the class name
  41084. */
  41085. getClassName(): string;
  41086. /**
  41087. * Get the friendly name associated with the input class.
  41088. * @returns the input friendly name
  41089. */
  41090. getSimpleName(): string;
  41091. }
  41092. }
  41093. declare module BABYLON {
  41094. /**
  41095. * Defines the potential axis of a Joystick
  41096. */
  41097. export enum JoystickAxis {
  41098. /** X axis */
  41099. X = 0,
  41100. /** Y axis */
  41101. Y = 1,
  41102. /** Z axis */
  41103. Z = 2
  41104. }
  41105. /**
  41106. * Class used to define virtual joystick (used in touch mode)
  41107. */
  41108. export class VirtualJoystick {
  41109. /**
  41110. * Gets or sets a boolean indicating that left and right values must be inverted
  41111. */
  41112. reverseLeftRight: boolean;
  41113. /**
  41114. * Gets or sets a boolean indicating that up and down values must be inverted
  41115. */
  41116. reverseUpDown: boolean;
  41117. /**
  41118. * Gets the offset value for the position (ie. the change of the position value)
  41119. */
  41120. deltaPosition: Vector3;
  41121. /**
  41122. * Gets a boolean indicating if the virtual joystick was pressed
  41123. */
  41124. pressed: boolean;
  41125. /**
  41126. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41127. */
  41128. static Canvas: Nullable<HTMLCanvasElement>;
  41129. private static _globalJoystickIndex;
  41130. private static vjCanvasContext;
  41131. private static vjCanvasWidth;
  41132. private static vjCanvasHeight;
  41133. private static halfWidth;
  41134. private _action;
  41135. private _axisTargetedByLeftAndRight;
  41136. private _axisTargetedByUpAndDown;
  41137. private _joystickSensibility;
  41138. private _inversedSensibility;
  41139. private _joystickPointerID;
  41140. private _joystickColor;
  41141. private _joystickPointerPos;
  41142. private _joystickPreviousPointerPos;
  41143. private _joystickPointerStartPos;
  41144. private _deltaJoystickVector;
  41145. private _leftJoystick;
  41146. private _touches;
  41147. private _onPointerDownHandlerRef;
  41148. private _onPointerMoveHandlerRef;
  41149. private _onPointerUpHandlerRef;
  41150. private _onResize;
  41151. /**
  41152. * Creates a new virtual joystick
  41153. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41154. */
  41155. constructor(leftJoystick?: boolean);
  41156. /**
  41157. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41158. * @param newJoystickSensibility defines the new sensibility
  41159. */
  41160. setJoystickSensibility(newJoystickSensibility: number): void;
  41161. private _onPointerDown;
  41162. private _onPointerMove;
  41163. private _onPointerUp;
  41164. /**
  41165. * Change the color of the virtual joystick
  41166. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41167. */
  41168. setJoystickColor(newColor: string): void;
  41169. /**
  41170. * Defines a callback to call when the joystick is touched
  41171. * @param action defines the callback
  41172. */
  41173. setActionOnTouch(action: () => any): void;
  41174. /**
  41175. * Defines which axis you'd like to control for left & right
  41176. * @param axis defines the axis to use
  41177. */
  41178. setAxisForLeftRight(axis: JoystickAxis): void;
  41179. /**
  41180. * Defines which axis you'd like to control for up & down
  41181. * @param axis defines the axis to use
  41182. */
  41183. setAxisForUpDown(axis: JoystickAxis): void;
  41184. private _drawVirtualJoystick;
  41185. /**
  41186. * Release internal HTML canvas
  41187. */
  41188. releaseCanvas(): void;
  41189. }
  41190. }
  41191. declare module BABYLON {
  41192. interface FreeCameraInputsManager {
  41193. /**
  41194. * Add virtual joystick input support to the input manager.
  41195. * @returns the current input manager
  41196. */
  41197. addVirtualJoystick(): FreeCameraInputsManager;
  41198. }
  41199. /**
  41200. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41202. */
  41203. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41204. /**
  41205. * Defines the camera the input is attached to.
  41206. */
  41207. camera: FreeCamera;
  41208. private _leftjoystick;
  41209. private _rightjoystick;
  41210. /**
  41211. * Gets the left stick of the virtual joystick.
  41212. * @returns The virtual Joystick
  41213. */
  41214. getLeftJoystick(): VirtualJoystick;
  41215. /**
  41216. * Gets the right stick of the virtual joystick.
  41217. * @returns The virtual Joystick
  41218. */
  41219. getRightJoystick(): VirtualJoystick;
  41220. /**
  41221. * Update the current camera state depending on the inputs that have been used this frame.
  41222. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41223. */
  41224. checkInputs(): void;
  41225. /**
  41226. * Attach the input controls to a specific dom element to get the input from.
  41227. * @param element Defines the element the controls should be listened from
  41228. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41229. */
  41230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41231. /**
  41232. * Detach the current controls from the specified dom element.
  41233. * @param element Defines the element to stop listening the inputs from
  41234. */
  41235. detachControl(element: Nullable<HTMLElement>): void;
  41236. /**
  41237. * Gets the class name of the current intput.
  41238. * @returns the class name
  41239. */
  41240. getClassName(): string;
  41241. /**
  41242. * Get the friendly name associated with the input class.
  41243. * @returns the input friendly name
  41244. */
  41245. getSimpleName(): string;
  41246. }
  41247. }
  41248. declare module BABYLON {
  41249. /**
  41250. * This represents a FPS type of camera controlled by touch.
  41251. * This is like a universal camera minus the Gamepad controls.
  41252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41253. */
  41254. export class TouchCamera extends FreeCamera {
  41255. /**
  41256. * Defines the touch sensibility for rotation.
  41257. * The higher the faster.
  41258. */
  41259. get touchAngularSensibility(): number;
  41260. set touchAngularSensibility(value: number);
  41261. /**
  41262. * Defines the touch sensibility for move.
  41263. * The higher the faster.
  41264. */
  41265. get touchMoveSensibility(): number;
  41266. set touchMoveSensibility(value: number);
  41267. /**
  41268. * Instantiates a new touch camera.
  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. * @param name Define the name of the camera in the scene
  41273. * @param position Define the start position of the camera in the scene
  41274. * @param scene Define the scene the camera belongs to
  41275. */
  41276. constructor(name: string, position: Vector3, scene: Scene);
  41277. /**
  41278. * Gets the current object class name.
  41279. * @return the class name
  41280. */
  41281. getClassName(): string;
  41282. /** @hidden */
  41283. _setupInputs(): void;
  41284. }
  41285. }
  41286. declare module BABYLON {
  41287. /**
  41288. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41289. * being tilted forward or back and left or right.
  41290. */
  41291. export class DeviceOrientationCamera extends FreeCamera {
  41292. private _initialQuaternion;
  41293. private _quaternionCache;
  41294. private _tmpDragQuaternion;
  41295. private _disablePointerInputWhenUsingDeviceOrientation;
  41296. /**
  41297. * Creates a new device orientation camera
  41298. * @param name The name of the camera
  41299. * @param position The start position camera
  41300. * @param scene The scene the camera belongs to
  41301. */
  41302. constructor(name: string, position: Vector3, scene: Scene);
  41303. /**
  41304. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41305. */
  41306. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41307. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41308. private _dragFactor;
  41309. /**
  41310. * Enabled turning on the y axis when the orientation sensor is active
  41311. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41312. */
  41313. enableHorizontalDragging(dragFactor?: number): void;
  41314. /**
  41315. * Gets the current instance class name ("DeviceOrientationCamera").
  41316. * This helps avoiding instanceof at run time.
  41317. * @returns the class name
  41318. */
  41319. getClassName(): string;
  41320. /**
  41321. * @hidden
  41322. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41323. */
  41324. _checkInputs(): void;
  41325. /**
  41326. * Reset the camera to its default orientation on the specified axis only.
  41327. * @param axis The axis to reset
  41328. */
  41329. resetToCurrentRotation(axis?: Axis): void;
  41330. }
  41331. }
  41332. declare module BABYLON {
  41333. /**
  41334. * Defines supported buttons for XBox360 compatible gamepads
  41335. */
  41336. export enum Xbox360Button {
  41337. /** A */
  41338. A = 0,
  41339. /** B */
  41340. B = 1,
  41341. /** X */
  41342. X = 2,
  41343. /** Y */
  41344. Y = 3,
  41345. /** Left button */
  41346. LB = 4,
  41347. /** Right button */
  41348. RB = 5,
  41349. /** Back */
  41350. Back = 8,
  41351. /** Start */
  41352. Start = 9,
  41353. /** Left stick */
  41354. LeftStick = 10,
  41355. /** Right stick */
  41356. RightStick = 11
  41357. }
  41358. /** Defines values for XBox360 DPad */
  41359. export enum Xbox360Dpad {
  41360. /** Up */
  41361. Up = 12,
  41362. /** Down */
  41363. Down = 13,
  41364. /** Left */
  41365. Left = 14,
  41366. /** Right */
  41367. Right = 15
  41368. }
  41369. /**
  41370. * Defines a XBox360 gamepad
  41371. */
  41372. export class Xbox360Pad extends Gamepad {
  41373. private _leftTrigger;
  41374. private _rightTrigger;
  41375. private _onlefttriggerchanged;
  41376. private _onrighttriggerchanged;
  41377. private _onbuttondown;
  41378. private _onbuttonup;
  41379. private _ondpaddown;
  41380. private _ondpadup;
  41381. /** Observable raised when a button is pressed */
  41382. onButtonDownObservable: Observable<Xbox360Button>;
  41383. /** Observable raised when a button is released */
  41384. onButtonUpObservable: Observable<Xbox360Button>;
  41385. /** Observable raised when a pad is pressed */
  41386. onPadDownObservable: Observable<Xbox360Dpad>;
  41387. /** Observable raised when a pad is released */
  41388. onPadUpObservable: Observable<Xbox360Dpad>;
  41389. private _buttonA;
  41390. private _buttonB;
  41391. private _buttonX;
  41392. private _buttonY;
  41393. private _buttonBack;
  41394. private _buttonStart;
  41395. private _buttonLB;
  41396. private _buttonRB;
  41397. private _buttonLeftStick;
  41398. private _buttonRightStick;
  41399. private _dPadUp;
  41400. private _dPadDown;
  41401. private _dPadLeft;
  41402. private _dPadRight;
  41403. private _isXboxOnePad;
  41404. /**
  41405. * Creates a new XBox360 gamepad object
  41406. * @param id defines the id of this gamepad
  41407. * @param index defines its index
  41408. * @param gamepad defines the internal HTML gamepad object
  41409. * @param xboxOne defines if it is a XBox One gamepad
  41410. */
  41411. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41412. /**
  41413. * Defines the callback to call when left trigger is pressed
  41414. * @param callback defines the callback to use
  41415. */
  41416. onlefttriggerchanged(callback: (value: number) => void): void;
  41417. /**
  41418. * Defines the callback to call when right trigger is pressed
  41419. * @param callback defines the callback to use
  41420. */
  41421. onrighttriggerchanged(callback: (value: number) => void): void;
  41422. /**
  41423. * Gets the left trigger value
  41424. */
  41425. get leftTrigger(): number;
  41426. /**
  41427. * Sets the left trigger value
  41428. */
  41429. set leftTrigger(newValue: number);
  41430. /**
  41431. * Gets the right trigger value
  41432. */
  41433. get rightTrigger(): number;
  41434. /**
  41435. * Sets the right trigger value
  41436. */
  41437. set rightTrigger(newValue: number);
  41438. /**
  41439. * Defines the callback to call when a button is pressed
  41440. * @param callback defines the callback to use
  41441. */
  41442. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41443. /**
  41444. * Defines the callback to call when a button is released
  41445. * @param callback defines the callback to use
  41446. */
  41447. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41448. /**
  41449. * Defines the callback to call when a pad is pressed
  41450. * @param callback defines the callback to use
  41451. */
  41452. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41453. /**
  41454. * Defines the callback to call when a pad is released
  41455. * @param callback defines the callback to use
  41456. */
  41457. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41458. private _setButtonValue;
  41459. private _setDPadValue;
  41460. /**
  41461. * Gets the value of the `A` button
  41462. */
  41463. get buttonA(): number;
  41464. /**
  41465. * Sets the value of the `A` button
  41466. */
  41467. set buttonA(value: number);
  41468. /**
  41469. * Gets the value of the `B` button
  41470. */
  41471. get buttonB(): number;
  41472. /**
  41473. * Sets the value of the `B` button
  41474. */
  41475. set buttonB(value: number);
  41476. /**
  41477. * Gets the value of the `X` button
  41478. */
  41479. get buttonX(): number;
  41480. /**
  41481. * Sets the value of the `X` button
  41482. */
  41483. set buttonX(value: number);
  41484. /**
  41485. * Gets the value of the `Y` button
  41486. */
  41487. get buttonY(): number;
  41488. /**
  41489. * Sets the value of the `Y` button
  41490. */
  41491. set buttonY(value: number);
  41492. /**
  41493. * Gets the value of the `Start` button
  41494. */
  41495. get buttonStart(): number;
  41496. /**
  41497. * Sets the value of the `Start` button
  41498. */
  41499. set buttonStart(value: number);
  41500. /**
  41501. * Gets the value of the `Back` button
  41502. */
  41503. get buttonBack(): number;
  41504. /**
  41505. * Sets the value of the `Back` button
  41506. */
  41507. set buttonBack(value: number);
  41508. /**
  41509. * Gets the value of the `Left` button
  41510. */
  41511. get buttonLB(): number;
  41512. /**
  41513. * Sets the value of the `Left` button
  41514. */
  41515. set buttonLB(value: number);
  41516. /**
  41517. * Gets the value of the `Right` button
  41518. */
  41519. get buttonRB(): number;
  41520. /**
  41521. * Sets the value of the `Right` button
  41522. */
  41523. set buttonRB(value: number);
  41524. /**
  41525. * Gets the value of the Left joystick
  41526. */
  41527. get buttonLeftStick(): number;
  41528. /**
  41529. * Sets the value of the Left joystick
  41530. */
  41531. set buttonLeftStick(value: number);
  41532. /**
  41533. * Gets the value of the Right joystick
  41534. */
  41535. get buttonRightStick(): number;
  41536. /**
  41537. * Sets the value of the Right joystick
  41538. */
  41539. set buttonRightStick(value: number);
  41540. /**
  41541. * Gets the value of D-pad up
  41542. */
  41543. get dPadUp(): number;
  41544. /**
  41545. * Sets the value of D-pad up
  41546. */
  41547. set dPadUp(value: number);
  41548. /**
  41549. * Gets the value of D-pad down
  41550. */
  41551. get dPadDown(): number;
  41552. /**
  41553. * Sets the value of D-pad down
  41554. */
  41555. set dPadDown(value: number);
  41556. /**
  41557. * Gets the value of D-pad left
  41558. */
  41559. get dPadLeft(): number;
  41560. /**
  41561. * Sets the value of D-pad left
  41562. */
  41563. set dPadLeft(value: number);
  41564. /**
  41565. * Gets the value of D-pad right
  41566. */
  41567. get dPadRight(): number;
  41568. /**
  41569. * Sets the value of D-pad right
  41570. */
  41571. set dPadRight(value: number);
  41572. /**
  41573. * Force the gamepad to synchronize with device values
  41574. */
  41575. update(): void;
  41576. /**
  41577. * Disposes the gamepad
  41578. */
  41579. dispose(): void;
  41580. }
  41581. }
  41582. declare module BABYLON {
  41583. /**
  41584. * Defines supported buttons for DualShock compatible gamepads
  41585. */
  41586. export enum DualShockButton {
  41587. /** Cross */
  41588. Cross = 0,
  41589. /** Circle */
  41590. Circle = 1,
  41591. /** Square */
  41592. Square = 2,
  41593. /** Triangle */
  41594. Triangle = 3,
  41595. /** L1 */
  41596. L1 = 4,
  41597. /** R1 */
  41598. R1 = 5,
  41599. /** Share */
  41600. Share = 8,
  41601. /** Options */
  41602. Options = 9,
  41603. /** Left stick */
  41604. LeftStick = 10,
  41605. /** Right stick */
  41606. RightStick = 11
  41607. }
  41608. /** Defines values for DualShock DPad */
  41609. export enum DualShockDpad {
  41610. /** Up */
  41611. Up = 12,
  41612. /** Down */
  41613. Down = 13,
  41614. /** Left */
  41615. Left = 14,
  41616. /** Right */
  41617. Right = 15
  41618. }
  41619. /**
  41620. * Defines a DualShock gamepad
  41621. */
  41622. export class DualShockPad extends Gamepad {
  41623. private _leftTrigger;
  41624. private _rightTrigger;
  41625. private _onlefttriggerchanged;
  41626. private _onrighttriggerchanged;
  41627. private _onbuttondown;
  41628. private _onbuttonup;
  41629. private _ondpaddown;
  41630. private _ondpadup;
  41631. /** Observable raised when a button is pressed */
  41632. onButtonDownObservable: Observable<DualShockButton>;
  41633. /** Observable raised when a button is released */
  41634. onButtonUpObservable: Observable<DualShockButton>;
  41635. /** Observable raised when a pad is pressed */
  41636. onPadDownObservable: Observable<DualShockDpad>;
  41637. /** Observable raised when a pad is released */
  41638. onPadUpObservable: Observable<DualShockDpad>;
  41639. private _buttonCross;
  41640. private _buttonCircle;
  41641. private _buttonSquare;
  41642. private _buttonTriangle;
  41643. private _buttonShare;
  41644. private _buttonOptions;
  41645. private _buttonL1;
  41646. private _buttonR1;
  41647. private _buttonLeftStick;
  41648. private _buttonRightStick;
  41649. private _dPadUp;
  41650. private _dPadDown;
  41651. private _dPadLeft;
  41652. private _dPadRight;
  41653. /**
  41654. * Creates a new DualShock gamepad object
  41655. * @param id defines the id of this gamepad
  41656. * @param index defines its index
  41657. * @param gamepad defines the internal HTML gamepad object
  41658. */
  41659. constructor(id: string, index: number, gamepad: any);
  41660. /**
  41661. * Defines the callback to call when left trigger is pressed
  41662. * @param callback defines the callback to use
  41663. */
  41664. onlefttriggerchanged(callback: (value: number) => void): void;
  41665. /**
  41666. * Defines the callback to call when right trigger is pressed
  41667. * @param callback defines the callback to use
  41668. */
  41669. onrighttriggerchanged(callback: (value: number) => void): void;
  41670. /**
  41671. * Gets the left trigger value
  41672. */
  41673. get leftTrigger(): number;
  41674. /**
  41675. * Sets the left trigger value
  41676. */
  41677. set leftTrigger(newValue: number);
  41678. /**
  41679. * Gets the right trigger value
  41680. */
  41681. get rightTrigger(): number;
  41682. /**
  41683. * Sets the right trigger value
  41684. */
  41685. set rightTrigger(newValue: number);
  41686. /**
  41687. * Defines the callback to call when a button is pressed
  41688. * @param callback defines the callback to use
  41689. */
  41690. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41691. /**
  41692. * Defines the callback to call when a button is released
  41693. * @param callback defines the callback to use
  41694. */
  41695. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41696. /**
  41697. * Defines the callback to call when a pad is pressed
  41698. * @param callback defines the callback to use
  41699. */
  41700. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41701. /**
  41702. * Defines the callback to call when a pad is released
  41703. * @param callback defines the callback to use
  41704. */
  41705. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41706. private _setButtonValue;
  41707. private _setDPadValue;
  41708. /**
  41709. * Gets the value of the `Cross` button
  41710. */
  41711. get buttonCross(): number;
  41712. /**
  41713. * Sets the value of the `Cross` button
  41714. */
  41715. set buttonCross(value: number);
  41716. /**
  41717. * Gets the value of the `Circle` button
  41718. */
  41719. get buttonCircle(): number;
  41720. /**
  41721. * Sets the value of the `Circle` button
  41722. */
  41723. set buttonCircle(value: number);
  41724. /**
  41725. * Gets the value of the `Square` button
  41726. */
  41727. get buttonSquare(): number;
  41728. /**
  41729. * Sets the value of the `Square` button
  41730. */
  41731. set buttonSquare(value: number);
  41732. /**
  41733. * Gets the value of the `Triangle` button
  41734. */
  41735. get buttonTriangle(): number;
  41736. /**
  41737. * Sets the value of the `Triangle` button
  41738. */
  41739. set buttonTriangle(value: number);
  41740. /**
  41741. * Gets the value of the `Options` button
  41742. */
  41743. get buttonOptions(): number;
  41744. /**
  41745. * Sets the value of the `Options` button
  41746. */
  41747. set buttonOptions(value: number);
  41748. /**
  41749. * Gets the value of the `Share` button
  41750. */
  41751. get buttonShare(): number;
  41752. /**
  41753. * Sets the value of the `Share` button
  41754. */
  41755. set buttonShare(value: number);
  41756. /**
  41757. * Gets the value of the `L1` button
  41758. */
  41759. get buttonL1(): number;
  41760. /**
  41761. * Sets the value of the `L1` button
  41762. */
  41763. set buttonL1(value: number);
  41764. /**
  41765. * Gets the value of the `R1` button
  41766. */
  41767. get buttonR1(): number;
  41768. /**
  41769. * Sets the value of the `R1` button
  41770. */
  41771. set buttonR1(value: number);
  41772. /**
  41773. * Gets the value of the Left joystick
  41774. */
  41775. get buttonLeftStick(): number;
  41776. /**
  41777. * Sets the value of the Left joystick
  41778. */
  41779. set buttonLeftStick(value: number);
  41780. /**
  41781. * Gets the value of the Right joystick
  41782. */
  41783. get buttonRightStick(): number;
  41784. /**
  41785. * Sets the value of the Right joystick
  41786. */
  41787. set buttonRightStick(value: number);
  41788. /**
  41789. * Gets the value of D-pad up
  41790. */
  41791. get dPadUp(): number;
  41792. /**
  41793. * Sets the value of D-pad up
  41794. */
  41795. set dPadUp(value: number);
  41796. /**
  41797. * Gets the value of D-pad down
  41798. */
  41799. get dPadDown(): number;
  41800. /**
  41801. * Sets the value of D-pad down
  41802. */
  41803. set dPadDown(value: number);
  41804. /**
  41805. * Gets the value of D-pad left
  41806. */
  41807. get dPadLeft(): number;
  41808. /**
  41809. * Sets the value of D-pad left
  41810. */
  41811. set dPadLeft(value: number);
  41812. /**
  41813. * Gets the value of D-pad right
  41814. */
  41815. get dPadRight(): number;
  41816. /**
  41817. * Sets the value of D-pad right
  41818. */
  41819. set dPadRight(value: number);
  41820. /**
  41821. * Force the gamepad to synchronize with device values
  41822. */
  41823. update(): void;
  41824. /**
  41825. * Disposes the gamepad
  41826. */
  41827. dispose(): void;
  41828. }
  41829. }
  41830. declare module BABYLON {
  41831. /**
  41832. * Manager for handling gamepads
  41833. */
  41834. export class GamepadManager {
  41835. private _scene?;
  41836. private _babylonGamepads;
  41837. private _oneGamepadConnected;
  41838. /** @hidden */
  41839. _isMonitoring: boolean;
  41840. private _gamepadEventSupported;
  41841. private _gamepadSupport?;
  41842. /**
  41843. * observable to be triggered when the gamepad controller has been connected
  41844. */
  41845. onGamepadConnectedObservable: Observable<Gamepad>;
  41846. /**
  41847. * observable to be triggered when the gamepad controller has been disconnected
  41848. */
  41849. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41850. private _onGamepadConnectedEvent;
  41851. private _onGamepadDisconnectedEvent;
  41852. /**
  41853. * Initializes the gamepad manager
  41854. * @param _scene BabylonJS scene
  41855. */
  41856. constructor(_scene?: Scene | undefined);
  41857. /**
  41858. * The gamepads in the game pad manager
  41859. */
  41860. get gamepads(): Gamepad[];
  41861. /**
  41862. * Get the gamepad controllers based on type
  41863. * @param type The type of gamepad controller
  41864. * @returns Nullable gamepad
  41865. */
  41866. getGamepadByType(type?: number): Nullable<Gamepad>;
  41867. /**
  41868. * Disposes the gamepad manager
  41869. */
  41870. dispose(): void;
  41871. private _addNewGamepad;
  41872. private _startMonitoringGamepads;
  41873. private _stopMonitoringGamepads;
  41874. /** @hidden */
  41875. _checkGamepadsStatus(): void;
  41876. private _updateGamepadObjects;
  41877. }
  41878. }
  41879. declare module BABYLON {
  41880. interface Scene {
  41881. /** @hidden */
  41882. _gamepadManager: Nullable<GamepadManager>;
  41883. /**
  41884. * Gets the gamepad manager associated with the scene
  41885. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41886. */
  41887. gamepadManager: GamepadManager;
  41888. }
  41889. /**
  41890. * Interface representing a free camera inputs manager
  41891. */
  41892. interface FreeCameraInputsManager {
  41893. /**
  41894. * Adds gamepad input support to the FreeCameraInputsManager.
  41895. * @returns the FreeCameraInputsManager
  41896. */
  41897. addGamepad(): FreeCameraInputsManager;
  41898. }
  41899. /**
  41900. * Interface representing an arc rotate camera inputs manager
  41901. */
  41902. interface ArcRotateCameraInputsManager {
  41903. /**
  41904. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41905. * @returns the camera inputs manager
  41906. */
  41907. addGamepad(): ArcRotateCameraInputsManager;
  41908. }
  41909. /**
  41910. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41911. */
  41912. export class GamepadSystemSceneComponent implements ISceneComponent {
  41913. /**
  41914. * The component name helpfull to identify the component in the list of scene components.
  41915. */
  41916. readonly name: string;
  41917. /**
  41918. * The scene the component belongs to.
  41919. */
  41920. scene: Scene;
  41921. /**
  41922. * Creates a new instance of the component for the given scene
  41923. * @param scene Defines the scene to register the component in
  41924. */
  41925. constructor(scene: Scene);
  41926. /**
  41927. * Registers the component in a given scene
  41928. */
  41929. register(): void;
  41930. /**
  41931. * Rebuilds the elements related to this component in case of
  41932. * context lost for instance.
  41933. */
  41934. rebuild(): void;
  41935. /**
  41936. * Disposes the component and the associated ressources
  41937. */
  41938. dispose(): void;
  41939. private _beforeCameraUpdate;
  41940. }
  41941. }
  41942. declare module BABYLON {
  41943. /**
  41944. * 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,
  41945. * which still works and will still be found in many Playgrounds.
  41946. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41947. */
  41948. export class UniversalCamera extends TouchCamera {
  41949. /**
  41950. * Defines the gamepad rotation sensiblity.
  41951. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41952. */
  41953. get gamepadAngularSensibility(): number;
  41954. set gamepadAngularSensibility(value: number);
  41955. /**
  41956. * Defines the gamepad move sensiblity.
  41957. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41958. */
  41959. get gamepadMoveSensibility(): number;
  41960. set gamepadMoveSensibility(value: number);
  41961. /**
  41962. * 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,
  41963. * which still works and will still be found in many Playgrounds.
  41964. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41965. * @param name Define the name of the camera in the scene
  41966. * @param position Define the start position of the camera in the scene
  41967. * @param scene Define the scene the camera belongs to
  41968. */
  41969. constructor(name: string, position: Vector3, scene: Scene);
  41970. /**
  41971. * Gets the current object class name.
  41972. * @return the class name
  41973. */
  41974. getClassName(): string;
  41975. }
  41976. }
  41977. declare module BABYLON {
  41978. /**
  41979. * This represents a FPS type of camera. This is only here for back compat purpose.
  41980. * Please use the UniversalCamera instead as both are identical.
  41981. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41982. */
  41983. export class GamepadCamera extends UniversalCamera {
  41984. /**
  41985. * Instantiates a new Gamepad Camera
  41986. * This represents a FPS type of camera. This is only here for back compat purpose.
  41987. * Please use the UniversalCamera instead as both are identical.
  41988. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41989. * @param name Define the name of the camera in the scene
  41990. * @param position Define the start position of the camera in the scene
  41991. * @param scene Define the scene the camera belongs to
  41992. */
  41993. constructor(name: string, position: Vector3, scene: Scene);
  41994. /**
  41995. * Gets the current object class name.
  41996. * @return the class name
  41997. */
  41998. getClassName(): string;
  41999. }
  42000. }
  42001. declare module BABYLON {
  42002. /** @hidden */
  42003. export var passPixelShader: {
  42004. name: string;
  42005. shader: string;
  42006. };
  42007. }
  42008. declare module BABYLON {
  42009. /** @hidden */
  42010. export var passCubePixelShader: {
  42011. name: string;
  42012. shader: string;
  42013. };
  42014. }
  42015. declare module BABYLON {
  42016. /**
  42017. * PassPostProcess which produces an output the same as it's input
  42018. */
  42019. export class PassPostProcess extends PostProcess {
  42020. /**
  42021. * Creates the PassPostProcess
  42022. * @param name The name of the effect.
  42023. * @param options The required width/height ratio to downsize to before computing the render pass.
  42024. * @param camera The camera to apply the render pass to.
  42025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42026. * @param engine The engine which the post process will be applied. (default: current engine)
  42027. * @param reusable If the post process can be reused on the same frame. (default: false)
  42028. * @param textureType The type of texture to be used when performing the post processing.
  42029. * @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)
  42030. */
  42031. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42032. }
  42033. /**
  42034. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42035. */
  42036. export class PassCubePostProcess extends PostProcess {
  42037. private _face;
  42038. /**
  42039. * Gets or sets the cube face to display.
  42040. * * 0 is +X
  42041. * * 1 is -X
  42042. * * 2 is +Y
  42043. * * 3 is -Y
  42044. * * 4 is +Z
  42045. * * 5 is -Z
  42046. */
  42047. get face(): number;
  42048. set face(value: number);
  42049. /**
  42050. * Creates the PassCubePostProcess
  42051. * @param name The name of the effect.
  42052. * @param options The required width/height ratio to downsize to before computing the render pass.
  42053. * @param camera The camera to apply the render pass to.
  42054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42055. * @param engine The engine which the post process will be applied. (default: current engine)
  42056. * @param reusable If the post process can be reused on the same frame. (default: false)
  42057. * @param textureType The type of texture to be used when performing the post processing.
  42058. * @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)
  42059. */
  42060. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42061. }
  42062. }
  42063. declare module BABYLON {
  42064. /** @hidden */
  42065. export var anaglyphPixelShader: {
  42066. name: string;
  42067. shader: string;
  42068. };
  42069. }
  42070. declare module BABYLON {
  42071. /**
  42072. * Postprocess used to generate anaglyphic rendering
  42073. */
  42074. export class AnaglyphPostProcess extends PostProcess {
  42075. private _passedProcess;
  42076. /**
  42077. * Creates a new AnaglyphPostProcess
  42078. * @param name defines postprocess name
  42079. * @param options defines creation options or target ratio scale
  42080. * @param rigCameras defines cameras using this postprocess
  42081. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42082. * @param engine defines hosting engine
  42083. * @param reusable defines if the postprocess will be reused multiple times per frame
  42084. */
  42085. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42086. }
  42087. }
  42088. declare module BABYLON {
  42089. /**
  42090. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42091. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42092. */
  42093. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42094. /**
  42095. * Creates a new AnaglyphArcRotateCamera
  42096. * @param name defines camera name
  42097. * @param alpha defines alpha angle (in radians)
  42098. * @param beta defines beta angle (in radians)
  42099. * @param radius defines radius
  42100. * @param target defines camera target
  42101. * @param interaxialDistance defines distance between each color axis
  42102. * @param scene defines the hosting scene
  42103. */
  42104. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42105. /**
  42106. * Gets camera class name
  42107. * @returns AnaglyphArcRotateCamera
  42108. */
  42109. getClassName(): string;
  42110. }
  42111. }
  42112. declare module BABYLON {
  42113. /**
  42114. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42115. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42116. */
  42117. export class AnaglyphFreeCamera extends FreeCamera {
  42118. /**
  42119. * Creates a new AnaglyphFreeCamera
  42120. * @param name defines camera name
  42121. * @param position defines initial position
  42122. * @param interaxialDistance defines distance between each color axis
  42123. * @param scene defines the hosting scene
  42124. */
  42125. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42126. /**
  42127. * Gets camera class name
  42128. * @returns AnaglyphFreeCamera
  42129. */
  42130. getClassName(): string;
  42131. }
  42132. }
  42133. declare module BABYLON {
  42134. /**
  42135. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42136. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42137. */
  42138. export class AnaglyphGamepadCamera extends GamepadCamera {
  42139. /**
  42140. * Creates a new AnaglyphGamepadCamera
  42141. * @param name defines camera name
  42142. * @param position defines initial position
  42143. * @param interaxialDistance defines distance between each color axis
  42144. * @param scene defines the hosting scene
  42145. */
  42146. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42147. /**
  42148. * Gets camera class name
  42149. * @returns AnaglyphGamepadCamera
  42150. */
  42151. getClassName(): string;
  42152. }
  42153. }
  42154. declare module BABYLON {
  42155. /**
  42156. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42157. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42158. */
  42159. export class AnaglyphUniversalCamera extends UniversalCamera {
  42160. /**
  42161. * Creates a new AnaglyphUniversalCamera
  42162. * @param name defines camera name
  42163. * @param position defines initial position
  42164. * @param interaxialDistance defines distance between each color axis
  42165. * @param scene defines the hosting scene
  42166. */
  42167. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42168. /**
  42169. * Gets camera class name
  42170. * @returns AnaglyphUniversalCamera
  42171. */
  42172. getClassName(): string;
  42173. }
  42174. }
  42175. declare module BABYLON {
  42176. /** @hidden */
  42177. export var stereoscopicInterlacePixelShader: {
  42178. name: string;
  42179. shader: string;
  42180. };
  42181. }
  42182. declare module BABYLON {
  42183. /**
  42184. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42185. */
  42186. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42187. private _stepSize;
  42188. private _passedProcess;
  42189. /**
  42190. * Initializes a StereoscopicInterlacePostProcessI
  42191. * @param name The name of the effect.
  42192. * @param rigCameras The rig cameras to be appled to the post process
  42193. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42194. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42196. * @param engine The engine which the post process will be applied. (default: current engine)
  42197. * @param reusable If the post process can be reused on the same frame. (default: false)
  42198. */
  42199. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42200. }
  42201. /**
  42202. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42203. */
  42204. export class StereoscopicInterlacePostProcess extends PostProcess {
  42205. private _stepSize;
  42206. private _passedProcess;
  42207. /**
  42208. * Initializes a StereoscopicInterlacePostProcess
  42209. * @param name The name of the effect.
  42210. * @param rigCameras The rig cameras to be appled to the post process
  42211. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42213. * @param engine The engine which the post process will be applied. (default: current engine)
  42214. * @param reusable If the post process can be reused on the same frame. (default: false)
  42215. */
  42216. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42217. }
  42218. }
  42219. declare module BABYLON {
  42220. /**
  42221. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42222. * @see http://doc.babylonjs.com/features/cameras
  42223. */
  42224. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42225. /**
  42226. * Creates a new StereoscopicArcRotateCamera
  42227. * @param name defines camera name
  42228. * @param alpha defines alpha angle (in radians)
  42229. * @param beta defines beta angle (in radians)
  42230. * @param radius defines radius
  42231. * @param target defines camera target
  42232. * @param interaxialDistance defines distance between each color axis
  42233. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42234. * @param scene defines the hosting scene
  42235. */
  42236. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42237. /**
  42238. * Gets camera class name
  42239. * @returns StereoscopicArcRotateCamera
  42240. */
  42241. getClassName(): string;
  42242. }
  42243. }
  42244. declare module BABYLON {
  42245. /**
  42246. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42247. * @see http://doc.babylonjs.com/features/cameras
  42248. */
  42249. export class StereoscopicFreeCamera extends FreeCamera {
  42250. /**
  42251. * Creates a new StereoscopicFreeCamera
  42252. * @param name defines camera name
  42253. * @param position defines initial position
  42254. * @param interaxialDistance defines distance between each color axis
  42255. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42256. * @param scene defines the hosting scene
  42257. */
  42258. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42259. /**
  42260. * Gets camera class name
  42261. * @returns StereoscopicFreeCamera
  42262. */
  42263. getClassName(): string;
  42264. }
  42265. }
  42266. declare module BABYLON {
  42267. /**
  42268. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42269. * @see http://doc.babylonjs.com/features/cameras
  42270. */
  42271. export class StereoscopicGamepadCamera extends GamepadCamera {
  42272. /**
  42273. * Creates a new StereoscopicGamepadCamera
  42274. * @param name defines camera name
  42275. * @param position defines initial position
  42276. * @param interaxialDistance defines distance between each color axis
  42277. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42278. * @param scene defines the hosting scene
  42279. */
  42280. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42281. /**
  42282. * Gets camera class name
  42283. * @returns StereoscopicGamepadCamera
  42284. */
  42285. getClassName(): string;
  42286. }
  42287. }
  42288. declare module BABYLON {
  42289. /**
  42290. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42291. * @see http://doc.babylonjs.com/features/cameras
  42292. */
  42293. export class StereoscopicUniversalCamera extends UniversalCamera {
  42294. /**
  42295. * Creates a new StereoscopicUniversalCamera
  42296. * @param name defines camera name
  42297. * @param position defines initial position
  42298. * @param interaxialDistance defines distance between each color axis
  42299. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42300. * @param scene defines the hosting scene
  42301. */
  42302. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42303. /**
  42304. * Gets camera class name
  42305. * @returns StereoscopicUniversalCamera
  42306. */
  42307. getClassName(): string;
  42308. }
  42309. }
  42310. declare module BABYLON {
  42311. /**
  42312. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42313. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42314. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42315. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42316. */
  42317. export class VirtualJoysticksCamera extends FreeCamera {
  42318. /**
  42319. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42320. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42321. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42322. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42323. * @param name Define the name of the camera in the scene
  42324. * @param position Define the start position of the camera in the scene
  42325. * @param scene Define the scene the camera belongs to
  42326. */
  42327. constructor(name: string, position: Vector3, scene: Scene);
  42328. /**
  42329. * Gets the current object class name.
  42330. * @return the class name
  42331. */
  42332. getClassName(): string;
  42333. }
  42334. }
  42335. declare module BABYLON {
  42336. /**
  42337. * This represents all the required metrics to create a VR camera.
  42338. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42339. */
  42340. export class VRCameraMetrics {
  42341. /**
  42342. * Define the horizontal resolution off the screen.
  42343. */
  42344. hResolution: number;
  42345. /**
  42346. * Define the vertical resolution off the screen.
  42347. */
  42348. vResolution: number;
  42349. /**
  42350. * Define the horizontal screen size.
  42351. */
  42352. hScreenSize: number;
  42353. /**
  42354. * Define the vertical screen size.
  42355. */
  42356. vScreenSize: number;
  42357. /**
  42358. * Define the vertical screen center position.
  42359. */
  42360. vScreenCenter: number;
  42361. /**
  42362. * Define the distance of the eyes to the screen.
  42363. */
  42364. eyeToScreenDistance: number;
  42365. /**
  42366. * Define the distance between both lenses
  42367. */
  42368. lensSeparationDistance: number;
  42369. /**
  42370. * Define the distance between both viewer's eyes.
  42371. */
  42372. interpupillaryDistance: number;
  42373. /**
  42374. * Define the distortion factor of the VR postprocess.
  42375. * Please, touch with care.
  42376. */
  42377. distortionK: number[];
  42378. /**
  42379. * Define the chromatic aberration correction factors for the VR post process.
  42380. */
  42381. chromaAbCorrection: number[];
  42382. /**
  42383. * Define the scale factor of the post process.
  42384. * The smaller the better but the slower.
  42385. */
  42386. postProcessScaleFactor: number;
  42387. /**
  42388. * Define an offset for the lens center.
  42389. */
  42390. lensCenterOffset: number;
  42391. /**
  42392. * Define if the current vr camera should compensate the distortion of the lense or not.
  42393. */
  42394. compensateDistortion: boolean;
  42395. /**
  42396. * Defines if multiview should be enabled when rendering (Default: false)
  42397. */
  42398. multiviewEnabled: boolean;
  42399. /**
  42400. * Gets the rendering aspect ratio based on the provided resolutions.
  42401. */
  42402. get aspectRatio(): number;
  42403. /**
  42404. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42405. */
  42406. get aspectRatioFov(): number;
  42407. /**
  42408. * @hidden
  42409. */
  42410. get leftHMatrix(): Matrix;
  42411. /**
  42412. * @hidden
  42413. */
  42414. get rightHMatrix(): Matrix;
  42415. /**
  42416. * @hidden
  42417. */
  42418. get leftPreViewMatrix(): Matrix;
  42419. /**
  42420. * @hidden
  42421. */
  42422. get rightPreViewMatrix(): Matrix;
  42423. /**
  42424. * Get the default VRMetrics based on the most generic setup.
  42425. * @returns the default vr metrics
  42426. */
  42427. static GetDefault(): VRCameraMetrics;
  42428. }
  42429. }
  42430. declare module BABYLON {
  42431. /** @hidden */
  42432. export var vrDistortionCorrectionPixelShader: {
  42433. name: string;
  42434. shader: string;
  42435. };
  42436. }
  42437. declare module BABYLON {
  42438. /**
  42439. * VRDistortionCorrectionPostProcess used for mobile VR
  42440. */
  42441. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42442. private _isRightEye;
  42443. private _distortionFactors;
  42444. private _postProcessScaleFactor;
  42445. private _lensCenterOffset;
  42446. private _scaleIn;
  42447. private _scaleFactor;
  42448. private _lensCenter;
  42449. /**
  42450. * Initializes the VRDistortionCorrectionPostProcess
  42451. * @param name The name of the effect.
  42452. * @param camera The camera to apply the render pass to.
  42453. * @param isRightEye If this is for the right eye distortion
  42454. * @param vrMetrics All the required metrics for the VR camera
  42455. */
  42456. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42457. }
  42458. }
  42459. declare module BABYLON {
  42460. /**
  42461. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42462. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42463. */
  42464. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42465. /**
  42466. * Creates a new VRDeviceOrientationArcRotateCamera
  42467. * @param name defines camera name
  42468. * @param alpha defines the camera rotation along the logitudinal axis
  42469. * @param beta defines the camera rotation along the latitudinal axis
  42470. * @param radius defines the camera distance from its target
  42471. * @param target defines the camera target
  42472. * @param scene defines the scene the camera belongs to
  42473. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42474. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42475. */
  42476. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42477. /**
  42478. * Gets camera class name
  42479. * @returns VRDeviceOrientationArcRotateCamera
  42480. */
  42481. getClassName(): string;
  42482. }
  42483. }
  42484. declare module BABYLON {
  42485. /**
  42486. * Camera used to simulate VR rendering (based on FreeCamera)
  42487. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42488. */
  42489. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42490. /**
  42491. * Creates a new VRDeviceOrientationFreeCamera
  42492. * @param name defines camera name
  42493. * @param position defines the start position of the camera
  42494. * @param scene defines the scene the camera belongs to
  42495. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42496. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42497. */
  42498. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42499. /**
  42500. * Gets camera class name
  42501. * @returns VRDeviceOrientationFreeCamera
  42502. */
  42503. getClassName(): string;
  42504. }
  42505. }
  42506. declare module BABYLON {
  42507. /**
  42508. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42509. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42510. */
  42511. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42512. /**
  42513. * Creates a new VRDeviceOrientationGamepadCamera
  42514. * @param name defines camera name
  42515. * @param position defines the start position of the camera
  42516. * @param scene defines the scene the camera belongs to
  42517. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42518. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42519. */
  42520. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42521. /**
  42522. * Gets camera class name
  42523. * @returns VRDeviceOrientationGamepadCamera
  42524. */
  42525. getClassName(): string;
  42526. }
  42527. }
  42528. declare module BABYLON {
  42529. /** @hidden */
  42530. export var imageProcessingPixelShader: {
  42531. name: string;
  42532. shader: string;
  42533. };
  42534. }
  42535. declare module BABYLON {
  42536. /**
  42537. * ImageProcessingPostProcess
  42538. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42539. */
  42540. export class ImageProcessingPostProcess extends PostProcess {
  42541. /**
  42542. * Default configuration related to image processing available in the PBR Material.
  42543. */
  42544. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42545. /**
  42546. * Gets the image processing configuration used either in this material.
  42547. */
  42548. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42549. /**
  42550. * Sets the Default image processing configuration used either in the this material.
  42551. *
  42552. * If sets to null, the scene one is in use.
  42553. */
  42554. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42555. /**
  42556. * Keep track of the image processing observer to allow dispose and replace.
  42557. */
  42558. private _imageProcessingObserver;
  42559. /**
  42560. * Attaches a new image processing configuration to the PBR Material.
  42561. * @param configuration
  42562. */
  42563. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42564. /**
  42565. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42566. */
  42567. get colorCurves(): Nullable<ColorCurves>;
  42568. /**
  42569. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42570. */
  42571. set colorCurves(value: Nullable<ColorCurves>);
  42572. /**
  42573. * Gets wether the color curves effect is enabled.
  42574. */
  42575. get colorCurvesEnabled(): boolean;
  42576. /**
  42577. * Sets wether the color curves effect is enabled.
  42578. */
  42579. set colorCurvesEnabled(value: boolean);
  42580. /**
  42581. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42582. */
  42583. get colorGradingTexture(): Nullable<BaseTexture>;
  42584. /**
  42585. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42586. */
  42587. set colorGradingTexture(value: Nullable<BaseTexture>);
  42588. /**
  42589. * Gets wether the color grading effect is enabled.
  42590. */
  42591. get colorGradingEnabled(): boolean;
  42592. /**
  42593. * Gets wether the color grading effect is enabled.
  42594. */
  42595. set colorGradingEnabled(value: boolean);
  42596. /**
  42597. * Gets exposure used in the effect.
  42598. */
  42599. get exposure(): number;
  42600. /**
  42601. * Sets exposure used in the effect.
  42602. */
  42603. set exposure(value: number);
  42604. /**
  42605. * Gets wether tonemapping is enabled or not.
  42606. */
  42607. get toneMappingEnabled(): boolean;
  42608. /**
  42609. * Sets wether tonemapping is enabled or not
  42610. */
  42611. set toneMappingEnabled(value: boolean);
  42612. /**
  42613. * Gets the type of tone mapping effect.
  42614. */
  42615. get toneMappingType(): number;
  42616. /**
  42617. * Sets the type of tone mapping effect.
  42618. */
  42619. set toneMappingType(value: number);
  42620. /**
  42621. * Gets contrast used in the effect.
  42622. */
  42623. get contrast(): number;
  42624. /**
  42625. * Sets contrast used in the effect.
  42626. */
  42627. set contrast(value: number);
  42628. /**
  42629. * Gets Vignette stretch size.
  42630. */
  42631. get vignetteStretch(): number;
  42632. /**
  42633. * Sets Vignette stretch size.
  42634. */
  42635. set vignetteStretch(value: number);
  42636. /**
  42637. * Gets Vignette centre X Offset.
  42638. */
  42639. get vignetteCentreX(): number;
  42640. /**
  42641. * Sets Vignette centre X Offset.
  42642. */
  42643. set vignetteCentreX(value: number);
  42644. /**
  42645. * Gets Vignette centre Y Offset.
  42646. */
  42647. get vignetteCentreY(): number;
  42648. /**
  42649. * Sets Vignette centre Y Offset.
  42650. */
  42651. set vignetteCentreY(value: number);
  42652. /**
  42653. * Gets Vignette weight or intensity of the vignette effect.
  42654. */
  42655. get vignetteWeight(): number;
  42656. /**
  42657. * Sets Vignette weight or intensity of the vignette effect.
  42658. */
  42659. set vignetteWeight(value: number);
  42660. /**
  42661. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42662. * if vignetteEnabled is set to true.
  42663. */
  42664. get vignetteColor(): Color4;
  42665. /**
  42666. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42667. * if vignetteEnabled is set to true.
  42668. */
  42669. set vignetteColor(value: Color4);
  42670. /**
  42671. * Gets Camera field of view used by the Vignette effect.
  42672. */
  42673. get vignetteCameraFov(): number;
  42674. /**
  42675. * Sets Camera field of view used by the Vignette effect.
  42676. */
  42677. set vignetteCameraFov(value: number);
  42678. /**
  42679. * Gets the vignette blend mode allowing different kind of effect.
  42680. */
  42681. get vignetteBlendMode(): number;
  42682. /**
  42683. * Sets the vignette blend mode allowing different kind of effect.
  42684. */
  42685. set vignetteBlendMode(value: number);
  42686. /**
  42687. * Gets wether the vignette effect is enabled.
  42688. */
  42689. get vignetteEnabled(): boolean;
  42690. /**
  42691. * Sets wether the vignette effect is enabled.
  42692. */
  42693. set vignetteEnabled(value: boolean);
  42694. private _fromLinearSpace;
  42695. /**
  42696. * Gets wether the input of the processing is in Gamma or Linear Space.
  42697. */
  42698. get fromLinearSpace(): boolean;
  42699. /**
  42700. * Sets wether the input of the processing is in Gamma or Linear Space.
  42701. */
  42702. set fromLinearSpace(value: boolean);
  42703. /**
  42704. * Defines cache preventing GC.
  42705. */
  42706. private _defines;
  42707. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42708. /**
  42709. * "ImageProcessingPostProcess"
  42710. * @returns "ImageProcessingPostProcess"
  42711. */
  42712. getClassName(): string;
  42713. protected _updateParameters(): void;
  42714. dispose(camera?: Camera): void;
  42715. }
  42716. }
  42717. declare module BABYLON {
  42718. /**
  42719. * Class containing static functions to help procedurally build meshes
  42720. */
  42721. export class GroundBuilder {
  42722. /**
  42723. * Creates a ground mesh
  42724. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42725. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42727. * @param name defines the name of the mesh
  42728. * @param options defines the options used to create the mesh
  42729. * @param scene defines the hosting scene
  42730. * @returns the ground mesh
  42731. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42732. */
  42733. static CreateGround(name: string, options: {
  42734. width?: number;
  42735. height?: number;
  42736. subdivisions?: number;
  42737. subdivisionsX?: number;
  42738. subdivisionsY?: number;
  42739. updatable?: boolean;
  42740. }, scene: any): Mesh;
  42741. /**
  42742. * Creates a tiled ground mesh
  42743. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42744. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42745. * * 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
  42746. * * 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
  42747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42748. * @param name defines the name of the mesh
  42749. * @param options defines the options used to create the mesh
  42750. * @param scene defines the hosting scene
  42751. * @returns the tiled ground mesh
  42752. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42753. */
  42754. static CreateTiledGround(name: string, options: {
  42755. xmin: number;
  42756. zmin: number;
  42757. xmax: number;
  42758. zmax: number;
  42759. subdivisions?: {
  42760. w: number;
  42761. h: number;
  42762. };
  42763. precision?: {
  42764. w: number;
  42765. h: number;
  42766. };
  42767. updatable?: boolean;
  42768. }, scene?: Nullable<Scene>): Mesh;
  42769. /**
  42770. * Creates a ground mesh from a height map
  42771. * * The parameter `url` sets the URL of the height map image resource.
  42772. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42773. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42774. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42775. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42776. * * 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.
  42777. * * 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).
  42778. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42780. * @param name defines the name of the mesh
  42781. * @param url defines the url to the height map
  42782. * @param options defines the options used to create the mesh
  42783. * @param scene defines the hosting scene
  42784. * @returns the ground mesh
  42785. * @see https://doc.babylonjs.com/babylon101/height_map
  42786. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42787. */
  42788. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42789. width?: number;
  42790. height?: number;
  42791. subdivisions?: number;
  42792. minHeight?: number;
  42793. maxHeight?: number;
  42794. colorFilter?: Color3;
  42795. alphaFilter?: number;
  42796. updatable?: boolean;
  42797. onReady?: (mesh: GroundMesh) => void;
  42798. }, scene?: Nullable<Scene>): GroundMesh;
  42799. }
  42800. }
  42801. declare module BABYLON {
  42802. /**
  42803. * Class containing static functions to help procedurally build meshes
  42804. */
  42805. export class TorusBuilder {
  42806. /**
  42807. * Creates a torus mesh
  42808. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42809. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42810. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42812. * * 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
  42813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42814. * @param name defines the name of the mesh
  42815. * @param options defines the options used to create the mesh
  42816. * @param scene defines the hosting scene
  42817. * @returns the torus mesh
  42818. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42819. */
  42820. static CreateTorus(name: string, options: {
  42821. diameter?: number;
  42822. thickness?: number;
  42823. tessellation?: number;
  42824. updatable?: boolean;
  42825. sideOrientation?: number;
  42826. frontUVs?: Vector4;
  42827. backUVs?: Vector4;
  42828. }, scene: any): Mesh;
  42829. }
  42830. }
  42831. declare module BABYLON {
  42832. /**
  42833. * Class containing static functions to help procedurally build meshes
  42834. */
  42835. export class CylinderBuilder {
  42836. /**
  42837. * Creates a cylinder or a cone mesh
  42838. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42839. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42840. * * 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.
  42841. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42842. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42843. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42844. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42845. * * 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).
  42846. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42847. * * 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).
  42848. * * 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
  42849. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42850. * * 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
  42851. * * 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.
  42852. * * If `enclose` is false, a ring surface is one element.
  42853. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42854. * * 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
  42855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42856. * * 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
  42857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42858. * @param name defines the name of the mesh
  42859. * @param options defines the options used to create the mesh
  42860. * @param scene defines the hosting scene
  42861. * @returns the cylinder mesh
  42862. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42863. */
  42864. static CreateCylinder(name: string, options: {
  42865. height?: number;
  42866. diameterTop?: number;
  42867. diameterBottom?: number;
  42868. diameter?: number;
  42869. tessellation?: number;
  42870. subdivisions?: number;
  42871. arc?: number;
  42872. faceColors?: Color4[];
  42873. faceUV?: Vector4[];
  42874. updatable?: boolean;
  42875. hasRings?: boolean;
  42876. enclose?: boolean;
  42877. cap?: number;
  42878. sideOrientation?: number;
  42879. frontUVs?: Vector4;
  42880. backUVs?: Vector4;
  42881. }, scene: any): Mesh;
  42882. }
  42883. }
  42884. declare module BABYLON {
  42885. /**
  42886. * States of the webXR experience
  42887. */
  42888. export enum WebXRState {
  42889. /**
  42890. * Transitioning to being in XR mode
  42891. */
  42892. ENTERING_XR = 0,
  42893. /**
  42894. * Transitioning to non XR mode
  42895. */
  42896. EXITING_XR = 1,
  42897. /**
  42898. * In XR mode and presenting
  42899. */
  42900. IN_XR = 2,
  42901. /**
  42902. * Not entered XR mode
  42903. */
  42904. NOT_IN_XR = 3
  42905. }
  42906. /**
  42907. * Abstraction of the XR render target
  42908. */
  42909. export interface WebXRRenderTarget extends IDisposable {
  42910. /**
  42911. * xrpresent context of the canvas which can be used to display/mirror xr content
  42912. */
  42913. canvasContext: WebGLRenderingContext;
  42914. /**
  42915. * xr layer for the canvas
  42916. */
  42917. xrLayer: Nullable<XRWebGLLayer>;
  42918. /**
  42919. * Initializes the xr layer for the session
  42920. * @param xrSession xr session
  42921. * @returns a promise that will resolve once the XR Layer has been created
  42922. */
  42923. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42924. }
  42925. }
  42926. declare module BABYLON {
  42927. /**
  42928. * COnfiguration object for WebXR output canvas
  42929. */
  42930. export class WebXRManagedOutputCanvasOptions {
  42931. /**
  42932. * An optional canvas in case you wish to create it yourself and provide it here.
  42933. * If not provided, a new canvas will be created
  42934. */
  42935. canvasElement?: HTMLCanvasElement;
  42936. /**
  42937. * Options for this XR Layer output
  42938. */
  42939. canvasOptions?: XRWebGLLayerOptions;
  42940. /**
  42941. * CSS styling for a newly created canvas (if not provided)
  42942. */
  42943. newCanvasCssStyle?: string;
  42944. /**
  42945. * Get the default values of the configuration object
  42946. * @returns default values of this configuration object
  42947. */
  42948. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42949. }
  42950. /**
  42951. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42952. */
  42953. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42954. private _options;
  42955. private _canvas;
  42956. private _engine;
  42957. /**
  42958. * Rendering context of the canvas which can be used to display/mirror xr content
  42959. */
  42960. canvasContext: WebGLRenderingContext;
  42961. /**
  42962. * xr layer for the canvas
  42963. */
  42964. xrLayer: Nullable<XRWebGLLayer>;
  42965. /**
  42966. * Initializes the canvas to be added/removed upon entering/exiting xr
  42967. * @param _xrSessionManager The XR Session manager
  42968. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42969. */
  42970. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42971. /**
  42972. * Disposes of the object
  42973. */
  42974. dispose(): void;
  42975. /**
  42976. * Initializes the xr layer for the session
  42977. * @param xrSession xr session
  42978. * @returns a promise that will resolve once the XR Layer has been created
  42979. */
  42980. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42981. private _addCanvas;
  42982. private _removeCanvas;
  42983. private _setManagedOutputCanvas;
  42984. }
  42985. }
  42986. declare module BABYLON {
  42987. /**
  42988. * Manages an XRSession to work with Babylon's engine
  42989. * @see https://doc.babylonjs.com/how_to/webxr
  42990. */
  42991. export class WebXRSessionManager implements IDisposable {
  42992. /** The scene which the session should be created for */
  42993. scene: Scene;
  42994. private _referenceSpace;
  42995. private _rttProvider;
  42996. private _sessionEnded;
  42997. private _xrNavigator;
  42998. private baseLayer;
  42999. /**
  43000. * The base reference space from which the session started. good if you want to reset your
  43001. * reference space
  43002. */
  43003. baseReferenceSpace: XRReferenceSpace;
  43004. /**
  43005. * Current XR frame
  43006. */
  43007. currentFrame: Nullable<XRFrame>;
  43008. /** WebXR timestamp updated every frame */
  43009. currentTimestamp: number;
  43010. /**
  43011. * Used just in case of a failure to initialize an immersive session.
  43012. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43013. */
  43014. defaultHeightCompensation: number;
  43015. /**
  43016. * Fires every time a new xrFrame arrives which can be used to update the camera
  43017. */
  43018. onXRFrameObservable: Observable<XRFrame>;
  43019. /**
  43020. * Fires when the reference space changed
  43021. */
  43022. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43023. /**
  43024. * Fires when the xr session is ended either by the device or manually done
  43025. */
  43026. onXRSessionEnded: Observable<any>;
  43027. /**
  43028. * Fires when the xr session is ended either by the device or manually done
  43029. */
  43030. onXRSessionInit: Observable<XRSession>;
  43031. /**
  43032. * Underlying xr session
  43033. */
  43034. session: XRSession;
  43035. /**
  43036. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43037. * or get the offset the player is currently at.
  43038. */
  43039. viewerReferenceSpace: XRReferenceSpace;
  43040. /**
  43041. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43042. * @param scene The scene which the session should be created for
  43043. */
  43044. constructor(
  43045. /** The scene which the session should be created for */
  43046. scene: Scene);
  43047. /**
  43048. * The current reference space used in this session. This reference space can constantly change!
  43049. * It is mainly used to offset the camera's position.
  43050. */
  43051. get referenceSpace(): XRReferenceSpace;
  43052. /**
  43053. * Set a new reference space and triggers the observable
  43054. */
  43055. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43056. /**
  43057. * Disposes of the session manager
  43058. */
  43059. dispose(): void;
  43060. /**
  43061. * Stops the xrSession and restores the render loop
  43062. * @returns Promise which resolves after it exits XR
  43063. */
  43064. exitXRAsync(): Promise<void>;
  43065. /**
  43066. * Gets the correct render target texture to be rendered this frame for this eye
  43067. * @param eye the eye for which to get the render target
  43068. * @returns the render target for the specified eye
  43069. */
  43070. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43071. /**
  43072. * Creates a WebXRRenderTarget object for the XR session
  43073. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43074. * @param options optional options to provide when creating a new render target
  43075. * @returns a WebXR render target to which the session can render
  43076. */
  43077. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43078. /**
  43079. * Initializes the manager
  43080. * After initialization enterXR can be called to start an XR session
  43081. * @returns Promise which resolves after it is initialized
  43082. */
  43083. initializeAsync(): Promise<void>;
  43084. /**
  43085. * Initializes an xr session
  43086. * @param xrSessionMode mode to initialize
  43087. * @param xrSessionInit defines optional and required values to pass to the session builder
  43088. * @returns a promise which will resolve once the session has been initialized
  43089. */
  43090. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43091. /**
  43092. * Checks if a session would be supported for the creation options specified
  43093. * @param sessionMode session mode to check if supported eg. immersive-vr
  43094. * @returns A Promise that resolves to true if supported and false if not
  43095. */
  43096. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43097. /**
  43098. * Resets the reference space to the one started the session
  43099. */
  43100. resetReferenceSpace(): void;
  43101. /**
  43102. * Starts rendering to the xr layer
  43103. */
  43104. runXRRenderLoop(): void;
  43105. /**
  43106. * Sets the reference space on the xr session
  43107. * @param referenceSpaceType space to set
  43108. * @returns a promise that will resolve once the reference space has been set
  43109. */
  43110. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43111. /**
  43112. * Updates the render state of the session
  43113. * @param state state to set
  43114. * @returns a promise that resolves once the render state has been updated
  43115. */
  43116. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43117. /**
  43118. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43119. * @param sessionMode defines the session to test
  43120. * @returns a promise with boolean as final value
  43121. */
  43122. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43123. private _createRenderTargetTexture;
  43124. }
  43125. }
  43126. declare module BABYLON {
  43127. /**
  43128. * WebXR Camera which holds the views for the xrSession
  43129. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43130. */
  43131. export class WebXRCamera extends FreeCamera {
  43132. private _xrSessionManager;
  43133. private _firstFrame;
  43134. private _referenceQuaternion;
  43135. private _referencedPosition;
  43136. private _xrInvPositionCache;
  43137. private _xrInvQuaternionCache;
  43138. /**
  43139. * Should position compensation execute on first frame.
  43140. * This is used when copying the position from a native (non XR) camera
  43141. */
  43142. compensateOnFirstFrame: boolean;
  43143. /**
  43144. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43145. * @param name the name of the camera
  43146. * @param scene the scene to add the camera to
  43147. * @param _xrSessionManager a constructed xr session manager
  43148. */
  43149. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43150. /**
  43151. * Return the user's height, unrelated to the current ground.
  43152. * This will be the y position of this camera, when ground level is 0.
  43153. */
  43154. get realWorldHeight(): number;
  43155. /** @hidden */
  43156. _updateForDualEyeDebugging(): void;
  43157. /**
  43158. * Sets this camera's transformation based on a non-vr camera
  43159. * @param otherCamera the non-vr camera to copy the transformation from
  43160. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43161. */
  43162. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43163. /**
  43164. * Gets the current instance class name ("WebXRCamera").
  43165. * @returns the class name
  43166. */
  43167. getClassName(): string;
  43168. private _updateFromXRSession;
  43169. private _updateNumberOfRigCameras;
  43170. private _updateReferenceSpace;
  43171. private _updateReferenceSpaceOffset;
  43172. }
  43173. }
  43174. declare module BABYLON {
  43175. /**
  43176. * Defining the interface required for a (webxr) feature
  43177. */
  43178. export interface IWebXRFeature extends IDisposable {
  43179. /**
  43180. * Is this feature attached
  43181. */
  43182. attached: boolean;
  43183. /**
  43184. * Should auto-attach be disabled?
  43185. */
  43186. disableAutoAttach: boolean;
  43187. /**
  43188. * Attach the feature to the session
  43189. * Will usually be called by the features manager
  43190. *
  43191. * @param force should attachment be forced (even when already attached)
  43192. * @returns true if successful.
  43193. */
  43194. attach(force?: boolean): boolean;
  43195. /**
  43196. * Detach the feature from the session
  43197. * Will usually be called by the features manager
  43198. *
  43199. * @returns true if successful.
  43200. */
  43201. detach(): boolean;
  43202. }
  43203. /**
  43204. * A list of the currently available features without referencing them
  43205. */
  43206. export class WebXRFeatureName {
  43207. /**
  43208. * The name of the anchor system feature
  43209. */
  43210. static ANCHOR_SYSTEM: string;
  43211. /**
  43212. * The name of the background remover feature
  43213. */
  43214. static BACKGROUND_REMOVER: string;
  43215. /**
  43216. * The name of the hit test feature
  43217. */
  43218. static HIT_TEST: string;
  43219. /**
  43220. * physics impostors for xr controllers feature
  43221. */
  43222. static PHYSICS_CONTROLLERS: string;
  43223. /**
  43224. * The name of the plane detection feature
  43225. */
  43226. static PLANE_DETECTION: string;
  43227. /**
  43228. * The name of the pointer selection feature
  43229. */
  43230. static POINTER_SELECTION: string;
  43231. /**
  43232. * The name of the teleportation feature
  43233. */
  43234. static TELEPORTATION: string;
  43235. }
  43236. /**
  43237. * Defining the constructor of a feature. Used to register the modules.
  43238. */
  43239. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43240. /**
  43241. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43242. * It is mainly used in AR sessions.
  43243. *
  43244. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43245. */
  43246. export class WebXRFeaturesManager implements IDisposable {
  43247. private _xrSessionManager;
  43248. private static readonly _AvailableFeatures;
  43249. private _features;
  43250. /**
  43251. * constructs a new features manages.
  43252. *
  43253. * @param _xrSessionManager an instance of WebXRSessionManager
  43254. */
  43255. constructor(_xrSessionManager: WebXRSessionManager);
  43256. /**
  43257. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43258. * Mainly used internally.
  43259. *
  43260. * @param featureName the name of the feature to register
  43261. * @param constructorFunction the function used to construct the module
  43262. * @param version the (babylon) version of the module
  43263. * @param stable is that a stable version of this module
  43264. */
  43265. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43266. /**
  43267. * Returns a constructor of a specific feature.
  43268. *
  43269. * @param featureName the name of the feature to construct
  43270. * @param version the version of the feature to load
  43271. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43272. * @param options optional options provided to the module.
  43273. * @returns a function that, when called, will return a new instance of this feature
  43274. */
  43275. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43276. /**
  43277. * Can be used to return the list of features currently registered
  43278. *
  43279. * @returns an Array of available features
  43280. */
  43281. static GetAvailableFeatures(): string[];
  43282. /**
  43283. * Gets the versions available for a specific feature
  43284. * @param featureName the name of the feature
  43285. * @returns an array with the available versions
  43286. */
  43287. static GetAvailableVersions(featureName: string): string[];
  43288. /**
  43289. * Return the latest unstable version of this feature
  43290. * @param featureName the name of the feature to search
  43291. * @returns the version number. if not found will return -1
  43292. */
  43293. static GetLatestVersionOfFeature(featureName: string): number;
  43294. /**
  43295. * Return the latest stable version of this feature
  43296. * @param featureName the name of the feature to search
  43297. * @returns the version number. if not found will return -1
  43298. */
  43299. static GetStableVersionOfFeature(featureName: string): number;
  43300. /**
  43301. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43302. * Can be used during a session to start a feature
  43303. * @param featureName the name of feature to attach
  43304. */
  43305. attachFeature(featureName: string): void;
  43306. /**
  43307. * Can be used inside a session or when the session ends to detach a specific feature
  43308. * @param featureName the name of the feature to detach
  43309. */
  43310. detachFeature(featureName: string): void;
  43311. /**
  43312. * Used to disable an already-enabled feature
  43313. * The feature will be disposed and will be recreated once enabled.
  43314. * @param featureName the feature to disable
  43315. * @returns true if disable was successful
  43316. */
  43317. disableFeature(featureName: string | {
  43318. Name: string;
  43319. }): boolean;
  43320. /**
  43321. * dispose this features manager
  43322. */
  43323. dispose(): void;
  43324. /**
  43325. * 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.
  43326. * 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.
  43327. *
  43328. * @param featureName the name of the feature to load or the class of the feature
  43329. * @param version optional version to load. if not provided the latest version will be enabled
  43330. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43331. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43332. * @returns a new constructed feature or throws an error if feature not found.
  43333. */
  43334. enableFeature(featureName: string | {
  43335. Name: string;
  43336. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43337. /**
  43338. * get the implementation of an enabled feature.
  43339. * @param featureName the name of the feature to load
  43340. * @returns the feature class, if found
  43341. */
  43342. getEnabledFeature(featureName: string): IWebXRFeature;
  43343. /**
  43344. * Get the list of enabled features
  43345. * @returns an array of enabled features
  43346. */
  43347. getEnabledFeatures(): string[];
  43348. }
  43349. }
  43350. declare module BABYLON {
  43351. /**
  43352. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43353. * @see https://doc.babylonjs.com/how_to/webxr
  43354. */
  43355. export class WebXRExperienceHelper implements IDisposable {
  43356. private scene;
  43357. private _nonVRCamera;
  43358. private _originalSceneAutoClear;
  43359. private _supported;
  43360. /**
  43361. * Camera used to render xr content
  43362. */
  43363. camera: WebXRCamera;
  43364. /** A features manager for this xr session */
  43365. featuresManager: WebXRFeaturesManager;
  43366. /**
  43367. * Observers registered here will be triggered after the camera's initial transformation is set
  43368. * This can be used to set a different ground level or an extra rotation.
  43369. *
  43370. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43371. * to the position set after this observable is done executing.
  43372. */
  43373. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43374. /**
  43375. * Fires when the state of the experience helper has changed
  43376. */
  43377. onStateChangedObservable: Observable<WebXRState>;
  43378. /** Session manager used to keep track of xr session */
  43379. sessionManager: WebXRSessionManager;
  43380. /**
  43381. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43382. */
  43383. state: WebXRState;
  43384. /**
  43385. * Creates a WebXRExperienceHelper
  43386. * @param scene The scene the helper should be created in
  43387. */
  43388. private constructor();
  43389. /**
  43390. * Creates the experience helper
  43391. * @param scene the scene to attach the experience helper to
  43392. * @returns a promise for the experience helper
  43393. */
  43394. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43395. /**
  43396. * Disposes of the experience helper
  43397. */
  43398. dispose(): void;
  43399. /**
  43400. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43401. * @param sessionMode options for the XR session
  43402. * @param referenceSpaceType frame of reference of the XR session
  43403. * @param renderTarget the output canvas that will be used to enter XR mode
  43404. * @returns promise that resolves after xr mode has entered
  43405. */
  43406. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43407. /**
  43408. * Exits XR mode and returns the scene to its original state
  43409. * @returns promise that resolves after xr mode has exited
  43410. */
  43411. exitXRAsync(): Promise<void>;
  43412. private _nonXRToXRCamera;
  43413. private _setState;
  43414. }
  43415. }
  43416. declare module BABYLON {
  43417. /**
  43418. * X-Y values for axes in WebXR
  43419. */
  43420. export interface IWebXRMotionControllerAxesValue {
  43421. /**
  43422. * The value of the x axis
  43423. */
  43424. x: number;
  43425. /**
  43426. * The value of the y-axis
  43427. */
  43428. y: number;
  43429. }
  43430. /**
  43431. * changed / previous values for the values of this component
  43432. */
  43433. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43434. /**
  43435. * current (this frame) value
  43436. */
  43437. current: T;
  43438. /**
  43439. * previous (last change) value
  43440. */
  43441. previous: T;
  43442. }
  43443. /**
  43444. * Represents changes in the component between current frame and last values recorded
  43445. */
  43446. export interface IWebXRMotionControllerComponentChanges {
  43447. /**
  43448. * will be populated with previous and current values if axes changed
  43449. */
  43450. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43451. /**
  43452. * will be populated with previous and current values if pressed changed
  43453. */
  43454. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43455. /**
  43456. * will be populated with previous and current values if touched changed
  43457. */
  43458. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43459. /**
  43460. * will be populated with previous and current values if value changed
  43461. */
  43462. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43463. }
  43464. /**
  43465. * This class represents a single component (for example button or thumbstick) of a motion controller
  43466. */
  43467. export class WebXRControllerComponent implements IDisposable {
  43468. /**
  43469. * the id of this component
  43470. */
  43471. id: string;
  43472. /**
  43473. * the type of the component
  43474. */
  43475. type: MotionControllerComponentType;
  43476. private _buttonIndex;
  43477. private _axesIndices;
  43478. private _axes;
  43479. private _changes;
  43480. private _currentValue;
  43481. private _hasChanges;
  43482. private _pressed;
  43483. private _touched;
  43484. /**
  43485. * button component type
  43486. */
  43487. static BUTTON_TYPE: MotionControllerComponentType;
  43488. /**
  43489. * squeeze component type
  43490. */
  43491. static SQUEEZE_TYPE: MotionControllerComponentType;
  43492. /**
  43493. * Thumbstick component type
  43494. */
  43495. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43496. /**
  43497. * Touchpad component type
  43498. */
  43499. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43500. /**
  43501. * trigger component type
  43502. */
  43503. static TRIGGER_TYPE: MotionControllerComponentType;
  43504. /**
  43505. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43506. * the axes data changes
  43507. */
  43508. onAxisValueChangedObservable: Observable<{
  43509. x: number;
  43510. y: number;
  43511. }>;
  43512. /**
  43513. * Observers registered here will be triggered when the state of a button changes
  43514. * State change is either pressed / touched / value
  43515. */
  43516. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43517. /**
  43518. * Creates a new component for a motion controller.
  43519. * It is created by the motion controller itself
  43520. *
  43521. * @param id the id of this component
  43522. * @param type the type of the component
  43523. * @param _buttonIndex index in the buttons array of the gamepad
  43524. * @param _axesIndices indices of the values in the axes array of the gamepad
  43525. */
  43526. constructor(
  43527. /**
  43528. * the id of this component
  43529. */
  43530. id: string,
  43531. /**
  43532. * the type of the component
  43533. */
  43534. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43535. /**
  43536. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43537. */
  43538. get axes(): IWebXRMotionControllerAxesValue;
  43539. /**
  43540. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43541. */
  43542. get changes(): IWebXRMotionControllerComponentChanges;
  43543. /**
  43544. * Return whether or not the component changed the last frame
  43545. */
  43546. get hasChanges(): boolean;
  43547. /**
  43548. * is the button currently pressed
  43549. */
  43550. get pressed(): boolean;
  43551. /**
  43552. * is the button currently touched
  43553. */
  43554. get touched(): boolean;
  43555. /**
  43556. * Get the current value of this component
  43557. */
  43558. get value(): number;
  43559. /**
  43560. * Dispose this component
  43561. */
  43562. dispose(): void;
  43563. /**
  43564. * Are there axes correlating to this component
  43565. * @return true is axes data is available
  43566. */
  43567. isAxes(): boolean;
  43568. /**
  43569. * Is this component a button (hence - pressable)
  43570. * @returns true if can be pressed
  43571. */
  43572. isButton(): boolean;
  43573. /**
  43574. * update this component using the gamepad object it is in. Called on every frame
  43575. * @param nativeController the native gamepad controller object
  43576. */
  43577. update(nativeController: IMinimalMotionControllerObject): void;
  43578. }
  43579. }
  43580. declare module BABYLON {
  43581. /**
  43582. * Class used to represent data loading progression
  43583. */
  43584. export class SceneLoaderProgressEvent {
  43585. /** defines if data length to load can be evaluated */
  43586. readonly lengthComputable: boolean;
  43587. /** defines the loaded data length */
  43588. readonly loaded: number;
  43589. /** defines the data length to load */
  43590. readonly total: number;
  43591. /**
  43592. * Create a new progress event
  43593. * @param lengthComputable defines if data length to load can be evaluated
  43594. * @param loaded defines the loaded data length
  43595. * @param total defines the data length to load
  43596. */
  43597. constructor(
  43598. /** defines if data length to load can be evaluated */
  43599. lengthComputable: boolean,
  43600. /** defines the loaded data length */
  43601. loaded: number,
  43602. /** defines the data length to load */
  43603. total: number);
  43604. /**
  43605. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43606. * @param event defines the source event
  43607. * @returns a new SceneLoaderProgressEvent
  43608. */
  43609. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43610. }
  43611. /**
  43612. * Interface used by SceneLoader plugins to define supported file extensions
  43613. */
  43614. export interface ISceneLoaderPluginExtensions {
  43615. /**
  43616. * Defines the list of supported extensions
  43617. */
  43618. [extension: string]: {
  43619. isBinary: boolean;
  43620. };
  43621. }
  43622. /**
  43623. * Interface used by SceneLoader plugin factory
  43624. */
  43625. export interface ISceneLoaderPluginFactory {
  43626. /**
  43627. * Defines the name of the factory
  43628. */
  43629. name: string;
  43630. /**
  43631. * Function called to create a new plugin
  43632. * @return the new plugin
  43633. */
  43634. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43635. /**
  43636. * The callback that returns true if the data can be directly loaded.
  43637. * @param data string containing the file data
  43638. * @returns if the data can be loaded directly
  43639. */
  43640. canDirectLoad?(data: string): boolean;
  43641. }
  43642. /**
  43643. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43644. */
  43645. export interface ISceneLoaderPluginBase {
  43646. /**
  43647. * The friendly name of this plugin.
  43648. */
  43649. name: string;
  43650. /**
  43651. * The file extensions supported by this plugin.
  43652. */
  43653. extensions: string | ISceneLoaderPluginExtensions;
  43654. /**
  43655. * The callback called when loading from a url.
  43656. * @param scene scene loading this url
  43657. * @param url url to load
  43658. * @param onSuccess callback called when the file successfully loads
  43659. * @param onProgress callback called while file is loading (if the server supports this mode)
  43660. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43661. * @param onError callback called when the file fails to load
  43662. * @returns a file request object
  43663. */
  43664. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43665. /**
  43666. * The callback called when loading from a file object.
  43667. * @param scene scene loading this file
  43668. * @param file defines the file to load
  43669. * @param onSuccess defines the callback to call when data is loaded
  43670. * @param onProgress defines the callback to call during loading process
  43671. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43672. * @param onError defines the callback to call when an error occurs
  43673. * @returns a file request object
  43674. */
  43675. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43676. /**
  43677. * The callback that returns true if the data can be directly loaded.
  43678. * @param data string containing the file data
  43679. * @returns if the data can be loaded directly
  43680. */
  43681. canDirectLoad?(data: string): boolean;
  43682. /**
  43683. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43684. * @param scene scene loading this data
  43685. * @param data string containing the data
  43686. * @returns data to pass to the plugin
  43687. */
  43688. directLoad?(scene: Scene, data: string): any;
  43689. /**
  43690. * The callback that allows custom handling of the root url based on the response url.
  43691. * @param rootUrl the original root url
  43692. * @param responseURL the response url if available
  43693. * @returns the new root url
  43694. */
  43695. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43696. }
  43697. /**
  43698. * Interface used to define a SceneLoader plugin
  43699. */
  43700. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43701. /**
  43702. * Import meshes into a scene.
  43703. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43704. * @param scene The scene to import into
  43705. * @param data The data to import
  43706. * @param rootUrl The root url for scene and resources
  43707. * @param meshes The meshes array to import into
  43708. * @param particleSystems The particle systems array to import into
  43709. * @param skeletons The skeletons array to import into
  43710. * @param onError The callback when import fails
  43711. * @returns True if successful or false otherwise
  43712. */
  43713. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43714. /**
  43715. * Load into a scene.
  43716. * @param scene The scene to load into
  43717. * @param data The data to import
  43718. * @param rootUrl The root url for scene and resources
  43719. * @param onError The callback when import fails
  43720. * @returns True if successful or false otherwise
  43721. */
  43722. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43723. /**
  43724. * Load into an asset container.
  43725. * @param scene The scene to load into
  43726. * @param data The data to import
  43727. * @param rootUrl The root url for scene and resources
  43728. * @param onError The callback when import fails
  43729. * @returns The loaded asset container
  43730. */
  43731. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43732. }
  43733. /**
  43734. * Interface used to define an async SceneLoader plugin
  43735. */
  43736. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43737. /**
  43738. * Import meshes into a scene.
  43739. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43740. * @param scene The scene to import into
  43741. * @param data The data to import
  43742. * @param rootUrl The root url for scene and resources
  43743. * @param onProgress The callback when the load progresses
  43744. * @param fileName Defines the name of the file to load
  43745. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43746. */
  43747. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43748. meshes: AbstractMesh[];
  43749. particleSystems: IParticleSystem[];
  43750. skeletons: Skeleton[];
  43751. animationGroups: AnimationGroup[];
  43752. }>;
  43753. /**
  43754. * Load into a scene.
  43755. * @param scene The scene to load into
  43756. * @param data The data to import
  43757. * @param rootUrl The root url for scene and resources
  43758. * @param onProgress The callback when the load progresses
  43759. * @param fileName Defines the name of the file to load
  43760. * @returns Nothing
  43761. */
  43762. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43763. /**
  43764. * Load into an asset container.
  43765. * @param scene The scene to load into
  43766. * @param data The data to import
  43767. * @param rootUrl The root url for scene and resources
  43768. * @param onProgress The callback when the load progresses
  43769. * @param fileName Defines the name of the file to load
  43770. * @returns The loaded asset container
  43771. */
  43772. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43773. }
  43774. /**
  43775. * Mode that determines how to handle old animation groups before loading new ones.
  43776. */
  43777. export enum SceneLoaderAnimationGroupLoadingMode {
  43778. /**
  43779. * Reset all old animations to initial state then dispose them.
  43780. */
  43781. Clean = 0,
  43782. /**
  43783. * Stop all old animations.
  43784. */
  43785. Stop = 1,
  43786. /**
  43787. * Restart old animations from first frame.
  43788. */
  43789. Sync = 2,
  43790. /**
  43791. * Old animations remains untouched.
  43792. */
  43793. NoSync = 3
  43794. }
  43795. /**
  43796. * Class used to load scene from various file formats using registered plugins
  43797. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43798. */
  43799. export class SceneLoader {
  43800. /**
  43801. * No logging while loading
  43802. */
  43803. static readonly NO_LOGGING: number;
  43804. /**
  43805. * Minimal logging while loading
  43806. */
  43807. static readonly MINIMAL_LOGGING: number;
  43808. /**
  43809. * Summary logging while loading
  43810. */
  43811. static readonly SUMMARY_LOGGING: number;
  43812. /**
  43813. * Detailled logging while loading
  43814. */
  43815. static readonly DETAILED_LOGGING: number;
  43816. /**
  43817. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43818. */
  43819. static get ForceFullSceneLoadingForIncremental(): boolean;
  43820. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43821. /**
  43822. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43823. */
  43824. static get ShowLoadingScreen(): boolean;
  43825. static set ShowLoadingScreen(value: boolean);
  43826. /**
  43827. * Defines the current logging level (while loading the scene)
  43828. * @ignorenaming
  43829. */
  43830. static get loggingLevel(): number;
  43831. static set loggingLevel(value: number);
  43832. /**
  43833. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43834. */
  43835. static get CleanBoneMatrixWeights(): boolean;
  43836. static set CleanBoneMatrixWeights(value: boolean);
  43837. /**
  43838. * Event raised when a plugin is used to load a scene
  43839. */
  43840. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43841. private static _registeredPlugins;
  43842. private static _getDefaultPlugin;
  43843. private static _getPluginForExtension;
  43844. private static _getPluginForDirectLoad;
  43845. private static _getPluginForFilename;
  43846. private static _getDirectLoad;
  43847. private static _loadData;
  43848. private static _getFileInfo;
  43849. /**
  43850. * Gets a plugin that can load the given extension
  43851. * @param extension defines the extension to load
  43852. * @returns a plugin or null if none works
  43853. */
  43854. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43855. /**
  43856. * Gets a boolean indicating that the given extension can be loaded
  43857. * @param extension defines the extension to load
  43858. * @returns true if the extension is supported
  43859. */
  43860. static IsPluginForExtensionAvailable(extension: string): boolean;
  43861. /**
  43862. * Adds a new plugin to the list of registered plugins
  43863. * @param plugin defines the plugin to add
  43864. */
  43865. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43866. /**
  43867. * Import meshes into a scene
  43868. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43869. * @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)
  43870. * @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)
  43871. * @param scene the instance of BABYLON.Scene to append to
  43872. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43873. * @param onProgress a callback with a progress event for each file being loaded
  43874. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43875. * @param pluginExtension the extension used to determine the plugin
  43876. * @returns The loaded plugin
  43877. */
  43878. 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>;
  43879. /**
  43880. * Import meshes into a scene
  43881. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43882. * @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)
  43883. * @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)
  43884. * @param scene the instance of BABYLON.Scene to append to
  43885. * @param onProgress a callback with a progress event for each file being loaded
  43886. * @param pluginExtension the extension used to determine the plugin
  43887. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43888. */
  43889. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43890. meshes: AbstractMesh[];
  43891. particleSystems: IParticleSystem[];
  43892. skeletons: Skeleton[];
  43893. animationGroups: AnimationGroup[];
  43894. }>;
  43895. /**
  43896. * Load a scene
  43897. * @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)
  43898. * @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)
  43899. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43900. * @param onSuccess a callback with the scene when import succeeds
  43901. * @param onProgress a callback with a progress event for each file being loaded
  43902. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43903. * @param pluginExtension the extension used to determine the plugin
  43904. * @returns The loaded plugin
  43905. */
  43906. 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>;
  43907. /**
  43908. * Load a scene
  43909. * @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)
  43910. * @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)
  43911. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43912. * @param onProgress a callback with a progress event for each file being loaded
  43913. * @param pluginExtension the extension used to determine the plugin
  43914. * @returns The loaded scene
  43915. */
  43916. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43917. /**
  43918. * Append a scene
  43919. * @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)
  43920. * @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)
  43921. * @param scene is the instance of BABYLON.Scene to append to
  43922. * @param onSuccess a callback with the scene when import succeeds
  43923. * @param onProgress a callback with a progress event for each file being loaded
  43924. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43925. * @param pluginExtension the extension used to determine the plugin
  43926. * @returns The loaded plugin
  43927. */
  43928. 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>;
  43929. /**
  43930. * Append a scene
  43931. * @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)
  43932. * @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)
  43933. * @param scene is the instance of BABYLON.Scene to append to
  43934. * @param onProgress a callback with a progress event for each file being loaded
  43935. * @param pluginExtension the extension used to determine the plugin
  43936. * @returns The given scene
  43937. */
  43938. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43939. /**
  43940. * Load a scene into an asset container
  43941. * @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)
  43942. * @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)
  43943. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43944. * @param onSuccess a callback with the scene when import succeeds
  43945. * @param onProgress a callback with a progress event for each file being loaded
  43946. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43947. * @param pluginExtension the extension used to determine the plugin
  43948. * @returns The loaded plugin
  43949. */
  43950. 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>;
  43951. /**
  43952. * Load a scene into an asset container
  43953. * @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)
  43954. * @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)
  43955. * @param scene is the instance of Scene to append to
  43956. * @param onProgress a callback with a progress event for each file being loaded
  43957. * @param pluginExtension the extension used to determine the plugin
  43958. * @returns The loaded asset container
  43959. */
  43960. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43961. /**
  43962. * Import animations from a file into a scene
  43963. * @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)
  43964. * @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)
  43965. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43966. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43967. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43968. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43969. * @param onSuccess a callback with the scene when import succeeds
  43970. * @param onProgress a callback with a progress event for each file being loaded
  43971. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43972. */
  43973. 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;
  43974. /**
  43975. * Import animations from a file into a scene
  43976. * @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)
  43977. * @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)
  43978. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43979. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43980. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43981. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43982. * @param onSuccess a callback with the scene when import succeeds
  43983. * @param onProgress a callback with a progress event for each file being loaded
  43984. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43985. * @returns the updated scene with imported animations
  43986. */
  43987. 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>;
  43988. }
  43989. }
  43990. declare module BABYLON {
  43991. /**
  43992. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43993. */
  43994. export type MotionControllerHandness = "none" | "left" | "right";
  43995. /**
  43996. * The type of components available in motion controllers.
  43997. * This is not the name of the component.
  43998. */
  43999. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44000. /**
  44001. * The state of a controller component
  44002. */
  44003. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44004. /**
  44005. * The schema of motion controller layout.
  44006. * No object will be initialized using this interface
  44007. * This is used just to define the profile.
  44008. */
  44009. export interface IMotionControllerLayout {
  44010. /**
  44011. * Path to load the assets. Usually relative to the base path
  44012. */
  44013. assetPath: string;
  44014. /**
  44015. * Available components (unsorted)
  44016. */
  44017. components: {
  44018. /**
  44019. * A map of component Ids
  44020. */
  44021. [componentId: string]: {
  44022. /**
  44023. * The type of input the component outputs
  44024. */
  44025. type: MotionControllerComponentType;
  44026. /**
  44027. * The indices of this component in the gamepad object
  44028. */
  44029. gamepadIndices: {
  44030. /**
  44031. * Index of button
  44032. */
  44033. button?: number;
  44034. /**
  44035. * If available, index of x-axis
  44036. */
  44037. xAxis?: number;
  44038. /**
  44039. * If available, index of y-axis
  44040. */
  44041. yAxis?: number;
  44042. };
  44043. /**
  44044. * The mesh's root node name
  44045. */
  44046. rootNodeName: string;
  44047. /**
  44048. * Animation definitions for this model
  44049. */
  44050. visualResponses: {
  44051. [stateKey: string]: {
  44052. /**
  44053. * What property will be animated
  44054. */
  44055. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44056. /**
  44057. * What states influence this visual response
  44058. */
  44059. states: MotionControllerComponentStateType[];
  44060. /**
  44061. * Type of animation - movement or visibility
  44062. */
  44063. valueNodeProperty: "transform" | "visibility";
  44064. /**
  44065. * Base node name to move. Its position will be calculated according to the min and max nodes
  44066. */
  44067. valueNodeName?: string;
  44068. /**
  44069. * Minimum movement node
  44070. */
  44071. minNodeName?: string;
  44072. /**
  44073. * Max movement node
  44074. */
  44075. maxNodeName?: string;
  44076. };
  44077. };
  44078. /**
  44079. * If touch enabled, what is the name of node to display user feedback
  44080. */
  44081. touchPointNodeName?: string;
  44082. };
  44083. };
  44084. /**
  44085. * Is it xr standard mapping or not
  44086. */
  44087. gamepadMapping: "" | "xr-standard";
  44088. /**
  44089. * Base root node of this entire model
  44090. */
  44091. rootNodeName: string;
  44092. /**
  44093. * Defines the main button component id
  44094. */
  44095. selectComponentId: string;
  44096. }
  44097. /**
  44098. * A definition for the layout map in the input profile
  44099. */
  44100. export interface IMotionControllerLayoutMap {
  44101. /**
  44102. * Layouts with handness type as a key
  44103. */
  44104. [handness: string]: IMotionControllerLayout;
  44105. }
  44106. /**
  44107. * The XR Input profile schema
  44108. * Profiles can be found here:
  44109. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44110. */
  44111. export interface IMotionControllerProfile {
  44112. /**
  44113. * fallback profiles for this profileId
  44114. */
  44115. fallbackProfileIds: string[];
  44116. /**
  44117. * The layout map, with handness as key
  44118. */
  44119. layouts: IMotionControllerLayoutMap;
  44120. /**
  44121. * The id of this profile
  44122. * correlates to the profile(s) in the xrInput.profiles array
  44123. */
  44124. profileId: string;
  44125. }
  44126. /**
  44127. * A helper-interface for the 3 meshes needed for controller button animation
  44128. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44129. */
  44130. export interface IMotionControllerButtonMeshMap {
  44131. /**
  44132. * the mesh that defines the pressed value mesh position.
  44133. * This is used to find the max-position of this button
  44134. */
  44135. pressedMesh: AbstractMesh;
  44136. /**
  44137. * the mesh that defines the unpressed value mesh position.
  44138. * This is used to find the min (or initial) position of this button
  44139. */
  44140. unpressedMesh: AbstractMesh;
  44141. /**
  44142. * The mesh that will be changed when value changes
  44143. */
  44144. valueMesh: AbstractMesh;
  44145. }
  44146. /**
  44147. * A helper-interface for the 3 meshes needed for controller axis animation.
  44148. * This will be expanded when touchpad animations are fully supported
  44149. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44150. */
  44151. export interface IMotionControllerMeshMap {
  44152. /**
  44153. * the mesh that defines the maximum value mesh position.
  44154. */
  44155. maxMesh?: AbstractMesh;
  44156. /**
  44157. * the mesh that defines the minimum value mesh position.
  44158. */
  44159. minMesh?: AbstractMesh;
  44160. /**
  44161. * The mesh that will be changed when axis value changes
  44162. */
  44163. valueMesh: AbstractMesh;
  44164. }
  44165. /**
  44166. * The elements needed for change-detection of the gamepad objects in motion controllers
  44167. */
  44168. export interface IMinimalMotionControllerObject {
  44169. /**
  44170. * Available axes of this controller
  44171. */
  44172. axes: number[];
  44173. /**
  44174. * An array of available buttons
  44175. */
  44176. buttons: Array<{
  44177. /**
  44178. * Value of the button/trigger
  44179. */
  44180. value: number;
  44181. /**
  44182. * If the button/trigger is currently touched
  44183. */
  44184. touched: boolean;
  44185. /**
  44186. * If the button/trigger is currently pressed
  44187. */
  44188. pressed: boolean;
  44189. }>;
  44190. }
  44191. /**
  44192. * An Abstract Motion controller
  44193. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44194. * Each component has an observable to check for changes in value and state
  44195. */
  44196. export abstract class WebXRAbstractMotionController implements IDisposable {
  44197. protected scene: Scene;
  44198. protected layout: IMotionControllerLayout;
  44199. /**
  44200. * The gamepad object correlating to this controller
  44201. */
  44202. gamepadObject: IMinimalMotionControllerObject;
  44203. /**
  44204. * handness (left/right/none) of this controller
  44205. */
  44206. handness: MotionControllerHandness;
  44207. private _initComponent;
  44208. private _modelReady;
  44209. /**
  44210. * A map of components (WebXRControllerComponent) in this motion controller
  44211. * Components have a ComponentType and can also have both button and axis definitions
  44212. */
  44213. readonly components: {
  44214. [id: string]: WebXRControllerComponent;
  44215. };
  44216. /**
  44217. * Disable the model's animation. Can be set at any time.
  44218. */
  44219. disableAnimation: boolean;
  44220. /**
  44221. * Observers registered here will be triggered when the model of this controller is done loading
  44222. */
  44223. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44224. /**
  44225. * The profile id of this motion controller
  44226. */
  44227. abstract profileId: string;
  44228. /**
  44229. * The root mesh of the model. It is null if the model was not yet initialized
  44230. */
  44231. rootMesh: Nullable<AbstractMesh>;
  44232. /**
  44233. * constructs a new abstract motion controller
  44234. * @param scene the scene to which the model of the controller will be added
  44235. * @param layout The profile layout to load
  44236. * @param gamepadObject The gamepad object correlating to this controller
  44237. * @param handness handness (left/right/none) of this controller
  44238. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44239. */
  44240. constructor(scene: Scene, layout: IMotionControllerLayout,
  44241. /**
  44242. * The gamepad object correlating to this controller
  44243. */
  44244. gamepadObject: IMinimalMotionControllerObject,
  44245. /**
  44246. * handness (left/right/none) of this controller
  44247. */
  44248. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44249. /**
  44250. * Dispose this controller, the model mesh and all its components
  44251. */
  44252. dispose(): void;
  44253. /**
  44254. * Returns all components of specific type
  44255. * @param type the type to search for
  44256. * @return an array of components with this type
  44257. */
  44258. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44259. /**
  44260. * get a component based an its component id as defined in layout.components
  44261. * @param id the id of the component
  44262. * @returns the component correlates to the id or undefined if not found
  44263. */
  44264. getComponent(id: string): WebXRControllerComponent;
  44265. /**
  44266. * Get the list of components available in this motion controller
  44267. * @returns an array of strings correlating to available components
  44268. */
  44269. getComponentIds(): string[];
  44270. /**
  44271. * Get the first component of specific type
  44272. * @param type type of component to find
  44273. * @return a controller component or null if not found
  44274. */
  44275. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44276. /**
  44277. * Get the main (Select) component of this controller as defined in the layout
  44278. * @returns the main component of this controller
  44279. */
  44280. getMainComponent(): WebXRControllerComponent;
  44281. /**
  44282. * Loads the model correlating to this controller
  44283. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44284. * @returns A promise fulfilled with the result of the model loading
  44285. */
  44286. loadModel(): Promise<boolean>;
  44287. /**
  44288. * Update this model using the current XRFrame
  44289. * @param xrFrame the current xr frame to use and update the model
  44290. */
  44291. updateFromXRFrame(xrFrame: XRFrame): void;
  44292. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44293. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44294. /**
  44295. * Moves the axis on the controller mesh based on its current state
  44296. * @param axis the index of the axis
  44297. * @param axisValue the value of the axis which determines the meshes new position
  44298. * @hidden
  44299. */
  44300. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44301. /**
  44302. * Update the model itself with the current frame data
  44303. * @param xrFrame the frame to use for updating the model mesh
  44304. */
  44305. protected updateModel(xrFrame: XRFrame): void;
  44306. /**
  44307. * Get the filename and path for this controller's model
  44308. * @returns a map of filename and path
  44309. */
  44310. protected abstract _getFilenameAndPath(): {
  44311. filename: string;
  44312. path: string;
  44313. };
  44314. /**
  44315. * This function is called before the mesh is loaded. It checks for loading constraints.
  44316. * For example, this function can check if the GLB loader is available
  44317. * If this function returns false, the generic controller will be loaded instead
  44318. * @returns Is the client ready to load the mesh
  44319. */
  44320. protected abstract _getModelLoadingConstraints(): boolean;
  44321. /**
  44322. * This function will be called after the model was successfully loaded and can be used
  44323. * for mesh transformations before it is available for the user
  44324. * @param meshes the loaded meshes
  44325. */
  44326. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44327. /**
  44328. * Set the root mesh for this controller. Important for the WebXR controller class
  44329. * @param meshes the loaded meshes
  44330. */
  44331. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44332. /**
  44333. * A function executed each frame that updates the mesh (if needed)
  44334. * @param xrFrame the current xrFrame
  44335. */
  44336. protected abstract _updateModel(xrFrame: XRFrame): void;
  44337. private _getGenericFilenameAndPath;
  44338. private _getGenericParentMesh;
  44339. }
  44340. }
  44341. declare module BABYLON {
  44342. /**
  44343. * A generic trigger-only motion controller for WebXR
  44344. */
  44345. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44346. /**
  44347. * Static version of the profile id of this controller
  44348. */
  44349. static ProfileId: string;
  44350. profileId: string;
  44351. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44352. protected _getFilenameAndPath(): {
  44353. filename: string;
  44354. path: string;
  44355. };
  44356. protected _getModelLoadingConstraints(): boolean;
  44357. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44358. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44359. protected _updateModel(): void;
  44360. }
  44361. }
  44362. declare module BABYLON {
  44363. /**
  44364. * Class containing static functions to help procedurally build meshes
  44365. */
  44366. export class SphereBuilder {
  44367. /**
  44368. * Creates a sphere mesh
  44369. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44370. * * 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`)
  44371. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44372. * * 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
  44373. * * 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)
  44374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44375. * * 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
  44376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44377. * @param name defines the name of the mesh
  44378. * @param options defines the options used to create the mesh
  44379. * @param scene defines the hosting scene
  44380. * @returns the sphere mesh
  44381. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44382. */
  44383. static CreateSphere(name: string, options: {
  44384. segments?: number;
  44385. diameter?: number;
  44386. diameterX?: number;
  44387. diameterY?: number;
  44388. diameterZ?: number;
  44389. arc?: number;
  44390. slice?: number;
  44391. sideOrientation?: number;
  44392. frontUVs?: Vector4;
  44393. backUVs?: Vector4;
  44394. updatable?: boolean;
  44395. }, scene?: Nullable<Scene>): Mesh;
  44396. }
  44397. }
  44398. declare module BABYLON {
  44399. /**
  44400. * A profiled motion controller has its profile loaded from an online repository.
  44401. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44402. */
  44403. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44404. private _repositoryUrl;
  44405. private _buttonMeshMapping;
  44406. private _touchDots;
  44407. /**
  44408. * The profile ID of this controller. Will be populated when the controller initializes.
  44409. */
  44410. profileId: string;
  44411. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44412. dispose(): void;
  44413. protected _getFilenameAndPath(): {
  44414. filename: string;
  44415. path: string;
  44416. };
  44417. protected _getModelLoadingConstraints(): boolean;
  44418. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44419. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44420. protected _updateModel(_xrFrame: XRFrame): void;
  44421. }
  44422. }
  44423. declare module BABYLON {
  44424. /**
  44425. * A construction function type to create a new controller based on an xrInput object
  44426. */
  44427. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44428. /**
  44429. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44430. *
  44431. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44432. * it should be replaced with auto-loaded controllers.
  44433. *
  44434. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44435. */
  44436. export class WebXRMotionControllerManager {
  44437. private static _AvailableControllers;
  44438. private static _Fallbacks;
  44439. private static _ProfileLoadingPromises;
  44440. private static _ProfilesList;
  44441. /**
  44442. * The base URL of the online controller repository. Can be changed at any time.
  44443. */
  44444. static BaseRepositoryUrl: string;
  44445. /**
  44446. * Which repository gets priority - local or online
  44447. */
  44448. static PrioritizeOnlineRepository: boolean;
  44449. /**
  44450. * Use the online repository, or use only locally-defined controllers
  44451. */
  44452. static UseOnlineRepository: boolean;
  44453. /**
  44454. * Clear the cache used for profile loading and reload when requested again
  44455. */
  44456. static ClearProfilesCache(): void;
  44457. /**
  44458. * Register the default fallbacks.
  44459. * This function is called automatically when this file is imported.
  44460. */
  44461. static DefaultFallbacks(): void;
  44462. /**
  44463. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44464. * @param profileId the profile to which a fallback needs to be found
  44465. * @return an array with corresponding fallback profiles
  44466. */
  44467. static FindFallbackWithProfileId(profileId: string): string[];
  44468. /**
  44469. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44470. * The order of search:
  44471. *
  44472. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44473. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44474. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44475. * 4) return the generic trigger controller if none were found
  44476. *
  44477. * @param xrInput the xrInput to which a new controller is initialized
  44478. * @param scene the scene to which the model will be added
  44479. * @param forceProfile force a certain profile for this controller
  44480. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44481. */
  44482. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44483. /**
  44484. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44485. *
  44486. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44487. *
  44488. * @param type the profile type to register
  44489. * @param constructFunction the function to be called when loading this profile
  44490. */
  44491. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44492. /**
  44493. * Register a fallback to a specific profile.
  44494. * @param profileId the profileId that will receive the fallbacks
  44495. * @param fallbacks A list of fallback profiles
  44496. */
  44497. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44498. /**
  44499. * Will update the list of profiles available in the repository
  44500. * @return a promise that resolves to a map of profiles available online
  44501. */
  44502. static UpdateProfilesList(): Promise<{
  44503. [profile: string]: string;
  44504. }>;
  44505. private static _LoadProfileFromRepository;
  44506. private static _LoadProfilesFromAvailableControllers;
  44507. }
  44508. }
  44509. declare module BABYLON {
  44510. /**
  44511. * Configuration options for the WebXR controller creation
  44512. */
  44513. export interface IWebXRControllerOptions {
  44514. /**
  44515. * Should the controller mesh be animated when a user interacts with it
  44516. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44517. */
  44518. disableMotionControllerAnimation?: boolean;
  44519. /**
  44520. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44521. */
  44522. doNotLoadControllerMesh?: boolean;
  44523. /**
  44524. * Force a specific controller type for this controller.
  44525. * This can be used when creating your own profile or when testing different controllers
  44526. */
  44527. forceControllerProfile?: string;
  44528. }
  44529. /**
  44530. * Represents an XR controller
  44531. */
  44532. export class WebXRInputSource {
  44533. private _scene;
  44534. /** The underlying input source for the controller */
  44535. inputSource: XRInputSource;
  44536. private _options;
  44537. private _tmpQuaternion;
  44538. private _tmpVector;
  44539. private _uniqueId;
  44540. /**
  44541. * 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
  44542. */
  44543. grip?: AbstractMesh;
  44544. /**
  44545. * If available, this is the gamepad object related to this controller.
  44546. * Using this object it is possible to get click events and trackpad changes of the
  44547. * webxr controller that is currently being used.
  44548. */
  44549. motionController?: WebXRAbstractMotionController;
  44550. /**
  44551. * Event that fires when the controller is removed/disposed.
  44552. * The object provided as event data is this controller, after associated assets were disposed.
  44553. * uniqueId is still available.
  44554. */
  44555. onDisposeObservable: Observable<WebXRInputSource>;
  44556. /**
  44557. * Will be triggered when the mesh associated with the motion controller is done loading.
  44558. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44559. * A shortened version of controller -> motion controller -> on mesh loaded.
  44560. */
  44561. onMeshLoadedObservable: Observable<AbstractMesh>;
  44562. /**
  44563. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44564. */
  44565. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44566. /**
  44567. * Pointer which can be used to select objects or attach a visible laser to
  44568. */
  44569. pointer: AbstractMesh;
  44570. /**
  44571. * Creates the controller
  44572. * @see https://doc.babylonjs.com/how_to/webxr
  44573. * @param _scene the scene which the controller should be associated to
  44574. * @param inputSource the underlying input source for the controller
  44575. * @param _options options for this controller creation
  44576. */
  44577. constructor(_scene: Scene,
  44578. /** The underlying input source for the controller */
  44579. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44580. /**
  44581. * Get this controllers unique id
  44582. */
  44583. get uniqueId(): string;
  44584. /**
  44585. * Disposes of the object
  44586. */
  44587. dispose(): void;
  44588. /**
  44589. * Gets a world space ray coming from the pointer or grip
  44590. * @param result the resulting ray
  44591. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44592. */
  44593. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44594. /**
  44595. * Updates the controller pose based on the given XRFrame
  44596. * @param xrFrame xr frame to update the pose with
  44597. * @param referenceSpace reference space to use
  44598. */
  44599. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44600. }
  44601. }
  44602. declare module BABYLON {
  44603. /**
  44604. * The schema for initialization options of the XR Input class
  44605. */
  44606. export interface IWebXRInputOptions {
  44607. /**
  44608. * If set to true no model will be automatically loaded
  44609. */
  44610. doNotLoadControllerMeshes?: boolean;
  44611. /**
  44612. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44613. * If not found, the xr input profile data will be used.
  44614. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44615. */
  44616. forceInputProfile?: string;
  44617. /**
  44618. * Do not send a request to the controller repository to load the profile.
  44619. *
  44620. * Instead, use the controllers available in babylon itself.
  44621. */
  44622. disableOnlineControllerRepository?: boolean;
  44623. /**
  44624. * A custom URL for the controllers repository
  44625. */
  44626. customControllersRepositoryURL?: string;
  44627. /**
  44628. * Should the controller model's components not move according to the user input
  44629. */
  44630. disableControllerAnimation?: boolean;
  44631. }
  44632. /**
  44633. * XR input used to track XR inputs such as controllers/rays
  44634. */
  44635. export class WebXRInput implements IDisposable {
  44636. /**
  44637. * the xr session manager for this session
  44638. */
  44639. xrSessionManager: WebXRSessionManager;
  44640. /**
  44641. * the WebXR camera for this session. Mainly used for teleportation
  44642. */
  44643. xrCamera: WebXRCamera;
  44644. private readonly options;
  44645. /**
  44646. * XR controllers being tracked
  44647. */
  44648. controllers: Array<WebXRInputSource>;
  44649. private _frameObserver;
  44650. private _sessionEndedObserver;
  44651. private _sessionInitObserver;
  44652. /**
  44653. * Event when a controller has been connected/added
  44654. */
  44655. onControllerAddedObservable: Observable<WebXRInputSource>;
  44656. /**
  44657. * Event when a controller has been removed/disconnected
  44658. */
  44659. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44660. /**
  44661. * Initializes the WebXRInput
  44662. * @param xrSessionManager the xr session manager for this session
  44663. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44664. * @param options = initialization options for this xr input
  44665. */
  44666. constructor(
  44667. /**
  44668. * the xr session manager for this session
  44669. */
  44670. xrSessionManager: WebXRSessionManager,
  44671. /**
  44672. * the WebXR camera for this session. Mainly used for teleportation
  44673. */
  44674. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44675. private _onInputSourcesChange;
  44676. private _addAndRemoveControllers;
  44677. /**
  44678. * Disposes of the object
  44679. */
  44680. dispose(): void;
  44681. }
  44682. }
  44683. declare module BABYLON {
  44684. /**
  44685. * This is the base class for all WebXR features.
  44686. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44687. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44688. */
  44689. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44690. protected _xrSessionManager: WebXRSessionManager;
  44691. private _attached;
  44692. private _removeOnDetach;
  44693. /**
  44694. * Should auto-attach be disabled?
  44695. */
  44696. disableAutoAttach: boolean;
  44697. /**
  44698. * Construct a new (abstract) WebXR feature
  44699. * @param _xrSessionManager the xr session manager for this feature
  44700. */
  44701. constructor(_xrSessionManager: WebXRSessionManager);
  44702. /**
  44703. * Is this feature attached
  44704. */
  44705. get attached(): boolean;
  44706. /**
  44707. * attach this feature
  44708. *
  44709. * @param force should attachment be forced (even when already attached)
  44710. * @returns true if successful, false is failed or already attached
  44711. */
  44712. attach(force?: boolean): boolean;
  44713. /**
  44714. * detach this feature.
  44715. *
  44716. * @returns true if successful, false if failed or already detached
  44717. */
  44718. detach(): boolean;
  44719. /**
  44720. * Dispose this feature and all of the resources attached
  44721. */
  44722. dispose(): void;
  44723. /**
  44724. * This is used to register callbacks that will automatically be removed when detach is called.
  44725. * @param observable the observable to which the observer will be attached
  44726. * @param callback the callback to register
  44727. */
  44728. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44729. /**
  44730. * Code in this function will be executed on each xrFrame received from the browser.
  44731. * This function will not execute after the feature is detached.
  44732. * @param _xrFrame the current frame
  44733. */
  44734. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44735. }
  44736. }
  44737. declare module BABYLON {
  44738. /**
  44739. * Renders a layer on top of an existing scene
  44740. */
  44741. export class UtilityLayerRenderer implements IDisposable {
  44742. /** the original scene that will be rendered on top of */
  44743. originalScene: Scene;
  44744. private _pointerCaptures;
  44745. private _lastPointerEvents;
  44746. private static _DefaultUtilityLayer;
  44747. private static _DefaultKeepDepthUtilityLayer;
  44748. private _sharedGizmoLight;
  44749. private _renderCamera;
  44750. /**
  44751. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44752. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44753. * @returns the camera that is used when rendering the utility layer
  44754. */
  44755. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44756. /**
  44757. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44758. * @param cam the camera that should be used when rendering the utility layer
  44759. */
  44760. setRenderCamera(cam: Nullable<Camera>): void;
  44761. /**
  44762. * @hidden
  44763. * Light which used by gizmos to get light shading
  44764. */
  44765. _getSharedGizmoLight(): HemisphericLight;
  44766. /**
  44767. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44768. */
  44769. pickUtilitySceneFirst: boolean;
  44770. /**
  44771. * 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)
  44772. */
  44773. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44774. /**
  44775. * 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)
  44776. */
  44777. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44778. /**
  44779. * The scene that is rendered on top of the original scene
  44780. */
  44781. utilityLayerScene: Scene;
  44782. /**
  44783. * If the utility layer should automatically be rendered on top of existing scene
  44784. */
  44785. shouldRender: boolean;
  44786. /**
  44787. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44788. */
  44789. onlyCheckPointerDownEvents: boolean;
  44790. /**
  44791. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44792. */
  44793. processAllEvents: boolean;
  44794. /**
  44795. * Observable raised when the pointer move from the utility layer scene to the main scene
  44796. */
  44797. onPointerOutObservable: Observable<number>;
  44798. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44799. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44800. private _afterRenderObserver;
  44801. private _sceneDisposeObserver;
  44802. private _originalPointerObserver;
  44803. /**
  44804. * Instantiates a UtilityLayerRenderer
  44805. * @param originalScene the original scene that will be rendered on top of
  44806. * @param handleEvents boolean indicating if the utility layer should handle events
  44807. */
  44808. constructor(
  44809. /** the original scene that will be rendered on top of */
  44810. originalScene: Scene, handleEvents?: boolean);
  44811. private _notifyObservers;
  44812. /**
  44813. * Renders the utility layers scene on top of the original scene
  44814. */
  44815. render(): void;
  44816. /**
  44817. * Disposes of the renderer
  44818. */
  44819. dispose(): void;
  44820. private _updateCamera;
  44821. }
  44822. }
  44823. declare module BABYLON {
  44824. /**
  44825. * Options interface for the pointer selection module
  44826. */
  44827. export interface IWebXRControllerPointerSelectionOptions {
  44828. /**
  44829. * if provided, this scene will be used to render meshes.
  44830. */
  44831. customUtilityLayerScene?: Scene;
  44832. /**
  44833. * 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)
  44834. * If not disabled, the last picked point will be used to execute a pointer up event
  44835. * If disabled, pointer up event will be triggered right after the pointer down event.
  44836. * Used in screen and gaze target ray mode only
  44837. */
  44838. disablePointerUpOnTouchOut: boolean;
  44839. /**
  44840. * For gaze mode (time to select instead of press)
  44841. */
  44842. forceGazeMode: boolean;
  44843. /**
  44844. * 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
  44845. * to start a new countdown to the pointer down event.
  44846. * Defaults to 1.
  44847. */
  44848. gazeModePointerMovedFactor?: number;
  44849. /**
  44850. * Different button type to use instead of the main component
  44851. */
  44852. overrideButtonId?: string;
  44853. /**
  44854. * use this rendering group id for the meshes (optional)
  44855. */
  44856. renderingGroupId?: number;
  44857. /**
  44858. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44859. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44860. * 3000 means 3 seconds between pointing at something and selecting it
  44861. */
  44862. timeToSelect?: number;
  44863. /**
  44864. * Should meshes created here be added to a utility layer or the main scene
  44865. */
  44866. useUtilityLayer?: boolean;
  44867. /**
  44868. * the xr input to use with this pointer selection
  44869. */
  44870. xrInput: WebXRInput;
  44871. }
  44872. /**
  44873. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44874. */
  44875. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44876. private readonly _options;
  44877. private static _idCounter;
  44878. private _attachController;
  44879. private _controllers;
  44880. private _scene;
  44881. private _tmpVectorForPickCompare;
  44882. /**
  44883. * The module's name
  44884. */
  44885. static readonly Name: string;
  44886. /**
  44887. * The (Babylon) version of this module.
  44888. * This is an integer representing the implementation version.
  44889. * This number does not correspond to the WebXR specs version
  44890. */
  44891. static readonly Version: number;
  44892. /**
  44893. * Disable lighting on the laser pointer (so it will always be visible)
  44894. */
  44895. disablePointerLighting: boolean;
  44896. /**
  44897. * Disable lighting on the selection mesh (so it will always be visible)
  44898. */
  44899. disableSelectionMeshLighting: boolean;
  44900. /**
  44901. * Should the laser pointer be displayed
  44902. */
  44903. displayLaserPointer: boolean;
  44904. /**
  44905. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44906. */
  44907. displaySelectionMesh: boolean;
  44908. /**
  44909. * This color will be set to the laser pointer when selection is triggered
  44910. */
  44911. laserPointerPickedColor: Color3;
  44912. /**
  44913. * Default color of the laser pointer
  44914. */
  44915. lasterPointerDefaultColor: Color3;
  44916. /**
  44917. * default color of the selection ring
  44918. */
  44919. selectionMeshDefaultColor: Color3;
  44920. /**
  44921. * This color will be applied to the selection ring when selection is triggered
  44922. */
  44923. selectionMeshPickedColor: Color3;
  44924. /**
  44925. * Optional filter to be used for ray selection. This predicate shares behavior with
  44926. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44927. */
  44928. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44929. /**
  44930. * constructs a new background remover module
  44931. * @param _xrSessionManager the session manager for this module
  44932. * @param _options read-only options to be used in this module
  44933. */
  44934. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44935. /**
  44936. * attach this feature
  44937. * Will usually be called by the features manager
  44938. *
  44939. * @returns true if successful.
  44940. */
  44941. attach(): boolean;
  44942. /**
  44943. * detach this feature.
  44944. * Will usually be called by the features manager
  44945. *
  44946. * @returns true if successful.
  44947. */
  44948. detach(): boolean;
  44949. /**
  44950. * Will get the mesh under a specific pointer.
  44951. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44952. * @param controllerId the controllerId to check
  44953. * @returns The mesh under pointer or null if no mesh is under the pointer
  44954. */
  44955. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44956. /**
  44957. * Get the xr controller that correlates to the pointer id in the pointer event
  44958. *
  44959. * @param id the pointer id to search for
  44960. * @returns the controller that correlates to this id or null if not found
  44961. */
  44962. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44963. protected _onXRFrame(_xrFrame: XRFrame): void;
  44964. private _attachGazeMode;
  44965. private _attachScreenRayMode;
  44966. private _attachTrackedPointerRayMode;
  44967. private _convertNormalToDirectionOfRay;
  44968. private _detachController;
  44969. private _generateNewMeshPair;
  44970. private _pickingMoved;
  44971. private _updatePointerDistance;
  44972. }
  44973. }
  44974. declare module BABYLON {
  44975. /**
  44976. * Button which can be used to enter a different mode of XR
  44977. */
  44978. export class WebXREnterExitUIButton {
  44979. /** button element */
  44980. element: HTMLElement;
  44981. /** XR initialization options for the button */
  44982. sessionMode: XRSessionMode;
  44983. /** Reference space type */
  44984. referenceSpaceType: XRReferenceSpaceType;
  44985. /**
  44986. * Creates a WebXREnterExitUIButton
  44987. * @param element button element
  44988. * @param sessionMode XR initialization session mode
  44989. * @param referenceSpaceType the type of reference space to be used
  44990. */
  44991. constructor(
  44992. /** button element */
  44993. element: HTMLElement,
  44994. /** XR initialization options for the button */
  44995. sessionMode: XRSessionMode,
  44996. /** Reference space type */
  44997. referenceSpaceType: XRReferenceSpaceType);
  44998. /**
  44999. * Extendable function which can be used to update the button's visuals when the state changes
  45000. * @param activeButton the current active button in the UI
  45001. */
  45002. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45003. }
  45004. /**
  45005. * Options to create the webXR UI
  45006. */
  45007. export class WebXREnterExitUIOptions {
  45008. /**
  45009. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45010. */
  45011. customButtons?: Array<WebXREnterExitUIButton>;
  45012. /**
  45013. * A reference space type to use when creating the default button.
  45014. * Default is local-floor
  45015. */
  45016. referenceSpaceType?: XRReferenceSpaceType;
  45017. /**
  45018. * Context to enter xr with
  45019. */
  45020. renderTarget?: Nullable<WebXRRenderTarget>;
  45021. /**
  45022. * A session mode to use when creating the default button.
  45023. * Default is immersive-vr
  45024. */
  45025. sessionMode?: XRSessionMode;
  45026. }
  45027. /**
  45028. * UI to allow the user to enter/exit XR mode
  45029. */
  45030. export class WebXREnterExitUI implements IDisposable {
  45031. private scene;
  45032. /** version of the options passed to this UI */
  45033. options: WebXREnterExitUIOptions;
  45034. private _activeButton;
  45035. private _buttons;
  45036. private _overlay;
  45037. /**
  45038. * Fired every time the active button is changed.
  45039. *
  45040. * When xr is entered via a button that launches xr that button will be the callback parameter
  45041. *
  45042. * When exiting xr the callback parameter will be null)
  45043. */
  45044. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45045. /**
  45046. *
  45047. * @param scene babylon scene object to use
  45048. * @param options (read-only) version of the options passed to this UI
  45049. */
  45050. private constructor();
  45051. /**
  45052. * Creates UI to allow the user to enter/exit XR mode
  45053. * @param scene the scene to add the ui to
  45054. * @param helper the xr experience helper to enter/exit xr with
  45055. * @param options options to configure the UI
  45056. * @returns the created ui
  45057. */
  45058. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45059. /**
  45060. * Disposes of the XR UI component
  45061. */
  45062. dispose(): void;
  45063. private _updateButtons;
  45064. }
  45065. }
  45066. declare module BABYLON {
  45067. /**
  45068. * Class containing static functions to help procedurally build meshes
  45069. */
  45070. export class LinesBuilder {
  45071. /**
  45072. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45073. * * 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
  45074. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45075. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45076. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45077. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45078. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45079. * * 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
  45080. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45083. * @param name defines the name of the new line system
  45084. * @param options defines the options used to create the line system
  45085. * @param scene defines the hosting scene
  45086. * @returns a new line system mesh
  45087. */
  45088. static CreateLineSystem(name: string, options: {
  45089. lines: Vector3[][];
  45090. updatable?: boolean;
  45091. instance?: Nullable<LinesMesh>;
  45092. colors?: Nullable<Color4[][]>;
  45093. useVertexAlpha?: boolean;
  45094. }, scene: Nullable<Scene>): LinesMesh;
  45095. /**
  45096. * Creates a line mesh
  45097. * 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
  45098. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45099. * * The parameter `points` is an array successive Vector3
  45100. * * 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
  45101. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45102. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45103. * * When updating an instance, remember that only point positions can change, not the number of points
  45104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45106. * @param name defines the name of the new line system
  45107. * @param options defines the options used to create the line system
  45108. * @param scene defines the hosting scene
  45109. * @returns a new line mesh
  45110. */
  45111. static CreateLines(name: string, options: {
  45112. points: Vector3[];
  45113. updatable?: boolean;
  45114. instance?: Nullable<LinesMesh>;
  45115. colors?: Color4[];
  45116. useVertexAlpha?: boolean;
  45117. }, scene?: Nullable<Scene>): LinesMesh;
  45118. /**
  45119. * Creates a dashed line mesh
  45120. * * 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
  45121. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45122. * * The parameter `points` is an array successive Vector3
  45123. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45124. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45125. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45126. * * 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
  45127. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45128. * * When updating an instance, remember that only point positions can change, not the number of points
  45129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45130. * @param name defines the name of the mesh
  45131. * @param options defines the options used to create the mesh
  45132. * @param scene defines the hosting scene
  45133. * @returns the dashed line mesh
  45134. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45135. */
  45136. static CreateDashedLines(name: string, options: {
  45137. points: Vector3[];
  45138. dashSize?: number;
  45139. gapSize?: number;
  45140. dashNb?: number;
  45141. updatable?: boolean;
  45142. instance?: LinesMesh;
  45143. useVertexAlpha?: boolean;
  45144. }, scene?: Nullable<Scene>): LinesMesh;
  45145. }
  45146. }
  45147. declare module BABYLON {
  45148. /**
  45149. * The options container for the teleportation module
  45150. */
  45151. export interface IWebXRTeleportationOptions {
  45152. /**
  45153. * if provided, this scene will be used to render meshes.
  45154. */
  45155. customUtilityLayerScene?: Scene;
  45156. /**
  45157. * Values to configure the default target mesh
  45158. */
  45159. defaultTargetMeshOptions?: {
  45160. /**
  45161. * Fill color of the teleportation area
  45162. */
  45163. teleportationFillColor?: string;
  45164. /**
  45165. * Border color for the teleportation area
  45166. */
  45167. teleportationBorderColor?: string;
  45168. /**
  45169. * Disable the mesh's animation sequence
  45170. */
  45171. disableAnimation?: boolean;
  45172. /**
  45173. * Disable lighting on the material or the ring and arrow
  45174. */
  45175. disableLighting?: boolean;
  45176. /**
  45177. * Override the default material of the torus and arrow
  45178. */
  45179. torusArrowMaterial?: Material;
  45180. };
  45181. /**
  45182. * A list of meshes to use as floor meshes.
  45183. * Meshes can be added and removed after initializing the feature using the
  45184. * addFloorMesh and removeFloorMesh functions
  45185. * If empty, rotation will still work
  45186. */
  45187. floorMeshes?: AbstractMesh[];
  45188. /**
  45189. * use this rendering group id for the meshes (optional)
  45190. */
  45191. renderingGroupId?: number;
  45192. /**
  45193. * Should teleportation move only to snap points
  45194. */
  45195. snapPointsOnly?: boolean;
  45196. /**
  45197. * An array of points to which the teleportation will snap to.
  45198. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45199. */
  45200. snapPositions?: Vector3[];
  45201. /**
  45202. * How close should the teleportation ray be in order to snap to position.
  45203. * Default to 0.8 units (meters)
  45204. */
  45205. snapToPositionRadius?: number;
  45206. /**
  45207. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45208. * If you want to support rotation, make sure your mesh has a direction indicator.
  45209. *
  45210. * When left untouched, the default mesh will be initialized.
  45211. */
  45212. teleportationTargetMesh?: AbstractMesh;
  45213. /**
  45214. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45215. */
  45216. timeToTeleport?: number;
  45217. /**
  45218. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45219. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45220. */
  45221. useMainComponentOnly?: boolean;
  45222. /**
  45223. * Should meshes created here be added to a utility layer or the main scene
  45224. */
  45225. useUtilityLayer?: boolean;
  45226. /**
  45227. * Babylon XR Input class for controller
  45228. */
  45229. xrInput: WebXRInput;
  45230. }
  45231. /**
  45232. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45233. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45234. * the input of the attached controllers.
  45235. */
  45236. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45237. private _options;
  45238. private _controllers;
  45239. private _currentTeleportationControllerId;
  45240. private _floorMeshes;
  45241. private _quadraticBezierCurve;
  45242. private _selectionFeature;
  45243. private _snapToPositions;
  45244. private _snappedToPoint;
  45245. private _teleportationRingMaterial?;
  45246. private _tmpRay;
  45247. private _tmpVector;
  45248. /**
  45249. * The module's name
  45250. */
  45251. static readonly Name: string;
  45252. /**
  45253. * The (Babylon) version of this module.
  45254. * This is an integer representing the implementation version.
  45255. * This number does not correspond to the webxr specs version
  45256. */
  45257. static readonly Version: number;
  45258. /**
  45259. * Is movement backwards enabled
  45260. */
  45261. backwardsMovementEnabled: boolean;
  45262. /**
  45263. * Distance to travel when moving backwards
  45264. */
  45265. backwardsTeleportationDistance: number;
  45266. /**
  45267. * The distance from the user to the inspection point in the direction of the controller
  45268. * A higher number will allow the user to move further
  45269. * defaults to 5 (meters, in xr units)
  45270. */
  45271. parabolicCheckRadius: number;
  45272. /**
  45273. * Should the module support parabolic ray on top of direct ray
  45274. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45275. * Very helpful when moving between floors / different heights
  45276. */
  45277. parabolicRayEnabled: boolean;
  45278. /**
  45279. * How much rotation should be applied when rotating right and left
  45280. */
  45281. rotationAngle: number;
  45282. /**
  45283. * Is rotation enabled when moving forward?
  45284. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45285. */
  45286. rotationEnabled: boolean;
  45287. /**
  45288. * constructs a new anchor system
  45289. * @param _xrSessionManager an instance of WebXRSessionManager
  45290. * @param _options configuration object for this feature
  45291. */
  45292. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45293. /**
  45294. * Get the snapPointsOnly flag
  45295. */
  45296. get snapPointsOnly(): boolean;
  45297. /**
  45298. * Sets the snapPointsOnly flag
  45299. * @param snapToPoints should teleportation be exclusively to snap points
  45300. */
  45301. set snapPointsOnly(snapToPoints: boolean);
  45302. /**
  45303. * Add a new mesh to the floor meshes array
  45304. * @param mesh the mesh to use as floor mesh
  45305. */
  45306. addFloorMesh(mesh: AbstractMesh): void;
  45307. /**
  45308. * Add a new snap-to point to fix teleportation to this position
  45309. * @param newSnapPoint The new Snap-To point
  45310. */
  45311. addSnapPoint(newSnapPoint: Vector3): void;
  45312. attach(): boolean;
  45313. detach(): boolean;
  45314. dispose(): void;
  45315. /**
  45316. * Remove a mesh from the floor meshes array
  45317. * @param mesh the mesh to remove
  45318. */
  45319. removeFloorMesh(mesh: AbstractMesh): void;
  45320. /**
  45321. * Remove a mesh from the floor meshes array using its name
  45322. * @param name the mesh name to remove
  45323. */
  45324. removeFloorMeshByName(name: string): void;
  45325. /**
  45326. * 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
  45327. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45328. * @returns was the point found and removed or not
  45329. */
  45330. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45331. /**
  45332. * This function sets a selection feature that will be disabled when
  45333. * the forward ray is shown and will be reattached when hidden.
  45334. * This is used to remove the selection rays when moving.
  45335. * @param selectionFeature the feature to disable when forward movement is enabled
  45336. */
  45337. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45338. protected _onXRFrame(_xrFrame: XRFrame): void;
  45339. private _attachController;
  45340. private _createDefaultTargetMesh;
  45341. private _detachController;
  45342. private _findClosestSnapPointWithRadius;
  45343. private _setTargetMeshPosition;
  45344. private _setTargetMeshVisibility;
  45345. private _showParabolicPath;
  45346. private _teleportForward;
  45347. }
  45348. }
  45349. declare module BABYLON {
  45350. /**
  45351. * Options for the default xr helper
  45352. */
  45353. export class WebXRDefaultExperienceOptions {
  45354. /**
  45355. * Enable or disable default UI to enter XR
  45356. */
  45357. disableDefaultUI?: boolean;
  45358. /**
  45359. * Should teleportation not initialize. defaults to false.
  45360. */
  45361. disableTeleportation?: boolean;
  45362. /**
  45363. * Floor meshes that will be used for teleport
  45364. */
  45365. floorMeshes?: Array<AbstractMesh>;
  45366. /**
  45367. * If set to true, the first frame will not be used to reset position
  45368. * The first frame is mainly used when copying transformation from the old camera
  45369. * Mainly used in AR
  45370. */
  45371. ignoreNativeCameraTransformation?: boolean;
  45372. /**
  45373. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45374. */
  45375. inputOptions?: IWebXRInputOptions;
  45376. /**
  45377. * optional configuration for the output canvas
  45378. */
  45379. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45380. /**
  45381. * optional UI options. This can be used among other to change session mode and reference space type
  45382. */
  45383. uiOptions?: WebXREnterExitUIOptions;
  45384. /**
  45385. * When loading teleportation and pointer select, use stable versions instead of latest.
  45386. */
  45387. useStablePlugins?: boolean;
  45388. }
  45389. /**
  45390. * Default experience which provides a similar setup to the previous webVRExperience
  45391. */
  45392. export class WebXRDefaultExperience {
  45393. /**
  45394. * Base experience
  45395. */
  45396. baseExperience: WebXRExperienceHelper;
  45397. /**
  45398. * Enables ui for entering/exiting xr
  45399. */
  45400. enterExitUI: WebXREnterExitUI;
  45401. /**
  45402. * Input experience extension
  45403. */
  45404. input: WebXRInput;
  45405. /**
  45406. * Enables laser pointer and selection
  45407. */
  45408. pointerSelection: WebXRControllerPointerSelection;
  45409. /**
  45410. * Default target xr should render to
  45411. */
  45412. renderTarget: WebXRRenderTarget;
  45413. /**
  45414. * Enables teleportation
  45415. */
  45416. teleportation: WebXRMotionControllerTeleportation;
  45417. private constructor();
  45418. /**
  45419. * Creates the default xr experience
  45420. * @param scene scene
  45421. * @param options options for basic configuration
  45422. * @returns resulting WebXRDefaultExperience
  45423. */
  45424. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45425. /**
  45426. * DIsposes of the experience helper
  45427. */
  45428. dispose(): void;
  45429. }
  45430. }
  45431. declare module BABYLON {
  45432. /**
  45433. * Options to modify the vr teleportation behavior.
  45434. */
  45435. export interface VRTeleportationOptions {
  45436. /**
  45437. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45438. */
  45439. floorMeshName?: string;
  45440. /**
  45441. * A list of meshes to be used as the teleportation floor. (default: empty)
  45442. */
  45443. floorMeshes?: Mesh[];
  45444. /**
  45445. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45446. */
  45447. teleportationMode?: number;
  45448. /**
  45449. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45450. */
  45451. teleportationTime?: number;
  45452. /**
  45453. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45454. */
  45455. teleportationSpeed?: number;
  45456. /**
  45457. * The easing function used in the animation or null for Linear. (default CircleEase)
  45458. */
  45459. easingFunction?: EasingFunction;
  45460. }
  45461. /**
  45462. * Options to modify the vr experience helper's behavior.
  45463. */
  45464. export interface VRExperienceHelperOptions extends WebVROptions {
  45465. /**
  45466. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45467. */
  45468. createDeviceOrientationCamera?: boolean;
  45469. /**
  45470. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45471. */
  45472. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45473. /**
  45474. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45475. */
  45476. laserToggle?: boolean;
  45477. /**
  45478. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45479. */
  45480. floorMeshes?: Mesh[];
  45481. /**
  45482. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45483. */
  45484. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45485. /**
  45486. * Defines if WebXR should be used instead of WebVR (if available)
  45487. */
  45488. useXR?: boolean;
  45489. }
  45490. /**
  45491. * Event containing information after VR has been entered
  45492. */
  45493. export class OnAfterEnteringVRObservableEvent {
  45494. /**
  45495. * If entering vr was successful
  45496. */
  45497. success: boolean;
  45498. }
  45499. /**
  45500. * Helps to quickly add VR support to an existing scene.
  45501. * See http://doc.babylonjs.com/how_to/webvr_helper
  45502. */
  45503. export class VRExperienceHelper {
  45504. /** Options to modify the vr experience helper's behavior. */
  45505. webVROptions: VRExperienceHelperOptions;
  45506. private _scene;
  45507. private _position;
  45508. private _btnVR;
  45509. private _btnVRDisplayed;
  45510. private _webVRsupported;
  45511. private _webVRready;
  45512. private _webVRrequesting;
  45513. private _webVRpresenting;
  45514. private _hasEnteredVR;
  45515. private _fullscreenVRpresenting;
  45516. private _inputElement;
  45517. private _webVRCamera;
  45518. private _vrDeviceOrientationCamera;
  45519. private _deviceOrientationCamera;
  45520. private _existingCamera;
  45521. private _onKeyDown;
  45522. private _onVrDisplayPresentChange;
  45523. private _onVRDisplayChanged;
  45524. private _onVRRequestPresentStart;
  45525. private _onVRRequestPresentComplete;
  45526. /**
  45527. * 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)
  45528. */
  45529. enableGazeEvenWhenNoPointerLock: boolean;
  45530. /**
  45531. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45532. */
  45533. exitVROnDoubleTap: boolean;
  45534. /**
  45535. * Observable raised right before entering VR.
  45536. */
  45537. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45538. /**
  45539. * Observable raised when entering VR has completed.
  45540. */
  45541. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45542. /**
  45543. * Observable raised when exiting VR.
  45544. */
  45545. onExitingVRObservable: Observable<VRExperienceHelper>;
  45546. /**
  45547. * Observable raised when controller mesh is loaded.
  45548. */
  45549. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45550. /** Return this.onEnteringVRObservable
  45551. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45552. */
  45553. get onEnteringVR(): Observable<VRExperienceHelper>;
  45554. /** Return this.onExitingVRObservable
  45555. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45556. */
  45557. get onExitingVR(): Observable<VRExperienceHelper>;
  45558. /** Return this.onControllerMeshLoadedObservable
  45559. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45560. */
  45561. get onControllerMeshLoaded(): Observable<WebVRController>;
  45562. private _rayLength;
  45563. private _useCustomVRButton;
  45564. private _teleportationRequested;
  45565. private _teleportActive;
  45566. private _floorMeshName;
  45567. private _floorMeshesCollection;
  45568. private _teleportationMode;
  45569. private _teleportationTime;
  45570. private _teleportationSpeed;
  45571. private _teleportationEasing;
  45572. private _rotationAllowed;
  45573. private _teleportBackwardsVector;
  45574. private _teleportationTarget;
  45575. private _isDefaultTeleportationTarget;
  45576. private _postProcessMove;
  45577. private _teleportationFillColor;
  45578. private _teleportationBorderColor;
  45579. private _rotationAngle;
  45580. private _haloCenter;
  45581. private _cameraGazer;
  45582. private _padSensibilityUp;
  45583. private _padSensibilityDown;
  45584. private _leftController;
  45585. private _rightController;
  45586. private _gazeColor;
  45587. private _laserColor;
  45588. private _pickedLaserColor;
  45589. private _pickedGazeColor;
  45590. /**
  45591. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45592. */
  45593. onNewMeshSelected: Observable<AbstractMesh>;
  45594. /**
  45595. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45596. * This observable will provide the mesh and the controller used to select the mesh
  45597. */
  45598. onMeshSelectedWithController: Observable<{
  45599. mesh: AbstractMesh;
  45600. controller: WebVRController;
  45601. }>;
  45602. /**
  45603. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45604. */
  45605. onNewMeshPicked: Observable<PickingInfo>;
  45606. private _circleEase;
  45607. /**
  45608. * Observable raised before camera teleportation
  45609. */
  45610. onBeforeCameraTeleport: Observable<Vector3>;
  45611. /**
  45612. * Observable raised after camera teleportation
  45613. */
  45614. onAfterCameraTeleport: Observable<Vector3>;
  45615. /**
  45616. * Observable raised when current selected mesh gets unselected
  45617. */
  45618. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45619. private _raySelectionPredicate;
  45620. /**
  45621. * To be optionaly changed by user to define custom ray selection
  45622. */
  45623. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45624. /**
  45625. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45626. */
  45627. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45628. /**
  45629. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45630. */
  45631. teleportationEnabled: boolean;
  45632. private _defaultHeight;
  45633. private _teleportationInitialized;
  45634. private _interactionsEnabled;
  45635. private _interactionsRequested;
  45636. private _displayGaze;
  45637. private _displayLaserPointer;
  45638. /**
  45639. * The mesh used to display where the user is going to teleport.
  45640. */
  45641. get teleportationTarget(): Mesh;
  45642. /**
  45643. * Sets the mesh to be used to display where the user is going to teleport.
  45644. */
  45645. set teleportationTarget(value: Mesh);
  45646. /**
  45647. * 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
  45648. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45649. * See http://doc.babylonjs.com/resources/baking_transformations
  45650. */
  45651. get gazeTrackerMesh(): Mesh;
  45652. set gazeTrackerMesh(value: Mesh);
  45653. /**
  45654. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45655. */
  45656. updateGazeTrackerScale: boolean;
  45657. /**
  45658. * If the gaze trackers color should be updated when selecting meshes
  45659. */
  45660. updateGazeTrackerColor: boolean;
  45661. /**
  45662. * If the controller laser color should be updated when selecting meshes
  45663. */
  45664. updateControllerLaserColor: boolean;
  45665. /**
  45666. * The gaze tracking mesh corresponding to the left controller
  45667. */
  45668. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45669. /**
  45670. * The gaze tracking mesh corresponding to the right controller
  45671. */
  45672. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45673. /**
  45674. * If the ray of the gaze should be displayed.
  45675. */
  45676. get displayGaze(): boolean;
  45677. /**
  45678. * Sets if the ray of the gaze should be displayed.
  45679. */
  45680. set displayGaze(value: boolean);
  45681. /**
  45682. * If the ray of the LaserPointer should be displayed.
  45683. */
  45684. get displayLaserPointer(): boolean;
  45685. /**
  45686. * Sets if the ray of the LaserPointer should be displayed.
  45687. */
  45688. set displayLaserPointer(value: boolean);
  45689. /**
  45690. * The deviceOrientationCamera used as the camera when not in VR.
  45691. */
  45692. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45693. /**
  45694. * Based on the current WebVR support, returns the current VR camera used.
  45695. */
  45696. get currentVRCamera(): Nullable<Camera>;
  45697. /**
  45698. * The webVRCamera which is used when in VR.
  45699. */
  45700. get webVRCamera(): WebVRFreeCamera;
  45701. /**
  45702. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45703. */
  45704. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45705. /**
  45706. * The html button that is used to trigger entering into VR.
  45707. */
  45708. get vrButton(): Nullable<HTMLButtonElement>;
  45709. private get _teleportationRequestInitiated();
  45710. /**
  45711. * Defines whether or not Pointer lock should be requested when switching to
  45712. * full screen.
  45713. */
  45714. requestPointerLockOnFullScreen: boolean;
  45715. /**
  45716. * If asking to force XR, this will be populated with the default xr experience
  45717. */
  45718. xr: WebXRDefaultExperience;
  45719. /**
  45720. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45721. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45722. */
  45723. xrTestDone: boolean;
  45724. /**
  45725. * Instantiates a VRExperienceHelper.
  45726. * Helps to quickly add VR support to an existing scene.
  45727. * @param scene The scene the VRExperienceHelper belongs to.
  45728. * @param webVROptions Options to modify the vr experience helper's behavior.
  45729. */
  45730. constructor(scene: Scene,
  45731. /** Options to modify the vr experience helper's behavior. */
  45732. webVROptions?: VRExperienceHelperOptions);
  45733. private completeVRInit;
  45734. private _onDefaultMeshLoaded;
  45735. private _onResize;
  45736. private _onFullscreenChange;
  45737. /**
  45738. * Gets a value indicating if we are currently in VR mode.
  45739. */
  45740. get isInVRMode(): boolean;
  45741. private onVrDisplayPresentChange;
  45742. private onVRDisplayChanged;
  45743. private moveButtonToBottomRight;
  45744. private displayVRButton;
  45745. private updateButtonVisibility;
  45746. private _cachedAngularSensibility;
  45747. /**
  45748. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45749. * Otherwise, will use the fullscreen API.
  45750. */
  45751. enterVR(): void;
  45752. /**
  45753. * Attempt to exit VR, or fullscreen.
  45754. */
  45755. exitVR(): void;
  45756. /**
  45757. * The position of the vr experience helper.
  45758. */
  45759. get position(): Vector3;
  45760. /**
  45761. * Sets the position of the vr experience helper.
  45762. */
  45763. set position(value: Vector3);
  45764. /**
  45765. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45766. */
  45767. enableInteractions(): void;
  45768. private get _noControllerIsActive();
  45769. private beforeRender;
  45770. private _isTeleportationFloor;
  45771. /**
  45772. * Adds a floor mesh to be used for teleportation.
  45773. * @param floorMesh the mesh to be used for teleportation.
  45774. */
  45775. addFloorMesh(floorMesh: Mesh): void;
  45776. /**
  45777. * Removes a floor mesh from being used for teleportation.
  45778. * @param floorMesh the mesh to be removed.
  45779. */
  45780. removeFloorMesh(floorMesh: Mesh): void;
  45781. /**
  45782. * Enables interactions and teleportation using the VR controllers and gaze.
  45783. * @param vrTeleportationOptions options to modify teleportation behavior.
  45784. */
  45785. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45786. private _onNewGamepadConnected;
  45787. private _tryEnableInteractionOnController;
  45788. private _onNewGamepadDisconnected;
  45789. private _enableInteractionOnController;
  45790. private _checkTeleportWithRay;
  45791. private _checkRotate;
  45792. private _checkTeleportBackwards;
  45793. private _enableTeleportationOnController;
  45794. private _createTeleportationCircles;
  45795. private _displayTeleportationTarget;
  45796. private _hideTeleportationTarget;
  45797. private _rotateCamera;
  45798. private _moveTeleportationSelectorTo;
  45799. private _workingVector;
  45800. private _workingQuaternion;
  45801. private _workingMatrix;
  45802. /**
  45803. * Time Constant Teleportation Mode
  45804. */
  45805. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45806. /**
  45807. * Speed Constant Teleportation Mode
  45808. */
  45809. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45810. /**
  45811. * Teleports the users feet to the desired location
  45812. * @param location The location where the user's feet should be placed
  45813. */
  45814. teleportCamera(location: Vector3): void;
  45815. private _convertNormalToDirectionOfRay;
  45816. private _castRayAndSelectObject;
  45817. private _notifySelectedMeshUnselected;
  45818. /**
  45819. * Permanently set new colors for the laser pointer
  45820. * @param color the new laser color
  45821. * @param pickedColor the new laser color when picked mesh detected
  45822. */
  45823. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45824. /**
  45825. * Set lighting enabled / disabled on the laser pointer of both controllers
  45826. * @param enabled should the lighting be enabled on the laser pointer
  45827. */
  45828. setLaserLightingState(enabled?: boolean): void;
  45829. /**
  45830. * Permanently set new colors for the gaze pointer
  45831. * @param color the new gaze color
  45832. * @param pickedColor the new gaze color when picked mesh detected
  45833. */
  45834. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45835. /**
  45836. * Sets the color of the laser ray from the vr controllers.
  45837. * @param color new color for the ray.
  45838. */
  45839. changeLaserColor(color: Color3): void;
  45840. /**
  45841. * Sets the color of the ray from the vr headsets gaze.
  45842. * @param color new color for the ray.
  45843. */
  45844. changeGazeColor(color: Color3): void;
  45845. /**
  45846. * Exits VR and disposes of the vr experience helper
  45847. */
  45848. dispose(): void;
  45849. /**
  45850. * Gets the name of the VRExperienceHelper class
  45851. * @returns "VRExperienceHelper"
  45852. */
  45853. getClassName(): string;
  45854. }
  45855. }
  45856. declare module BABYLON {
  45857. /**
  45858. * Contains an array of blocks representing the octree
  45859. */
  45860. export interface IOctreeContainer<T> {
  45861. /**
  45862. * Blocks within the octree
  45863. */
  45864. blocks: Array<OctreeBlock<T>>;
  45865. }
  45866. /**
  45867. * Class used to store a cell in an octree
  45868. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45869. */
  45870. export class OctreeBlock<T> {
  45871. /**
  45872. * Gets the content of the current block
  45873. */
  45874. entries: T[];
  45875. /**
  45876. * Gets the list of block children
  45877. */
  45878. blocks: Array<OctreeBlock<T>>;
  45879. private _depth;
  45880. private _maxDepth;
  45881. private _capacity;
  45882. private _minPoint;
  45883. private _maxPoint;
  45884. private _boundingVectors;
  45885. private _creationFunc;
  45886. /**
  45887. * Creates a new block
  45888. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45889. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45890. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45891. * @param depth defines the current depth of this block in the octree
  45892. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45893. * @param creationFunc defines a callback to call when an element is added to the block
  45894. */
  45895. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45896. /**
  45897. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45898. */
  45899. get capacity(): number;
  45900. /**
  45901. * Gets the minimum vector (in world space) of the block's bounding box
  45902. */
  45903. get minPoint(): Vector3;
  45904. /**
  45905. * Gets the maximum vector (in world space) of the block's bounding box
  45906. */
  45907. get maxPoint(): Vector3;
  45908. /**
  45909. * Add a new element to this block
  45910. * @param entry defines the element to add
  45911. */
  45912. addEntry(entry: T): void;
  45913. /**
  45914. * Remove an element from this block
  45915. * @param entry defines the element to remove
  45916. */
  45917. removeEntry(entry: T): void;
  45918. /**
  45919. * Add an array of elements to this block
  45920. * @param entries defines the array of elements to add
  45921. */
  45922. addEntries(entries: T[]): void;
  45923. /**
  45924. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45925. * @param frustumPlanes defines the frustum planes to test
  45926. * @param selection defines the array to store current content if selection is positive
  45927. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45928. */
  45929. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45930. /**
  45931. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45932. * @param sphereCenter defines the bounding sphere center
  45933. * @param sphereRadius defines the bounding sphere radius
  45934. * @param selection defines the array to store current content if selection is positive
  45935. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45936. */
  45937. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45938. /**
  45939. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45940. * @param ray defines the ray to test with
  45941. * @param selection defines the array to store current content if selection is positive
  45942. */
  45943. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45944. /**
  45945. * Subdivide the content into child blocks (this block will then be empty)
  45946. */
  45947. createInnerBlocks(): void;
  45948. /**
  45949. * @hidden
  45950. */
  45951. 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;
  45952. }
  45953. }
  45954. declare module BABYLON {
  45955. /**
  45956. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45957. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45958. */
  45959. export class Octree<T> {
  45960. /** 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.) */
  45961. maxDepth: number;
  45962. /**
  45963. * Blocks within the octree containing objects
  45964. */
  45965. blocks: Array<OctreeBlock<T>>;
  45966. /**
  45967. * Content stored in the octree
  45968. */
  45969. dynamicContent: T[];
  45970. private _maxBlockCapacity;
  45971. private _selectionContent;
  45972. private _creationFunc;
  45973. /**
  45974. * Creates a octree
  45975. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45976. * @param creationFunc function to be used to instatiate the octree
  45977. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45978. * @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.)
  45979. */
  45980. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45981. /** 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.) */
  45982. maxDepth?: number);
  45983. /**
  45984. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45985. * @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);
  45986. * @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);
  45987. * @param entries meshes to be added to the octree blocks
  45988. */
  45989. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45990. /**
  45991. * Adds a mesh to the octree
  45992. * @param entry Mesh to add to the octree
  45993. */
  45994. addMesh(entry: T): void;
  45995. /**
  45996. * Remove an element from the octree
  45997. * @param entry defines the element to remove
  45998. */
  45999. removeMesh(entry: T): void;
  46000. /**
  46001. * Selects an array of meshes within the frustum
  46002. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46003. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46004. * @returns array of meshes within the frustum
  46005. */
  46006. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46007. /**
  46008. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46009. * @param sphereCenter defines the bounding sphere center
  46010. * @param sphereRadius defines the bounding sphere radius
  46011. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46012. * @returns an array of objects that intersect the sphere
  46013. */
  46014. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46015. /**
  46016. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46017. * @param ray defines the ray to test with
  46018. * @returns array of intersected objects
  46019. */
  46020. intersectsRay(ray: Ray): SmartArray<T>;
  46021. /**
  46022. * Adds a mesh into the octree block if it intersects the block
  46023. */
  46024. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46025. /**
  46026. * Adds a submesh into the octree block if it intersects the block
  46027. */
  46028. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46029. }
  46030. }
  46031. declare module BABYLON {
  46032. interface Scene {
  46033. /**
  46034. * @hidden
  46035. * Backing Filed
  46036. */
  46037. _selectionOctree: Octree<AbstractMesh>;
  46038. /**
  46039. * Gets the octree used to boost mesh selection (picking)
  46040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46041. */
  46042. selectionOctree: Octree<AbstractMesh>;
  46043. /**
  46044. * Creates or updates the octree used to boost selection (picking)
  46045. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46046. * @param maxCapacity defines the maximum capacity per leaf
  46047. * @param maxDepth defines the maximum depth of the octree
  46048. * @returns an octree of AbstractMesh
  46049. */
  46050. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46051. }
  46052. interface AbstractMesh {
  46053. /**
  46054. * @hidden
  46055. * Backing Field
  46056. */
  46057. _submeshesOctree: Octree<SubMesh>;
  46058. /**
  46059. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46060. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46061. * @param maxCapacity defines the maximum size of each block (64 by default)
  46062. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46063. * @returns the new octree
  46064. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46066. */
  46067. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46068. }
  46069. /**
  46070. * Defines the octree scene component responsible to manage any octrees
  46071. * in a given scene.
  46072. */
  46073. export class OctreeSceneComponent {
  46074. /**
  46075. * The component name help to identify the component in the list of scene components.
  46076. */
  46077. readonly name: string;
  46078. /**
  46079. * The scene the component belongs to.
  46080. */
  46081. scene: Scene;
  46082. /**
  46083. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46084. */
  46085. readonly checksIsEnabled: boolean;
  46086. /**
  46087. * Creates a new instance of the component for the given scene
  46088. * @param scene Defines the scene to register the component in
  46089. */
  46090. constructor(scene: Scene);
  46091. /**
  46092. * Registers the component in a given scene
  46093. */
  46094. register(): void;
  46095. /**
  46096. * Return the list of active meshes
  46097. * @returns the list of active meshes
  46098. */
  46099. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46100. /**
  46101. * Return the list of active sub meshes
  46102. * @param mesh The mesh to get the candidates sub meshes from
  46103. * @returns the list of active sub meshes
  46104. */
  46105. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46106. private _tempRay;
  46107. /**
  46108. * Return the list of sub meshes intersecting with a given local ray
  46109. * @param mesh defines the mesh to find the submesh for
  46110. * @param localRay defines the ray in local space
  46111. * @returns the list of intersecting sub meshes
  46112. */
  46113. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46114. /**
  46115. * Return the list of sub meshes colliding with a collider
  46116. * @param mesh defines the mesh to find the submesh for
  46117. * @param collider defines the collider to evaluate the collision against
  46118. * @returns the list of colliding sub meshes
  46119. */
  46120. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46121. /**
  46122. * Rebuilds the elements related to this component in case of
  46123. * context lost for instance.
  46124. */
  46125. rebuild(): void;
  46126. /**
  46127. * Disposes the component and the associated ressources.
  46128. */
  46129. dispose(): void;
  46130. }
  46131. }
  46132. declare module BABYLON {
  46133. /**
  46134. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46135. */
  46136. export class Gizmo implements IDisposable {
  46137. /** The utility layer the gizmo will be added to */
  46138. gizmoLayer: UtilityLayerRenderer;
  46139. /**
  46140. * The root mesh of the gizmo
  46141. */
  46142. _rootMesh: Mesh;
  46143. private _attachedMesh;
  46144. /**
  46145. * Ratio for the scale of the gizmo (Default: 1)
  46146. */
  46147. scaleRatio: number;
  46148. /**
  46149. * If a custom mesh has been set (Default: false)
  46150. */
  46151. protected _customMeshSet: boolean;
  46152. /**
  46153. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46154. * * When set, interactions will be enabled
  46155. */
  46156. get attachedMesh(): Nullable<AbstractMesh>;
  46157. set attachedMesh(value: Nullable<AbstractMesh>);
  46158. /**
  46159. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46160. * @param mesh The mesh to replace the default mesh of the gizmo
  46161. */
  46162. setCustomMesh(mesh: Mesh): void;
  46163. /**
  46164. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46165. */
  46166. updateGizmoRotationToMatchAttachedMesh: boolean;
  46167. /**
  46168. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46169. */
  46170. updateGizmoPositionToMatchAttachedMesh: boolean;
  46171. /**
  46172. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46173. */
  46174. updateScale: boolean;
  46175. protected _interactionsEnabled: boolean;
  46176. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46177. private _beforeRenderObserver;
  46178. private _tempVector;
  46179. /**
  46180. * Creates a gizmo
  46181. * @param gizmoLayer The utility layer the gizmo will be added to
  46182. */
  46183. constructor(
  46184. /** The utility layer the gizmo will be added to */
  46185. gizmoLayer?: UtilityLayerRenderer);
  46186. /**
  46187. * Updates the gizmo to match the attached mesh's position/rotation
  46188. */
  46189. protected _update(): void;
  46190. /**
  46191. * Disposes of the gizmo
  46192. */
  46193. dispose(): void;
  46194. }
  46195. }
  46196. declare module BABYLON {
  46197. /**
  46198. * Single plane drag gizmo
  46199. */
  46200. export class PlaneDragGizmo extends Gizmo {
  46201. /**
  46202. * Drag behavior responsible for the gizmos dragging interactions
  46203. */
  46204. dragBehavior: PointerDragBehavior;
  46205. private _pointerObserver;
  46206. /**
  46207. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46208. */
  46209. snapDistance: number;
  46210. /**
  46211. * Event that fires each time the gizmo snaps to a new location.
  46212. * * snapDistance is the the change in distance
  46213. */
  46214. onSnapObservable: Observable<{
  46215. snapDistance: number;
  46216. }>;
  46217. private _plane;
  46218. private _coloredMaterial;
  46219. private _hoverMaterial;
  46220. private _isEnabled;
  46221. private _parent;
  46222. /** @hidden */
  46223. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46224. /** @hidden */
  46225. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46226. /**
  46227. * Creates a PlaneDragGizmo
  46228. * @param gizmoLayer The utility layer the gizmo will be added to
  46229. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46230. * @param color The color of the gizmo
  46231. */
  46232. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46233. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46234. /**
  46235. * If the gizmo is enabled
  46236. */
  46237. set isEnabled(value: boolean);
  46238. get isEnabled(): boolean;
  46239. /**
  46240. * Disposes of the gizmo
  46241. */
  46242. dispose(): void;
  46243. }
  46244. }
  46245. declare module BABYLON {
  46246. /**
  46247. * Gizmo that enables dragging a mesh along 3 axis
  46248. */
  46249. export class PositionGizmo extends Gizmo {
  46250. /**
  46251. * Internal gizmo used for interactions on the x axis
  46252. */
  46253. xGizmo: AxisDragGizmo;
  46254. /**
  46255. * Internal gizmo used for interactions on the y axis
  46256. */
  46257. yGizmo: AxisDragGizmo;
  46258. /**
  46259. * Internal gizmo used for interactions on the z axis
  46260. */
  46261. zGizmo: AxisDragGizmo;
  46262. /**
  46263. * Internal gizmo used for interactions on the yz plane
  46264. */
  46265. xPlaneGizmo: PlaneDragGizmo;
  46266. /**
  46267. * Internal gizmo used for interactions on the xz plane
  46268. */
  46269. yPlaneGizmo: PlaneDragGizmo;
  46270. /**
  46271. * Internal gizmo used for interactions on the xy plane
  46272. */
  46273. zPlaneGizmo: PlaneDragGizmo;
  46274. /**
  46275. * private variables
  46276. */
  46277. private _meshAttached;
  46278. private _updateGizmoRotationToMatchAttachedMesh;
  46279. private _snapDistance;
  46280. private _scaleRatio;
  46281. /** Fires an event when any of it's sub gizmos are dragged */
  46282. onDragStartObservable: Observable<unknown>;
  46283. /** Fires an event when any of it's sub gizmos are released from dragging */
  46284. onDragEndObservable: Observable<unknown>;
  46285. /**
  46286. * If set to true, planar drag is enabled
  46287. */
  46288. private _planarGizmoEnabled;
  46289. get attachedMesh(): Nullable<AbstractMesh>;
  46290. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46291. /**
  46292. * Creates a PositionGizmo
  46293. * @param gizmoLayer The utility layer the gizmo will be added to
  46294. */
  46295. constructor(gizmoLayer?: UtilityLayerRenderer);
  46296. /**
  46297. * If the planar drag gizmo is enabled
  46298. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46299. */
  46300. set planarGizmoEnabled(value: boolean);
  46301. get planarGizmoEnabled(): boolean;
  46302. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46303. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46304. /**
  46305. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46306. */
  46307. set snapDistance(value: number);
  46308. get snapDistance(): number;
  46309. /**
  46310. * Ratio for the scale of the gizmo (Default: 1)
  46311. */
  46312. set scaleRatio(value: number);
  46313. get scaleRatio(): number;
  46314. /**
  46315. * Disposes of the gizmo
  46316. */
  46317. dispose(): void;
  46318. /**
  46319. * CustomMeshes are not supported by this gizmo
  46320. * @param mesh The mesh to replace the default mesh of the gizmo
  46321. */
  46322. setCustomMesh(mesh: Mesh): void;
  46323. }
  46324. }
  46325. declare module BABYLON {
  46326. /**
  46327. * Single axis drag gizmo
  46328. */
  46329. export class AxisDragGizmo extends Gizmo {
  46330. /**
  46331. * Drag behavior responsible for the gizmos dragging interactions
  46332. */
  46333. dragBehavior: PointerDragBehavior;
  46334. private _pointerObserver;
  46335. /**
  46336. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46337. */
  46338. snapDistance: number;
  46339. /**
  46340. * Event that fires each time the gizmo snaps to a new location.
  46341. * * snapDistance is the the change in distance
  46342. */
  46343. onSnapObservable: Observable<{
  46344. snapDistance: number;
  46345. }>;
  46346. private _isEnabled;
  46347. private _parent;
  46348. private _arrow;
  46349. private _coloredMaterial;
  46350. private _hoverMaterial;
  46351. /** @hidden */
  46352. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46353. /** @hidden */
  46354. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46355. /**
  46356. * Creates an AxisDragGizmo
  46357. * @param gizmoLayer The utility layer the gizmo will be added to
  46358. * @param dragAxis The axis which the gizmo will be able to drag on
  46359. * @param color The color of the gizmo
  46360. */
  46361. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46362. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46363. /**
  46364. * If the gizmo is enabled
  46365. */
  46366. set isEnabled(value: boolean);
  46367. get isEnabled(): boolean;
  46368. /**
  46369. * Disposes of the gizmo
  46370. */
  46371. dispose(): void;
  46372. }
  46373. }
  46374. declare module BABYLON.Debug {
  46375. /**
  46376. * The Axes viewer will show 3 axes in a specific point in space
  46377. */
  46378. export class AxesViewer {
  46379. private _xAxis;
  46380. private _yAxis;
  46381. private _zAxis;
  46382. private _scaleLinesFactor;
  46383. private _instanced;
  46384. /**
  46385. * Gets the hosting scene
  46386. */
  46387. scene: Scene;
  46388. /**
  46389. * Gets or sets a number used to scale line length
  46390. */
  46391. scaleLines: number;
  46392. /** Gets the node hierarchy used to render x-axis */
  46393. get xAxis(): TransformNode;
  46394. /** Gets the node hierarchy used to render y-axis */
  46395. get yAxis(): TransformNode;
  46396. /** Gets the node hierarchy used to render z-axis */
  46397. get zAxis(): TransformNode;
  46398. /**
  46399. * Creates a new AxesViewer
  46400. * @param scene defines the hosting scene
  46401. * @param scaleLines defines a number used to scale line length (1 by default)
  46402. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46403. * @param xAxis defines the node hierarchy used to render the x-axis
  46404. * @param yAxis defines the node hierarchy used to render the y-axis
  46405. * @param zAxis defines the node hierarchy used to render the z-axis
  46406. */
  46407. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46408. /**
  46409. * Force the viewer to update
  46410. * @param position defines the position of the viewer
  46411. * @param xaxis defines the x axis of the viewer
  46412. * @param yaxis defines the y axis of the viewer
  46413. * @param zaxis defines the z axis of the viewer
  46414. */
  46415. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46416. /**
  46417. * Creates an instance of this axes viewer.
  46418. * @returns a new axes viewer with instanced meshes
  46419. */
  46420. createInstance(): AxesViewer;
  46421. /** Releases resources */
  46422. dispose(): void;
  46423. private static _SetRenderingGroupId;
  46424. }
  46425. }
  46426. declare module BABYLON.Debug {
  46427. /**
  46428. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46429. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46430. */
  46431. export class BoneAxesViewer extends AxesViewer {
  46432. /**
  46433. * Gets or sets the target mesh where to display the axes viewer
  46434. */
  46435. mesh: Nullable<Mesh>;
  46436. /**
  46437. * Gets or sets the target bone where to display the axes viewer
  46438. */
  46439. bone: Nullable<Bone>;
  46440. /** Gets current position */
  46441. pos: Vector3;
  46442. /** Gets direction of X axis */
  46443. xaxis: Vector3;
  46444. /** Gets direction of Y axis */
  46445. yaxis: Vector3;
  46446. /** Gets direction of Z axis */
  46447. zaxis: Vector3;
  46448. /**
  46449. * Creates a new BoneAxesViewer
  46450. * @param scene defines the hosting scene
  46451. * @param bone defines the target bone
  46452. * @param mesh defines the target mesh
  46453. * @param scaleLines defines a scaling factor for line length (1 by default)
  46454. */
  46455. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46456. /**
  46457. * Force the viewer to update
  46458. */
  46459. update(): void;
  46460. /** Releases resources */
  46461. dispose(): void;
  46462. }
  46463. }
  46464. declare module BABYLON {
  46465. /**
  46466. * Interface used to define scene explorer extensibility option
  46467. */
  46468. export interface IExplorerExtensibilityOption {
  46469. /**
  46470. * Define the option label
  46471. */
  46472. label: string;
  46473. /**
  46474. * Defines the action to execute on click
  46475. */
  46476. action: (entity: any) => void;
  46477. }
  46478. /**
  46479. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46480. */
  46481. export interface IExplorerExtensibilityGroup {
  46482. /**
  46483. * Defines a predicate to test if a given type mut be extended
  46484. */
  46485. predicate: (entity: any) => boolean;
  46486. /**
  46487. * Gets the list of options added to a type
  46488. */
  46489. entries: IExplorerExtensibilityOption[];
  46490. }
  46491. /**
  46492. * Interface used to define the options to use to create the Inspector
  46493. */
  46494. export interface IInspectorOptions {
  46495. /**
  46496. * Display in overlay mode (default: false)
  46497. */
  46498. overlay?: boolean;
  46499. /**
  46500. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46501. */
  46502. globalRoot?: HTMLElement;
  46503. /**
  46504. * Display the Scene explorer
  46505. */
  46506. showExplorer?: boolean;
  46507. /**
  46508. * Display the property inspector
  46509. */
  46510. showInspector?: boolean;
  46511. /**
  46512. * Display in embed mode (both panes on the right)
  46513. */
  46514. embedMode?: boolean;
  46515. /**
  46516. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46517. */
  46518. handleResize?: boolean;
  46519. /**
  46520. * Allow the panes to popup (default: true)
  46521. */
  46522. enablePopup?: boolean;
  46523. /**
  46524. * Allow the panes to be closed by users (default: true)
  46525. */
  46526. enableClose?: boolean;
  46527. /**
  46528. * Optional list of extensibility entries
  46529. */
  46530. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46531. /**
  46532. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46533. */
  46534. inspectorURL?: string;
  46535. /**
  46536. * Optional initial tab (default to DebugLayerTab.Properties)
  46537. */
  46538. initialTab?: DebugLayerTab;
  46539. }
  46540. interface Scene {
  46541. /**
  46542. * @hidden
  46543. * Backing field
  46544. */
  46545. _debugLayer: DebugLayer;
  46546. /**
  46547. * Gets the debug layer (aka Inspector) associated with the scene
  46548. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46549. */
  46550. debugLayer: DebugLayer;
  46551. }
  46552. /**
  46553. * Enum of inspector action tab
  46554. */
  46555. export enum DebugLayerTab {
  46556. /**
  46557. * Properties tag (default)
  46558. */
  46559. Properties = 0,
  46560. /**
  46561. * Debug tab
  46562. */
  46563. Debug = 1,
  46564. /**
  46565. * Statistics tab
  46566. */
  46567. Statistics = 2,
  46568. /**
  46569. * Tools tab
  46570. */
  46571. Tools = 3,
  46572. /**
  46573. * Settings tab
  46574. */
  46575. Settings = 4
  46576. }
  46577. /**
  46578. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46579. * what is happening in your scene
  46580. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46581. */
  46582. export class DebugLayer {
  46583. /**
  46584. * Define the url to get the inspector script from.
  46585. * By default it uses the babylonjs CDN.
  46586. * @ignoreNaming
  46587. */
  46588. static InspectorURL: string;
  46589. private _scene;
  46590. private BJSINSPECTOR;
  46591. private _onPropertyChangedObservable?;
  46592. /**
  46593. * Observable triggered when a property is changed through the inspector.
  46594. */
  46595. get onPropertyChangedObservable(): any;
  46596. /**
  46597. * Instantiates a new debug layer.
  46598. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46599. * what is happening in your scene
  46600. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46601. * @param scene Defines the scene to inspect
  46602. */
  46603. constructor(scene: Scene);
  46604. /** Creates the inspector window. */
  46605. private _createInspector;
  46606. /**
  46607. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46608. * @param entity defines the entity to select
  46609. * @param lineContainerTitle defines the specific block to highlight
  46610. */
  46611. select(entity: any, lineContainerTitle?: string): void;
  46612. /** Get the inspector from bundle or global */
  46613. private _getGlobalInspector;
  46614. /**
  46615. * Get if the inspector is visible or not.
  46616. * @returns true if visible otherwise, false
  46617. */
  46618. isVisible(): boolean;
  46619. /**
  46620. * Hide the inspector and close its window.
  46621. */
  46622. hide(): void;
  46623. /**
  46624. * Launch the debugLayer.
  46625. * @param config Define the configuration of the inspector
  46626. * @return a promise fulfilled when the debug layer is visible
  46627. */
  46628. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46629. }
  46630. }
  46631. declare module BABYLON {
  46632. /**
  46633. * Class containing static functions to help procedurally build meshes
  46634. */
  46635. export class BoxBuilder {
  46636. /**
  46637. * Creates a box mesh
  46638. * * The parameter `size` sets the size (float) of each box side (default 1)
  46639. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46640. * * 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)
  46641. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46643. * * 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
  46644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46645. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46646. * @param name defines the name of the mesh
  46647. * @param options defines the options used to create the mesh
  46648. * @param scene defines the hosting scene
  46649. * @returns the box mesh
  46650. */
  46651. static CreateBox(name: string, options: {
  46652. size?: number;
  46653. width?: number;
  46654. height?: number;
  46655. depth?: number;
  46656. faceUV?: Vector4[];
  46657. faceColors?: Color4[];
  46658. sideOrientation?: number;
  46659. frontUVs?: Vector4;
  46660. backUVs?: Vector4;
  46661. wrap?: boolean;
  46662. topBaseAt?: number;
  46663. bottomBaseAt?: number;
  46664. updatable?: boolean;
  46665. }, scene?: Nullable<Scene>): Mesh;
  46666. }
  46667. }
  46668. declare module BABYLON.Debug {
  46669. /**
  46670. * Used to show the physics impostor around the specific mesh
  46671. */
  46672. export class PhysicsViewer {
  46673. /** @hidden */
  46674. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46675. /** @hidden */
  46676. protected _meshes: Array<Nullable<AbstractMesh>>;
  46677. /** @hidden */
  46678. protected _scene: Nullable<Scene>;
  46679. /** @hidden */
  46680. protected _numMeshes: number;
  46681. /** @hidden */
  46682. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46683. private _renderFunction;
  46684. private _utilityLayer;
  46685. private _debugBoxMesh;
  46686. private _debugSphereMesh;
  46687. private _debugCylinderMesh;
  46688. private _debugMaterial;
  46689. private _debugMeshMeshes;
  46690. /**
  46691. * Creates a new PhysicsViewer
  46692. * @param scene defines the hosting scene
  46693. */
  46694. constructor(scene: Scene);
  46695. /** @hidden */
  46696. protected _updateDebugMeshes(): void;
  46697. /**
  46698. * Renders a specified physic impostor
  46699. * @param impostor defines the impostor to render
  46700. * @param targetMesh defines the mesh represented by the impostor
  46701. * @returns the new debug mesh used to render the impostor
  46702. */
  46703. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46704. /**
  46705. * Hides a specified physic impostor
  46706. * @param impostor defines the impostor to hide
  46707. */
  46708. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46709. private _getDebugMaterial;
  46710. private _getDebugBoxMesh;
  46711. private _getDebugSphereMesh;
  46712. private _getDebugCylinderMesh;
  46713. private _getDebugMeshMesh;
  46714. private _getDebugMesh;
  46715. /** Releases all resources */
  46716. dispose(): void;
  46717. }
  46718. }
  46719. declare module BABYLON {
  46720. /**
  46721. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46722. * in order to better appreciate the issue one might have.
  46723. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46724. */
  46725. export class RayHelper {
  46726. /**
  46727. * Defines the ray we are currently tryin to visualize.
  46728. */
  46729. ray: Nullable<Ray>;
  46730. private _renderPoints;
  46731. private _renderLine;
  46732. private _renderFunction;
  46733. private _scene;
  46734. private _updateToMeshFunction;
  46735. private _attachedToMesh;
  46736. private _meshSpaceDirection;
  46737. private _meshSpaceOrigin;
  46738. /**
  46739. * Helper function to create a colored helper in a scene in one line.
  46740. * @param ray Defines the ray we are currently tryin to visualize
  46741. * @param scene Defines the scene the ray is used in
  46742. * @param color Defines the color we want to see the ray in
  46743. * @returns The newly created ray helper.
  46744. */
  46745. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46746. /**
  46747. * Instantiate a new ray helper.
  46748. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46749. * in order to better appreciate the issue one might have.
  46750. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46751. * @param ray Defines the ray we are currently tryin to visualize
  46752. */
  46753. constructor(ray: Ray);
  46754. /**
  46755. * Shows the ray we are willing to debug.
  46756. * @param scene Defines the scene the ray needs to be rendered in
  46757. * @param color Defines the color the ray needs to be rendered in
  46758. */
  46759. show(scene: Scene, color?: Color3): void;
  46760. /**
  46761. * Hides the ray we are debugging.
  46762. */
  46763. hide(): void;
  46764. private _render;
  46765. /**
  46766. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46767. * @param mesh Defines the mesh we want the helper attached to
  46768. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46769. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46770. * @param length Defines the length of the ray
  46771. */
  46772. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46773. /**
  46774. * Detach the ray helper from the mesh it has previously been attached to.
  46775. */
  46776. detachFromMesh(): void;
  46777. private _updateToMesh;
  46778. /**
  46779. * Dispose the helper and release its associated resources.
  46780. */
  46781. dispose(): void;
  46782. }
  46783. }
  46784. declare module BABYLON.Debug {
  46785. /**
  46786. * Class used to render a debug view of a given skeleton
  46787. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46788. */
  46789. export class SkeletonViewer {
  46790. /** defines the skeleton to render */
  46791. skeleton: Skeleton;
  46792. /** defines the mesh attached to the skeleton */
  46793. mesh: AbstractMesh;
  46794. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46795. autoUpdateBonesMatrices: boolean;
  46796. /** defines the rendering group id to use with the viewer */
  46797. renderingGroupId: number;
  46798. /** Gets or sets the color used to render the skeleton */
  46799. color: Color3;
  46800. private _scene;
  46801. private _debugLines;
  46802. private _debugMesh;
  46803. private _isEnabled;
  46804. private _renderFunction;
  46805. private _utilityLayer;
  46806. /**
  46807. * Returns the mesh used to render the bones
  46808. */
  46809. get debugMesh(): Nullable<LinesMesh>;
  46810. /**
  46811. * Creates a new SkeletonViewer
  46812. * @param skeleton defines the skeleton to render
  46813. * @param mesh defines the mesh attached to the skeleton
  46814. * @param scene defines the hosting scene
  46815. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46816. * @param renderingGroupId defines the rendering group id to use with the viewer
  46817. */
  46818. constructor(
  46819. /** defines the skeleton to render */
  46820. skeleton: Skeleton,
  46821. /** defines the mesh attached to the skeleton */
  46822. mesh: AbstractMesh, scene: Scene,
  46823. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46824. autoUpdateBonesMatrices?: boolean,
  46825. /** defines the rendering group id to use with the viewer */
  46826. renderingGroupId?: number);
  46827. /** Gets or sets a boolean indicating if the viewer is enabled */
  46828. set isEnabled(value: boolean);
  46829. get isEnabled(): boolean;
  46830. private _getBonePosition;
  46831. private _getLinesForBonesWithLength;
  46832. private _getLinesForBonesNoLength;
  46833. /** Update the viewer to sync with current skeleton state */
  46834. update(): void;
  46835. /** Release associated resources */
  46836. dispose(): void;
  46837. }
  46838. }
  46839. declare module BABYLON {
  46840. /**
  46841. * Options to create the null engine
  46842. */
  46843. export class NullEngineOptions {
  46844. /**
  46845. * Render width (Default: 512)
  46846. */
  46847. renderWidth: number;
  46848. /**
  46849. * Render height (Default: 256)
  46850. */
  46851. renderHeight: number;
  46852. /**
  46853. * Texture size (Default: 512)
  46854. */
  46855. textureSize: number;
  46856. /**
  46857. * If delta time between frames should be constant
  46858. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46859. */
  46860. deterministicLockstep: boolean;
  46861. /**
  46862. * Maximum about of steps between frames (Default: 4)
  46863. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46864. */
  46865. lockstepMaxSteps: number;
  46866. }
  46867. /**
  46868. * The null engine class provides support for headless version of babylon.js.
  46869. * This can be used in server side scenario or for testing purposes
  46870. */
  46871. export class NullEngine extends Engine {
  46872. private _options;
  46873. /**
  46874. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46875. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46876. * @returns true if engine is in deterministic lock step mode
  46877. */
  46878. isDeterministicLockStep(): boolean;
  46879. /**
  46880. * Gets the max steps when engine is running in deterministic lock step
  46881. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46882. * @returns the max steps
  46883. */
  46884. getLockstepMaxSteps(): number;
  46885. /**
  46886. * Gets the current hardware scaling level.
  46887. * By default the hardware scaling level is computed from the window device ratio.
  46888. * 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.
  46889. * @returns a number indicating the current hardware scaling level
  46890. */
  46891. getHardwareScalingLevel(): number;
  46892. constructor(options?: NullEngineOptions);
  46893. /**
  46894. * Creates a vertex buffer
  46895. * @param vertices the data for the vertex buffer
  46896. * @returns the new WebGL static buffer
  46897. */
  46898. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46899. /**
  46900. * Creates a new index buffer
  46901. * @param indices defines the content of the index buffer
  46902. * @param updatable defines if the index buffer must be updatable
  46903. * @returns a new webGL buffer
  46904. */
  46905. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46906. /**
  46907. * Clear the current render buffer or the current render target (if any is set up)
  46908. * @param color defines the color to use
  46909. * @param backBuffer defines if the back buffer must be cleared
  46910. * @param depth defines if the depth buffer must be cleared
  46911. * @param stencil defines if the stencil buffer must be cleared
  46912. */
  46913. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46914. /**
  46915. * Gets the current render width
  46916. * @param useScreen defines if screen size must be used (or the current render target if any)
  46917. * @returns a number defining the current render width
  46918. */
  46919. getRenderWidth(useScreen?: boolean): number;
  46920. /**
  46921. * Gets the current render height
  46922. * @param useScreen defines if screen size must be used (or the current render target if any)
  46923. * @returns a number defining the current render height
  46924. */
  46925. getRenderHeight(useScreen?: boolean): number;
  46926. /**
  46927. * Set the WebGL's viewport
  46928. * @param viewport defines the viewport element to be used
  46929. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46930. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46931. */
  46932. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46933. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46934. /**
  46935. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46936. * @param pipelineContext defines the pipeline context to use
  46937. * @param uniformsNames defines the list of uniform names
  46938. * @returns an array of webGL uniform locations
  46939. */
  46940. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46941. /**
  46942. * Gets the lsit of active attributes for a given webGL program
  46943. * @param pipelineContext defines the pipeline context to use
  46944. * @param attributesNames defines the list of attribute names to get
  46945. * @returns an array of indices indicating the offset of each attribute
  46946. */
  46947. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46948. /**
  46949. * Binds an effect to the webGL context
  46950. * @param effect defines the effect to bind
  46951. */
  46952. bindSamplers(effect: Effect): void;
  46953. /**
  46954. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46955. * @param effect defines the effect to activate
  46956. */
  46957. enableEffect(effect: Effect): void;
  46958. /**
  46959. * Set various states to the webGL context
  46960. * @param culling defines backface culling state
  46961. * @param zOffset defines the value to apply to zOffset (0 by default)
  46962. * @param force defines if states must be applied even if cache is up to date
  46963. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46964. */
  46965. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46966. /**
  46967. * Set the value of an uniform to an array of int32
  46968. * @param uniform defines the webGL uniform location where to store the value
  46969. * @param array defines the array of int32 to store
  46970. */
  46971. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46972. /**
  46973. * Set the value of an uniform to an array of int32 (stored as vec2)
  46974. * @param uniform defines the webGL uniform location where to store the value
  46975. * @param array defines the array of int32 to store
  46976. */
  46977. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46978. /**
  46979. * Set the value of an uniform to an array of int32 (stored as vec3)
  46980. * @param uniform defines the webGL uniform location where to store the value
  46981. * @param array defines the array of int32 to store
  46982. */
  46983. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46984. /**
  46985. * Set the value of an uniform to an array of int32 (stored as vec4)
  46986. * @param uniform defines the webGL uniform location where to store the value
  46987. * @param array defines the array of int32 to store
  46988. */
  46989. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46990. /**
  46991. * Set the value of an uniform to an array of float32
  46992. * @param uniform defines the webGL uniform location where to store the value
  46993. * @param array defines the array of float32 to store
  46994. */
  46995. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46996. /**
  46997. * Set the value of an uniform to an array of float32 (stored as vec2)
  46998. * @param uniform defines the webGL uniform location where to store the value
  46999. * @param array defines the array of float32 to store
  47000. */
  47001. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47002. /**
  47003. * Set the value of an uniform to an array of float32 (stored as vec3)
  47004. * @param uniform defines the webGL uniform location where to store the value
  47005. * @param array defines the array of float32 to store
  47006. */
  47007. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47008. /**
  47009. * Set the value of an uniform to an array of float32 (stored as vec4)
  47010. * @param uniform defines the webGL uniform location where to store the value
  47011. * @param array defines the array of float32 to store
  47012. */
  47013. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47014. /**
  47015. * Set the value of an uniform to an array of number
  47016. * @param uniform defines the webGL uniform location where to store the value
  47017. * @param array defines the array of number to store
  47018. */
  47019. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47020. /**
  47021. * Set the value of an uniform to an array of number (stored as vec2)
  47022. * @param uniform defines the webGL uniform location where to store the value
  47023. * @param array defines the array of number to store
  47024. */
  47025. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47026. /**
  47027. * Set the value of an uniform to an array of number (stored as vec3)
  47028. * @param uniform defines the webGL uniform location where to store the value
  47029. * @param array defines the array of number to store
  47030. */
  47031. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47032. /**
  47033. * Set the value of an uniform to an array of number (stored as vec4)
  47034. * @param uniform defines the webGL uniform location where to store the value
  47035. * @param array defines the array of number to store
  47036. */
  47037. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47038. /**
  47039. * Set the value of an uniform to an array of float32 (stored as matrices)
  47040. * @param uniform defines the webGL uniform location where to store the value
  47041. * @param matrices defines the array of float32 to store
  47042. */
  47043. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47044. /**
  47045. * Set the value of an uniform to a matrix (3x3)
  47046. * @param uniform defines the webGL uniform location where to store the value
  47047. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47048. */
  47049. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47050. /**
  47051. * Set the value of an uniform to a matrix (2x2)
  47052. * @param uniform defines the webGL uniform location where to store the value
  47053. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47054. */
  47055. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47056. /**
  47057. * Set the value of an uniform to a number (float)
  47058. * @param uniform defines the webGL uniform location where to store the value
  47059. * @param value defines the float number to store
  47060. */
  47061. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47062. /**
  47063. * Set the value of an uniform to a vec2
  47064. * @param uniform defines the webGL uniform location where to store the value
  47065. * @param x defines the 1st component of the value
  47066. * @param y defines the 2nd component of the value
  47067. */
  47068. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47069. /**
  47070. * Set the value of an uniform to a vec3
  47071. * @param uniform defines the webGL uniform location where to store the value
  47072. * @param x defines the 1st component of the value
  47073. * @param y defines the 2nd component of the value
  47074. * @param z defines the 3rd component of the value
  47075. */
  47076. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47077. /**
  47078. * Set the value of an uniform to a boolean
  47079. * @param uniform defines the webGL uniform location where to store the value
  47080. * @param bool defines the boolean to store
  47081. */
  47082. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47083. /**
  47084. * Set the value of an uniform to a vec4
  47085. * @param uniform defines the webGL uniform location where to store the value
  47086. * @param x defines the 1st component of the value
  47087. * @param y defines the 2nd component of the value
  47088. * @param z defines the 3rd component of the value
  47089. * @param w defines the 4th component of the value
  47090. */
  47091. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47092. /**
  47093. * Sets the current alpha mode
  47094. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47095. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47096. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47097. */
  47098. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47099. /**
  47100. * Bind webGl buffers directly to the webGL context
  47101. * @param vertexBuffers defines the vertex buffer to bind
  47102. * @param indexBuffer defines the index buffer to bind
  47103. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47104. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47105. * @param effect defines the effect associated with the vertex buffer
  47106. */
  47107. bindBuffers(vertexBuffers: {
  47108. [key: string]: VertexBuffer;
  47109. }, indexBuffer: DataBuffer, effect: Effect): void;
  47110. /**
  47111. * Force the entire cache to be cleared
  47112. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47113. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47114. */
  47115. wipeCaches(bruteForce?: boolean): void;
  47116. /**
  47117. * Send a draw order
  47118. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47119. * @param indexStart defines the starting index
  47120. * @param indexCount defines the number of index to draw
  47121. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47122. */
  47123. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47124. /**
  47125. * Draw a list of indexed primitives
  47126. * @param fillMode defines the primitive to use
  47127. * @param indexStart defines the starting index
  47128. * @param indexCount defines the number of index to draw
  47129. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47130. */
  47131. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47132. /**
  47133. * Draw a list of unindexed primitives
  47134. * @param fillMode defines the primitive to use
  47135. * @param verticesStart defines the index of first vertex to draw
  47136. * @param verticesCount defines the count of vertices to draw
  47137. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47138. */
  47139. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47140. /** @hidden */
  47141. _createTexture(): WebGLTexture;
  47142. /** @hidden */
  47143. _releaseTexture(texture: InternalTexture): void;
  47144. /**
  47145. * Usually called from Texture.ts.
  47146. * Passed information to create a WebGLTexture
  47147. * @param urlArg defines a value which contains one of the following:
  47148. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47149. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47150. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47151. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47152. * @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)
  47153. * @param scene needed for loading to the correct scene
  47154. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47155. * @param onLoad optional callback to be called upon successful completion
  47156. * @param onError optional callback to be called upon failure
  47157. * @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
  47158. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47159. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47160. * @param forcedExtension defines the extension to use to pick the right loader
  47161. * @param mimeType defines an optional mime type
  47162. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47163. */
  47164. 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;
  47165. /**
  47166. * Creates a new render target texture
  47167. * @param size defines the size of the texture
  47168. * @param options defines the options used to create the texture
  47169. * @returns a new render target texture stored in an InternalTexture
  47170. */
  47171. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47172. /**
  47173. * Update the sampling mode of a given texture
  47174. * @param samplingMode defines the required sampling mode
  47175. * @param texture defines the texture to update
  47176. */
  47177. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47178. /**
  47179. * Binds the frame buffer to the specified texture.
  47180. * @param texture The texture to render to or null for the default canvas
  47181. * @param faceIndex The face of the texture to render to in case of cube texture
  47182. * @param requiredWidth The width of the target to render to
  47183. * @param requiredHeight The height of the target to render to
  47184. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47185. * @param lodLevel defines le lod level to bind to the frame buffer
  47186. */
  47187. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47188. /**
  47189. * Unbind the current render target texture from the webGL context
  47190. * @param texture defines the render target texture to unbind
  47191. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47192. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47193. */
  47194. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47195. /**
  47196. * Creates a dynamic vertex buffer
  47197. * @param vertices the data for the dynamic vertex buffer
  47198. * @returns the new WebGL dynamic buffer
  47199. */
  47200. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47201. /**
  47202. * Update the content of a dynamic texture
  47203. * @param texture defines the texture to update
  47204. * @param canvas defines the canvas containing the source
  47205. * @param invertY defines if data must be stored with Y axis inverted
  47206. * @param premulAlpha defines if alpha is stored as premultiplied
  47207. * @param format defines the format of the data
  47208. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47209. */
  47210. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47211. /**
  47212. * Gets a boolean indicating if all created effects are ready
  47213. * @returns true if all effects are ready
  47214. */
  47215. areAllEffectsReady(): boolean;
  47216. /**
  47217. * @hidden
  47218. * Get the current error code of the webGL context
  47219. * @returns the error code
  47220. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47221. */
  47222. getError(): number;
  47223. /** @hidden */
  47224. _getUnpackAlignement(): number;
  47225. /** @hidden */
  47226. _unpackFlipY(value: boolean): void;
  47227. /**
  47228. * Update a dynamic index buffer
  47229. * @param indexBuffer defines the target index buffer
  47230. * @param indices defines the data to update
  47231. * @param offset defines the offset in the target index buffer where update should start
  47232. */
  47233. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47234. /**
  47235. * Updates a dynamic vertex buffer.
  47236. * @param vertexBuffer the vertex buffer to update
  47237. * @param vertices the data used to update the vertex buffer
  47238. * @param byteOffset the byte offset of the data (optional)
  47239. * @param byteLength the byte length of the data (optional)
  47240. */
  47241. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47242. /** @hidden */
  47243. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47244. /** @hidden */
  47245. _bindTexture(channel: number, texture: InternalTexture): void;
  47246. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47247. /**
  47248. * 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
  47249. */
  47250. releaseEffects(): void;
  47251. displayLoadingUI(): void;
  47252. hideLoadingUI(): void;
  47253. /** @hidden */
  47254. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47255. /** @hidden */
  47256. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47257. /** @hidden */
  47258. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47259. /** @hidden */
  47260. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47261. }
  47262. }
  47263. declare module BABYLON {
  47264. /**
  47265. * @hidden
  47266. **/
  47267. export class _TimeToken {
  47268. _startTimeQuery: Nullable<WebGLQuery>;
  47269. _endTimeQuery: Nullable<WebGLQuery>;
  47270. _timeElapsedQuery: Nullable<WebGLQuery>;
  47271. _timeElapsedQueryEnded: boolean;
  47272. }
  47273. }
  47274. declare module BABYLON {
  47275. /** @hidden */
  47276. export class _OcclusionDataStorage {
  47277. /** @hidden */
  47278. occlusionInternalRetryCounter: number;
  47279. /** @hidden */
  47280. isOcclusionQueryInProgress: boolean;
  47281. /** @hidden */
  47282. isOccluded: boolean;
  47283. /** @hidden */
  47284. occlusionRetryCount: number;
  47285. /** @hidden */
  47286. occlusionType: number;
  47287. /** @hidden */
  47288. occlusionQueryAlgorithmType: number;
  47289. }
  47290. interface Engine {
  47291. /**
  47292. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47293. * @return the new query
  47294. */
  47295. createQuery(): WebGLQuery;
  47296. /**
  47297. * Delete and release a webGL query
  47298. * @param query defines the query to delete
  47299. * @return the current engine
  47300. */
  47301. deleteQuery(query: WebGLQuery): Engine;
  47302. /**
  47303. * Check if a given query has resolved and got its value
  47304. * @param query defines the query to check
  47305. * @returns true if the query got its value
  47306. */
  47307. isQueryResultAvailable(query: WebGLQuery): boolean;
  47308. /**
  47309. * Gets the value of a given query
  47310. * @param query defines the query to check
  47311. * @returns the value of the query
  47312. */
  47313. getQueryResult(query: WebGLQuery): number;
  47314. /**
  47315. * Initiates an occlusion query
  47316. * @param algorithmType defines the algorithm to use
  47317. * @param query defines the query to use
  47318. * @returns the current engine
  47319. * @see http://doc.babylonjs.com/features/occlusionquery
  47320. */
  47321. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47322. /**
  47323. * Ends an occlusion query
  47324. * @see http://doc.babylonjs.com/features/occlusionquery
  47325. * @param algorithmType defines the algorithm to use
  47326. * @returns the current engine
  47327. */
  47328. endOcclusionQuery(algorithmType: number): Engine;
  47329. /**
  47330. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47331. * Please note that only one query can be issued at a time
  47332. * @returns a time token used to track the time span
  47333. */
  47334. startTimeQuery(): Nullable<_TimeToken>;
  47335. /**
  47336. * Ends a time query
  47337. * @param token defines the token used to measure the time span
  47338. * @returns the time spent (in ns)
  47339. */
  47340. endTimeQuery(token: _TimeToken): int;
  47341. /** @hidden */
  47342. _currentNonTimestampToken: Nullable<_TimeToken>;
  47343. /** @hidden */
  47344. _createTimeQuery(): WebGLQuery;
  47345. /** @hidden */
  47346. _deleteTimeQuery(query: WebGLQuery): void;
  47347. /** @hidden */
  47348. _getGlAlgorithmType(algorithmType: number): number;
  47349. /** @hidden */
  47350. _getTimeQueryResult(query: WebGLQuery): any;
  47351. /** @hidden */
  47352. _getTimeQueryAvailability(query: WebGLQuery): any;
  47353. }
  47354. interface AbstractMesh {
  47355. /**
  47356. * Backing filed
  47357. * @hidden
  47358. */
  47359. __occlusionDataStorage: _OcclusionDataStorage;
  47360. /**
  47361. * Access property
  47362. * @hidden
  47363. */
  47364. _occlusionDataStorage: _OcclusionDataStorage;
  47365. /**
  47366. * 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.
  47367. * The default value is -1 which means don't break the query and wait till the result
  47368. * @see http://doc.babylonjs.com/features/occlusionquery
  47369. */
  47370. occlusionRetryCount: number;
  47371. /**
  47372. * 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:
  47373. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47374. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47375. * * 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.
  47376. * @see http://doc.babylonjs.com/features/occlusionquery
  47377. */
  47378. occlusionType: number;
  47379. /**
  47380. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47381. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47382. * * 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.
  47383. * @see http://doc.babylonjs.com/features/occlusionquery
  47384. */
  47385. occlusionQueryAlgorithmType: number;
  47386. /**
  47387. * 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
  47388. * @see http://doc.babylonjs.com/features/occlusionquery
  47389. */
  47390. isOccluded: boolean;
  47391. /**
  47392. * Flag to check the progress status of the query
  47393. * @see http://doc.babylonjs.com/features/occlusionquery
  47394. */
  47395. isOcclusionQueryInProgress: boolean;
  47396. }
  47397. }
  47398. declare module BABYLON {
  47399. /** @hidden */
  47400. export var _forceTransformFeedbackToBundle: boolean;
  47401. interface Engine {
  47402. /**
  47403. * Creates a webGL transform feedback object
  47404. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47405. * @returns the webGL transform feedback object
  47406. */
  47407. createTransformFeedback(): WebGLTransformFeedback;
  47408. /**
  47409. * Delete a webGL transform feedback object
  47410. * @param value defines the webGL transform feedback object to delete
  47411. */
  47412. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47413. /**
  47414. * Bind a webGL transform feedback object to the webgl context
  47415. * @param value defines the webGL transform feedback object to bind
  47416. */
  47417. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47418. /**
  47419. * Begins a transform feedback operation
  47420. * @param usePoints defines if points or triangles must be used
  47421. */
  47422. beginTransformFeedback(usePoints: boolean): void;
  47423. /**
  47424. * Ends a transform feedback operation
  47425. */
  47426. endTransformFeedback(): void;
  47427. /**
  47428. * Specify the varyings to use with transform feedback
  47429. * @param program defines the associated webGL program
  47430. * @param value defines the list of strings representing the varying names
  47431. */
  47432. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47433. /**
  47434. * Bind a webGL buffer for a transform feedback operation
  47435. * @param value defines the webGL buffer to bind
  47436. */
  47437. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47438. }
  47439. }
  47440. declare module BABYLON {
  47441. /**
  47442. * Creation options of the multi render target texture.
  47443. */
  47444. export interface IMultiRenderTargetOptions {
  47445. /**
  47446. * Define if the texture needs to create mip maps after render.
  47447. */
  47448. generateMipMaps?: boolean;
  47449. /**
  47450. * Define the types of all the draw buffers we want to create
  47451. */
  47452. types?: number[];
  47453. /**
  47454. * Define the sampling modes of all the draw buffers we want to create
  47455. */
  47456. samplingModes?: number[];
  47457. /**
  47458. * Define if a depth buffer is required
  47459. */
  47460. generateDepthBuffer?: boolean;
  47461. /**
  47462. * Define if a stencil buffer is required
  47463. */
  47464. generateStencilBuffer?: boolean;
  47465. /**
  47466. * Define if a depth texture is required instead of a depth buffer
  47467. */
  47468. generateDepthTexture?: boolean;
  47469. /**
  47470. * Define the number of desired draw buffers
  47471. */
  47472. textureCount?: number;
  47473. /**
  47474. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47475. */
  47476. doNotChangeAspectRatio?: boolean;
  47477. /**
  47478. * Define the default type of the buffers we are creating
  47479. */
  47480. defaultType?: number;
  47481. }
  47482. /**
  47483. * A multi render target, like a render target provides the ability to render to a texture.
  47484. * Unlike the render target, it can render to several draw buffers in one draw.
  47485. * This is specially interesting in deferred rendering or for any effects requiring more than
  47486. * just one color from a single pass.
  47487. */
  47488. export class MultiRenderTarget extends RenderTargetTexture {
  47489. private _internalTextures;
  47490. private _textures;
  47491. private _multiRenderTargetOptions;
  47492. /**
  47493. * Get if draw buffers are currently supported by the used hardware and browser.
  47494. */
  47495. get isSupported(): boolean;
  47496. /**
  47497. * Get the list of textures generated by the multi render target.
  47498. */
  47499. get textures(): Texture[];
  47500. /**
  47501. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47502. */
  47503. get depthTexture(): Texture;
  47504. /**
  47505. * Set the wrapping mode on U of all the textures we are rendering to.
  47506. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47507. */
  47508. set wrapU(wrap: number);
  47509. /**
  47510. * Set the wrapping mode on V of all the textures we are rendering to.
  47511. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47512. */
  47513. set wrapV(wrap: number);
  47514. /**
  47515. * Instantiate a new multi render target texture.
  47516. * A multi render target, like a render target provides the ability to render to a texture.
  47517. * Unlike the render target, it can render to several draw buffers in one draw.
  47518. * This is specially interesting in deferred rendering or for any effects requiring more than
  47519. * just one color from a single pass.
  47520. * @param name Define the name of the texture
  47521. * @param size Define the size of the buffers to render to
  47522. * @param count Define the number of target we are rendering into
  47523. * @param scene Define the scene the texture belongs to
  47524. * @param options Define the options used to create the multi render target
  47525. */
  47526. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47527. /** @hidden */
  47528. _rebuild(): void;
  47529. private _createInternalTextures;
  47530. private _createTextures;
  47531. /**
  47532. * Define the number of samples used if MSAA is enabled.
  47533. */
  47534. get samples(): number;
  47535. set samples(value: number);
  47536. /**
  47537. * Resize all the textures in the multi render target.
  47538. * Be carrefull as it will recreate all the data in the new texture.
  47539. * @param size Define the new size
  47540. */
  47541. resize(size: any): void;
  47542. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47543. /**
  47544. * Dispose the render targets and their associated resources
  47545. */
  47546. dispose(): void;
  47547. /**
  47548. * Release all the underlying texture used as draw buffers.
  47549. */
  47550. releaseInternalTextures(): void;
  47551. }
  47552. }
  47553. declare module BABYLON {
  47554. interface ThinEngine {
  47555. /**
  47556. * Unbind a list of render target textures from the webGL context
  47557. * This is used only when drawBuffer extension or webGL2 are active
  47558. * @param textures defines the render target textures to unbind
  47559. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47560. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47561. */
  47562. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47563. /**
  47564. * Create a multi render target texture
  47565. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47566. * @param size defines the size of the texture
  47567. * @param options defines the creation options
  47568. * @returns the cube texture as an InternalTexture
  47569. */
  47570. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47571. /**
  47572. * Update the sample count for a given multiple render target texture
  47573. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47574. * @param textures defines the textures to update
  47575. * @param samples defines the sample count to set
  47576. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47577. */
  47578. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47579. }
  47580. }
  47581. declare module BABYLON {
  47582. /**
  47583. * Class used to define an additional view for the engine
  47584. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47585. */
  47586. export class EngineView {
  47587. /** Defines the canvas where to render the view */
  47588. target: HTMLCanvasElement;
  47589. /** Defines an optional camera used to render the view (will use active camera else) */
  47590. camera?: Camera;
  47591. }
  47592. interface Engine {
  47593. /**
  47594. * Gets or sets the HTML element to use for attaching events
  47595. */
  47596. inputElement: Nullable<HTMLElement>;
  47597. /**
  47598. * Gets the current engine view
  47599. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47600. */
  47601. activeView: Nullable<EngineView>;
  47602. /** Gets or sets the list of views */
  47603. views: EngineView[];
  47604. /**
  47605. * Register a new child canvas
  47606. * @param canvas defines the canvas to register
  47607. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47608. * @returns the associated view
  47609. */
  47610. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47611. /**
  47612. * Remove a registered child canvas
  47613. * @param canvas defines the canvas to remove
  47614. * @returns the current engine
  47615. */
  47616. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47617. }
  47618. }
  47619. declare module BABYLON {
  47620. interface Engine {
  47621. /** @hidden */
  47622. _excludedCompressedTextures: string[];
  47623. /** @hidden */
  47624. _textureFormatInUse: string;
  47625. /**
  47626. * Gets the list of texture formats supported
  47627. */
  47628. readonly texturesSupported: Array<string>;
  47629. /**
  47630. * Gets the texture format in use
  47631. */
  47632. readonly textureFormatInUse: Nullable<string>;
  47633. /**
  47634. * Set the compressed texture extensions or file names to skip.
  47635. *
  47636. * @param skippedFiles defines the list of those texture files you want to skip
  47637. * Example: [".dds", ".env", "myfile.png"]
  47638. */
  47639. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47640. /**
  47641. * Set the compressed texture format to use, based on the formats you have, and the formats
  47642. * supported by the hardware / browser.
  47643. *
  47644. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47645. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47646. * to API arguments needed to compressed textures. This puts the burden on the container
  47647. * generator to house the arcane code for determining these for current & future formats.
  47648. *
  47649. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47650. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47651. *
  47652. * Note: The result of this call is not taken into account when a texture is base64.
  47653. *
  47654. * @param formatsAvailable defines the list of those format families you have created
  47655. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47656. *
  47657. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47658. * @returns The extension selected.
  47659. */
  47660. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47661. }
  47662. }
  47663. declare module BABYLON {
  47664. /**
  47665. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47666. */
  47667. export interface CubeMapInfo {
  47668. /**
  47669. * The pixel array for the front face.
  47670. * This is stored in format, left to right, up to down format.
  47671. */
  47672. front: Nullable<ArrayBufferView>;
  47673. /**
  47674. * The pixel array for the back face.
  47675. * This is stored in format, left to right, up to down format.
  47676. */
  47677. back: Nullable<ArrayBufferView>;
  47678. /**
  47679. * The pixel array for the left face.
  47680. * This is stored in format, left to right, up to down format.
  47681. */
  47682. left: Nullable<ArrayBufferView>;
  47683. /**
  47684. * The pixel array for the right face.
  47685. * This is stored in format, left to right, up to down format.
  47686. */
  47687. right: Nullable<ArrayBufferView>;
  47688. /**
  47689. * The pixel array for the up face.
  47690. * This is stored in format, left to right, up to down format.
  47691. */
  47692. up: Nullable<ArrayBufferView>;
  47693. /**
  47694. * The pixel array for the down face.
  47695. * This is stored in format, left to right, up to down format.
  47696. */
  47697. down: Nullable<ArrayBufferView>;
  47698. /**
  47699. * The size of the cubemap stored.
  47700. *
  47701. * Each faces will be size * size pixels.
  47702. */
  47703. size: number;
  47704. /**
  47705. * The format of the texture.
  47706. *
  47707. * RGBA, RGB.
  47708. */
  47709. format: number;
  47710. /**
  47711. * The type of the texture data.
  47712. *
  47713. * UNSIGNED_INT, FLOAT.
  47714. */
  47715. type: number;
  47716. /**
  47717. * Specifies whether the texture is in gamma space.
  47718. */
  47719. gammaSpace: boolean;
  47720. }
  47721. /**
  47722. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47723. */
  47724. export class PanoramaToCubeMapTools {
  47725. private static FACE_FRONT;
  47726. private static FACE_BACK;
  47727. private static FACE_RIGHT;
  47728. private static FACE_LEFT;
  47729. private static FACE_DOWN;
  47730. private static FACE_UP;
  47731. /**
  47732. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47733. *
  47734. * @param float32Array The source data.
  47735. * @param inputWidth The width of the input panorama.
  47736. * @param inputHeight The height of the input panorama.
  47737. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47738. * @return The cubemap data
  47739. */
  47740. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47741. private static CreateCubemapTexture;
  47742. private static CalcProjectionSpherical;
  47743. }
  47744. }
  47745. declare module BABYLON {
  47746. /**
  47747. * Helper class dealing with the extraction of spherical polynomial dataArray
  47748. * from a cube map.
  47749. */
  47750. export class CubeMapToSphericalPolynomialTools {
  47751. private static FileFaces;
  47752. /**
  47753. * Converts a texture to the according Spherical Polynomial data.
  47754. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47755. *
  47756. * @param texture The texture to extract the information from.
  47757. * @return The Spherical Polynomial data.
  47758. */
  47759. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47760. /**
  47761. * Converts a cubemap to the according Spherical Polynomial data.
  47762. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47763. *
  47764. * @param cubeInfo The Cube map to extract the information from.
  47765. * @return The Spherical Polynomial data.
  47766. */
  47767. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47768. }
  47769. }
  47770. declare module BABYLON {
  47771. interface BaseTexture {
  47772. /**
  47773. * Get the polynomial representation of the texture data.
  47774. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47775. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47776. */
  47777. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47778. }
  47779. }
  47780. declare module BABYLON {
  47781. /** @hidden */
  47782. export var rgbdEncodePixelShader: {
  47783. name: string;
  47784. shader: string;
  47785. };
  47786. }
  47787. declare module BABYLON {
  47788. /** @hidden */
  47789. export var rgbdDecodePixelShader: {
  47790. name: string;
  47791. shader: string;
  47792. };
  47793. }
  47794. declare module BABYLON {
  47795. /**
  47796. * Raw texture data and descriptor sufficient for WebGL texture upload
  47797. */
  47798. export interface EnvironmentTextureInfo {
  47799. /**
  47800. * Version of the environment map
  47801. */
  47802. version: number;
  47803. /**
  47804. * Width of image
  47805. */
  47806. width: number;
  47807. /**
  47808. * Irradiance information stored in the file.
  47809. */
  47810. irradiance: any;
  47811. /**
  47812. * Specular information stored in the file.
  47813. */
  47814. specular: any;
  47815. }
  47816. /**
  47817. * Defines One Image in the file. It requires only the position in the file
  47818. * as well as the length.
  47819. */
  47820. interface BufferImageData {
  47821. /**
  47822. * Length of the image data.
  47823. */
  47824. length: number;
  47825. /**
  47826. * Position of the data from the null terminator delimiting the end of the JSON.
  47827. */
  47828. position: number;
  47829. }
  47830. /**
  47831. * Defines the specular data enclosed in the file.
  47832. * This corresponds to the version 1 of the data.
  47833. */
  47834. export interface EnvironmentTextureSpecularInfoV1 {
  47835. /**
  47836. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47837. */
  47838. specularDataPosition?: number;
  47839. /**
  47840. * This contains all the images data needed to reconstruct the cubemap.
  47841. */
  47842. mipmaps: Array<BufferImageData>;
  47843. /**
  47844. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47845. */
  47846. lodGenerationScale: number;
  47847. }
  47848. /**
  47849. * Sets of helpers addressing the serialization and deserialization of environment texture
  47850. * stored in a BabylonJS env file.
  47851. * Those files are usually stored as .env files.
  47852. */
  47853. export class EnvironmentTextureTools {
  47854. /**
  47855. * Magic number identifying the env file.
  47856. */
  47857. private static _MagicBytes;
  47858. /**
  47859. * Gets the environment info from an env file.
  47860. * @param data The array buffer containing the .env bytes.
  47861. * @returns the environment file info (the json header) if successfully parsed.
  47862. */
  47863. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47864. /**
  47865. * Creates an environment texture from a loaded cube texture.
  47866. * @param texture defines the cube texture to convert in env file
  47867. * @return a promise containing the environment data if succesfull.
  47868. */
  47869. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47870. /**
  47871. * Creates a JSON representation of the spherical data.
  47872. * @param texture defines the texture containing the polynomials
  47873. * @return the JSON representation of the spherical info
  47874. */
  47875. private static _CreateEnvTextureIrradiance;
  47876. /**
  47877. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47878. * @param data the image data
  47879. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47880. * @return the views described by info providing access to the underlying buffer
  47881. */
  47882. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47883. /**
  47884. * Uploads the texture info contained in the env file to the GPU.
  47885. * @param texture defines the internal texture to upload to
  47886. * @param data defines the data to load
  47887. * @param info defines the texture info retrieved through the GetEnvInfo method
  47888. * @returns a promise
  47889. */
  47890. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47891. private static _OnImageReadyAsync;
  47892. /**
  47893. * Uploads the levels of image data to the GPU.
  47894. * @param texture defines the internal texture to upload to
  47895. * @param imageData defines the array buffer views of image data [mipmap][face]
  47896. * @returns a promise
  47897. */
  47898. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47899. /**
  47900. * Uploads spherical polynomials information to the texture.
  47901. * @param texture defines the texture we are trying to upload the information to
  47902. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47903. */
  47904. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47905. /** @hidden */
  47906. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47907. }
  47908. }
  47909. declare module BABYLON {
  47910. /**
  47911. * Contains position and normal vectors for a vertex
  47912. */
  47913. export class PositionNormalVertex {
  47914. /** the position of the vertex (defaut: 0,0,0) */
  47915. position: Vector3;
  47916. /** the normal of the vertex (defaut: 0,1,0) */
  47917. normal: Vector3;
  47918. /**
  47919. * Creates a PositionNormalVertex
  47920. * @param position the position of the vertex (defaut: 0,0,0)
  47921. * @param normal the normal of the vertex (defaut: 0,1,0)
  47922. */
  47923. constructor(
  47924. /** the position of the vertex (defaut: 0,0,0) */
  47925. position?: Vector3,
  47926. /** the normal of the vertex (defaut: 0,1,0) */
  47927. normal?: Vector3);
  47928. /**
  47929. * Clones the PositionNormalVertex
  47930. * @returns the cloned PositionNormalVertex
  47931. */
  47932. clone(): PositionNormalVertex;
  47933. }
  47934. /**
  47935. * Contains position, normal and uv vectors for a vertex
  47936. */
  47937. export class PositionNormalTextureVertex {
  47938. /** the position of the vertex (defaut: 0,0,0) */
  47939. position: Vector3;
  47940. /** the normal of the vertex (defaut: 0,1,0) */
  47941. normal: Vector3;
  47942. /** the uv of the vertex (default: 0,0) */
  47943. uv: Vector2;
  47944. /**
  47945. * Creates a PositionNormalTextureVertex
  47946. * @param position the position of the vertex (defaut: 0,0,0)
  47947. * @param normal the normal of the vertex (defaut: 0,1,0)
  47948. * @param uv the uv of the vertex (default: 0,0)
  47949. */
  47950. constructor(
  47951. /** the position of the vertex (defaut: 0,0,0) */
  47952. position?: Vector3,
  47953. /** the normal of the vertex (defaut: 0,1,0) */
  47954. normal?: Vector3,
  47955. /** the uv of the vertex (default: 0,0) */
  47956. uv?: Vector2);
  47957. /**
  47958. * Clones the PositionNormalTextureVertex
  47959. * @returns the cloned PositionNormalTextureVertex
  47960. */
  47961. clone(): PositionNormalTextureVertex;
  47962. }
  47963. }
  47964. declare module BABYLON {
  47965. /** @hidden */
  47966. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47967. private _genericAttributeLocation;
  47968. private _varyingLocationCount;
  47969. private _varyingLocationMap;
  47970. private _replacements;
  47971. private _textureCount;
  47972. private _uniforms;
  47973. lineProcessor(line: string): string;
  47974. attributeProcessor(attribute: string): string;
  47975. varyingProcessor(varying: string, isFragment: boolean): string;
  47976. uniformProcessor(uniform: string): string;
  47977. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47978. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47979. }
  47980. }
  47981. declare module BABYLON {
  47982. /**
  47983. * Container for accessors for natively-stored mesh data buffers.
  47984. */
  47985. class NativeDataBuffer extends DataBuffer {
  47986. /**
  47987. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47988. */
  47989. nativeIndexBuffer?: any;
  47990. /**
  47991. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47992. */
  47993. nativeVertexBuffer?: any;
  47994. }
  47995. /** @hidden */
  47996. class NativeTexture extends InternalTexture {
  47997. getInternalTexture(): InternalTexture;
  47998. getViewCount(): number;
  47999. }
  48000. /** @hidden */
  48001. export class NativeEngine extends Engine {
  48002. private readonly _native;
  48003. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48004. private readonly INVALID_HANDLE;
  48005. getHardwareScalingLevel(): number;
  48006. constructor();
  48007. /**
  48008. * Can be used to override the current requestAnimationFrame requester.
  48009. * @hidden
  48010. */
  48011. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48012. /**
  48013. * Override default engine behavior.
  48014. * @param color
  48015. * @param backBuffer
  48016. * @param depth
  48017. * @param stencil
  48018. */
  48019. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48020. /**
  48021. * Gets host document
  48022. * @returns the host document object
  48023. */
  48024. getHostDocument(): Nullable<Document>;
  48025. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48026. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48027. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48028. recordVertexArrayObject(vertexBuffers: {
  48029. [key: string]: VertexBuffer;
  48030. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48031. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48032. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48033. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48034. /**
  48035. * Draw a list of indexed primitives
  48036. * @param fillMode defines the primitive to use
  48037. * @param indexStart defines the starting index
  48038. * @param indexCount defines the number of index to draw
  48039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48040. */
  48041. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48042. /**
  48043. * Draw a list of unindexed primitives
  48044. * @param fillMode defines the primitive to use
  48045. * @param verticesStart defines the index of first vertex to draw
  48046. * @param verticesCount defines the count of vertices to draw
  48047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48048. */
  48049. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48050. createPipelineContext(): IPipelineContext;
  48051. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48052. /** @hidden */
  48053. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48054. /** @hidden */
  48055. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48056. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48057. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48058. protected _setProgram(program: WebGLProgram): void;
  48059. _releaseEffect(effect: Effect): void;
  48060. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48061. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48062. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48063. bindSamplers(effect: Effect): void;
  48064. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48065. getRenderWidth(useScreen?: boolean): number;
  48066. getRenderHeight(useScreen?: boolean): number;
  48067. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48068. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48069. /**
  48070. * Set the z offset to apply to current rendering
  48071. * @param value defines the offset to apply
  48072. */
  48073. setZOffset(value: number): void;
  48074. /**
  48075. * Gets the current value of the zOffset
  48076. * @returns the current zOffset state
  48077. */
  48078. getZOffset(): number;
  48079. /**
  48080. * Enable or disable depth buffering
  48081. * @param enable defines the state to set
  48082. */
  48083. setDepthBuffer(enable: boolean): void;
  48084. /**
  48085. * Gets a boolean indicating if depth writing is enabled
  48086. * @returns the current depth writing state
  48087. */
  48088. getDepthWrite(): boolean;
  48089. /**
  48090. * Enable or disable depth writing
  48091. * @param enable defines the state to set
  48092. */
  48093. setDepthWrite(enable: boolean): void;
  48094. /**
  48095. * Enable or disable color writing
  48096. * @param enable defines the state to set
  48097. */
  48098. setColorWrite(enable: boolean): void;
  48099. /**
  48100. * Gets a boolean indicating if color writing is enabled
  48101. * @returns the current color writing state
  48102. */
  48103. getColorWrite(): boolean;
  48104. /**
  48105. * Sets alpha constants used by some alpha blending modes
  48106. * @param r defines the red component
  48107. * @param g defines the green component
  48108. * @param b defines the blue component
  48109. * @param a defines the alpha component
  48110. */
  48111. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48112. /**
  48113. * Sets the current alpha mode
  48114. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48115. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48116. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48117. */
  48118. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48119. /**
  48120. * Gets the current alpha mode
  48121. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48122. * @returns the current alpha mode
  48123. */
  48124. getAlphaMode(): number;
  48125. setInt(uniform: WebGLUniformLocation, int: number): void;
  48126. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48127. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48128. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48129. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48130. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48131. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48132. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48133. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48134. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48135. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48136. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48137. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48138. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48139. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48140. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48141. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48142. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48143. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48144. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48145. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48146. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48147. wipeCaches(bruteForce?: boolean): void;
  48148. _createTexture(): WebGLTexture;
  48149. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48150. /**
  48151. * Usually called from Texture.ts.
  48152. * Passed information to create a WebGLTexture
  48153. * @param urlArg defines a value which contains one of the following:
  48154. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48155. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48156. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48157. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48158. * @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)
  48159. * @param scene needed for loading to the correct scene
  48160. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48161. * @param onLoad optional callback to be called upon successful completion
  48162. * @param onError optional callback to be called upon failure
  48163. * @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
  48164. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48165. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48166. * @param forcedExtension defines the extension to use to pick the right loader
  48167. * @param mimeType defines an optional mime type
  48168. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48169. */
  48170. 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;
  48171. /**
  48172. * Creates a cube texture
  48173. * @param rootUrl defines the url where the files to load is located
  48174. * @param scene defines the current scene
  48175. * @param files defines the list of files to load (1 per face)
  48176. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48177. * @param onLoad defines an optional callback raised when the texture is loaded
  48178. * @param onError defines an optional callback raised if there is an issue to load the texture
  48179. * @param format defines the format of the data
  48180. * @param forcedExtension defines the extension to use to pick the right loader
  48181. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48182. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48183. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48184. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48185. * @returns the cube texture as an InternalTexture
  48186. */
  48187. 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;
  48188. private _getSamplingFilter;
  48189. private static _GetNativeTextureFormat;
  48190. createRenderTargetTexture(size: number | {
  48191. width: number;
  48192. height: number;
  48193. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48194. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48195. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48196. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48197. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48198. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48199. /**
  48200. * Updates a dynamic vertex buffer.
  48201. * @param vertexBuffer the vertex buffer to update
  48202. * @param data the data used to update the vertex buffer
  48203. * @param byteOffset the byte offset of the data (optional)
  48204. * @param byteLength the byte length of the data (optional)
  48205. */
  48206. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48207. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48208. private _updateAnisotropicLevel;
  48209. private _getAddressMode;
  48210. /** @hidden */
  48211. _bindTexture(channel: number, texture: InternalTexture): void;
  48212. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48213. releaseEffects(): void;
  48214. /** @hidden */
  48215. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48216. /** @hidden */
  48217. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48218. /** @hidden */
  48219. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48220. /** @hidden */
  48221. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48222. }
  48223. }
  48224. declare module BABYLON {
  48225. /**
  48226. * Gather the list of clipboard event types as constants.
  48227. */
  48228. export class ClipboardEventTypes {
  48229. /**
  48230. * The clipboard event is fired when a copy command is active (pressed).
  48231. */
  48232. static readonly COPY: number;
  48233. /**
  48234. * The clipboard event is fired when a cut command is active (pressed).
  48235. */
  48236. static readonly CUT: number;
  48237. /**
  48238. * The clipboard event is fired when a paste command is active (pressed).
  48239. */
  48240. static readonly PASTE: number;
  48241. }
  48242. /**
  48243. * This class is used to store clipboard related info for the onClipboardObservable event.
  48244. */
  48245. export class ClipboardInfo {
  48246. /**
  48247. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48248. */
  48249. type: number;
  48250. /**
  48251. * Defines the related dom event
  48252. */
  48253. event: ClipboardEvent;
  48254. /**
  48255. *Creates an instance of ClipboardInfo.
  48256. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48257. * @param event Defines the related dom event
  48258. */
  48259. constructor(
  48260. /**
  48261. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48262. */
  48263. type: number,
  48264. /**
  48265. * Defines the related dom event
  48266. */
  48267. event: ClipboardEvent);
  48268. /**
  48269. * Get the clipboard event's type from the keycode.
  48270. * @param keyCode Defines the keyCode for the current keyboard event.
  48271. * @return {number}
  48272. */
  48273. static GetTypeFromCharacter(keyCode: number): number;
  48274. }
  48275. }
  48276. declare module BABYLON {
  48277. /**
  48278. * Google Daydream controller
  48279. */
  48280. export class DaydreamController extends WebVRController {
  48281. /**
  48282. * Base Url for the controller model.
  48283. */
  48284. static MODEL_BASE_URL: string;
  48285. /**
  48286. * File name for the controller model.
  48287. */
  48288. static MODEL_FILENAME: string;
  48289. /**
  48290. * Gamepad Id prefix used to identify Daydream Controller.
  48291. */
  48292. static readonly GAMEPAD_ID_PREFIX: string;
  48293. /**
  48294. * Creates a new DaydreamController from a gamepad
  48295. * @param vrGamepad the gamepad that the controller should be created from
  48296. */
  48297. constructor(vrGamepad: any);
  48298. /**
  48299. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48300. * @param scene scene in which to add meshes
  48301. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48302. */
  48303. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48304. /**
  48305. * Called once for each button that changed state since the last frame
  48306. * @param buttonIdx Which button index changed
  48307. * @param state New state of the button
  48308. * @param changes Which properties on the state changed since last frame
  48309. */
  48310. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48311. }
  48312. }
  48313. declare module BABYLON {
  48314. /**
  48315. * Gear VR Controller
  48316. */
  48317. export class GearVRController extends WebVRController {
  48318. /**
  48319. * Base Url for the controller model.
  48320. */
  48321. static MODEL_BASE_URL: string;
  48322. /**
  48323. * File name for the controller model.
  48324. */
  48325. static MODEL_FILENAME: string;
  48326. /**
  48327. * Gamepad Id prefix used to identify this controller.
  48328. */
  48329. static readonly GAMEPAD_ID_PREFIX: string;
  48330. private readonly _buttonIndexToObservableNameMap;
  48331. /**
  48332. * Creates a new GearVRController from a gamepad
  48333. * @param vrGamepad the gamepad that the controller should be created from
  48334. */
  48335. constructor(vrGamepad: any);
  48336. /**
  48337. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48338. * @param scene scene in which to add meshes
  48339. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48340. */
  48341. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48342. /**
  48343. * Called once for each button that changed state since the last frame
  48344. * @param buttonIdx Which button index changed
  48345. * @param state New state of the button
  48346. * @param changes Which properties on the state changed since last frame
  48347. */
  48348. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48349. }
  48350. }
  48351. declare module BABYLON {
  48352. /**
  48353. * Generic Controller
  48354. */
  48355. export class GenericController extends WebVRController {
  48356. /**
  48357. * Base Url for the controller model.
  48358. */
  48359. static readonly MODEL_BASE_URL: string;
  48360. /**
  48361. * File name for the controller model.
  48362. */
  48363. static readonly MODEL_FILENAME: string;
  48364. /**
  48365. * Creates a new GenericController from a gamepad
  48366. * @param vrGamepad the gamepad that the controller should be created from
  48367. */
  48368. constructor(vrGamepad: any);
  48369. /**
  48370. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48371. * @param scene scene in which to add meshes
  48372. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48373. */
  48374. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48375. /**
  48376. * Called once for each button that changed state since the last frame
  48377. * @param buttonIdx Which button index changed
  48378. * @param state New state of the button
  48379. * @param changes Which properties on the state changed since last frame
  48380. */
  48381. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48382. }
  48383. }
  48384. declare module BABYLON {
  48385. /**
  48386. * Oculus Touch Controller
  48387. */
  48388. export class OculusTouchController extends WebVRController {
  48389. /**
  48390. * Base Url for the controller model.
  48391. */
  48392. static MODEL_BASE_URL: string;
  48393. /**
  48394. * File name for the left controller model.
  48395. */
  48396. static MODEL_LEFT_FILENAME: string;
  48397. /**
  48398. * File name for the right controller model.
  48399. */
  48400. static MODEL_RIGHT_FILENAME: string;
  48401. /**
  48402. * Base Url for the Quest controller model.
  48403. */
  48404. static QUEST_MODEL_BASE_URL: string;
  48405. /**
  48406. * @hidden
  48407. * If the controllers are running on a device that needs the updated Quest controller models
  48408. */
  48409. static _IsQuest: boolean;
  48410. /**
  48411. * Fired when the secondary trigger on this controller is modified
  48412. */
  48413. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48414. /**
  48415. * Fired when the thumb rest on this controller is modified
  48416. */
  48417. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48418. /**
  48419. * Creates a new OculusTouchController from a gamepad
  48420. * @param vrGamepad the gamepad that the controller should be created from
  48421. */
  48422. constructor(vrGamepad: any);
  48423. /**
  48424. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48425. * @param scene scene in which to add meshes
  48426. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48427. */
  48428. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48429. /**
  48430. * Fired when the A button on this controller is modified
  48431. */
  48432. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48433. /**
  48434. * Fired when the B button on this controller is modified
  48435. */
  48436. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48437. /**
  48438. * Fired when the X button on this controller is modified
  48439. */
  48440. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48441. /**
  48442. * Fired when the Y button on this controller is modified
  48443. */
  48444. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48445. /**
  48446. * Called once for each button that changed state since the last frame
  48447. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48448. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48449. * 2) secondary trigger (same)
  48450. * 3) A (right) X (left), touch, pressed = value
  48451. * 4) B / Y
  48452. * 5) thumb rest
  48453. * @param buttonIdx Which button index changed
  48454. * @param state New state of the button
  48455. * @param changes Which properties on the state changed since last frame
  48456. */
  48457. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48458. }
  48459. }
  48460. declare module BABYLON {
  48461. /**
  48462. * Vive Controller
  48463. */
  48464. export class ViveController extends WebVRController {
  48465. /**
  48466. * Base Url for the controller model.
  48467. */
  48468. static MODEL_BASE_URL: string;
  48469. /**
  48470. * File name for the controller model.
  48471. */
  48472. static MODEL_FILENAME: string;
  48473. /**
  48474. * Creates a new ViveController from a gamepad
  48475. * @param vrGamepad the gamepad that the controller should be created from
  48476. */
  48477. constructor(vrGamepad: any);
  48478. /**
  48479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48480. * @param scene scene in which to add meshes
  48481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48482. */
  48483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48484. /**
  48485. * Fired when the left button on this controller is modified
  48486. */
  48487. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48488. /**
  48489. * Fired when the right button on this controller is modified
  48490. */
  48491. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48492. /**
  48493. * Fired when the menu button on this controller is modified
  48494. */
  48495. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48496. /**
  48497. * Called once for each button that changed state since the last frame
  48498. * Vive mapping:
  48499. * 0: touchpad
  48500. * 1: trigger
  48501. * 2: left AND right buttons
  48502. * 3: menu button
  48503. * @param buttonIdx Which button index changed
  48504. * @param state New state of the button
  48505. * @param changes Which properties on the state changed since last frame
  48506. */
  48507. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48508. }
  48509. }
  48510. declare module BABYLON {
  48511. /**
  48512. * Defines the WindowsMotionController object that the state of the windows motion controller
  48513. */
  48514. export class WindowsMotionController extends WebVRController {
  48515. /**
  48516. * The base url used to load the left and right controller models
  48517. */
  48518. static MODEL_BASE_URL: string;
  48519. /**
  48520. * The name of the left controller model file
  48521. */
  48522. static MODEL_LEFT_FILENAME: string;
  48523. /**
  48524. * The name of the right controller model file
  48525. */
  48526. static MODEL_RIGHT_FILENAME: string;
  48527. /**
  48528. * The controller name prefix for this controller type
  48529. */
  48530. static readonly GAMEPAD_ID_PREFIX: string;
  48531. /**
  48532. * The controller id pattern for this controller type
  48533. */
  48534. private static readonly GAMEPAD_ID_PATTERN;
  48535. private _loadedMeshInfo;
  48536. protected readonly _mapping: {
  48537. buttons: string[];
  48538. buttonMeshNames: {
  48539. trigger: string;
  48540. menu: string;
  48541. grip: string;
  48542. thumbstick: string;
  48543. trackpad: string;
  48544. };
  48545. buttonObservableNames: {
  48546. trigger: string;
  48547. menu: string;
  48548. grip: string;
  48549. thumbstick: string;
  48550. trackpad: string;
  48551. };
  48552. axisMeshNames: string[];
  48553. pointingPoseMeshName: string;
  48554. };
  48555. /**
  48556. * Fired when the trackpad on this controller is clicked
  48557. */
  48558. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48559. /**
  48560. * Fired when the trackpad on this controller is modified
  48561. */
  48562. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48563. /**
  48564. * The current x and y values of this controller's trackpad
  48565. */
  48566. trackpad: StickValues;
  48567. /**
  48568. * Creates a new WindowsMotionController from a gamepad
  48569. * @param vrGamepad the gamepad that the controller should be created from
  48570. */
  48571. constructor(vrGamepad: any);
  48572. /**
  48573. * Fired when the trigger on this controller is modified
  48574. */
  48575. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48576. /**
  48577. * Fired when the menu button on this controller is modified
  48578. */
  48579. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48580. /**
  48581. * Fired when the grip button on this controller is modified
  48582. */
  48583. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48584. /**
  48585. * Fired when the thumbstick button on this controller is modified
  48586. */
  48587. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48588. /**
  48589. * Fired when the touchpad button on this controller is modified
  48590. */
  48591. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48592. /**
  48593. * Fired when the touchpad values on this controller are modified
  48594. */
  48595. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48596. protected _updateTrackpad(): void;
  48597. /**
  48598. * Called once per frame by the engine.
  48599. */
  48600. update(): void;
  48601. /**
  48602. * Called once for each button that changed state since the last frame
  48603. * @param buttonIdx Which button index changed
  48604. * @param state New state of the button
  48605. * @param changes Which properties on the state changed since last frame
  48606. */
  48607. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48608. /**
  48609. * Moves the buttons on the controller mesh based on their current state
  48610. * @param buttonName the name of the button to move
  48611. * @param buttonValue the value of the button which determines the buttons new position
  48612. */
  48613. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48614. /**
  48615. * Moves the axis on the controller mesh based on its current state
  48616. * @param axis the index of the axis
  48617. * @param axisValue the value of the axis which determines the meshes new position
  48618. * @hidden
  48619. */
  48620. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48621. /**
  48622. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48623. * @param scene scene in which to add meshes
  48624. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48625. */
  48626. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48627. /**
  48628. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48629. * can be transformed by button presses and axes values, based on this._mapping.
  48630. *
  48631. * @param scene scene in which the meshes exist
  48632. * @param meshes list of meshes that make up the controller model to process
  48633. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48634. */
  48635. private processModel;
  48636. private createMeshInfo;
  48637. /**
  48638. * Gets the ray of the controller in the direction the controller is pointing
  48639. * @param length the length the resulting ray should be
  48640. * @returns a ray in the direction the controller is pointing
  48641. */
  48642. getForwardRay(length?: number): Ray;
  48643. /**
  48644. * Disposes of the controller
  48645. */
  48646. dispose(): void;
  48647. }
  48648. /**
  48649. * This class represents a new windows motion controller in XR.
  48650. */
  48651. export class XRWindowsMotionController extends WindowsMotionController {
  48652. /**
  48653. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48654. */
  48655. protected readonly _mapping: {
  48656. buttons: string[];
  48657. buttonMeshNames: {
  48658. trigger: string;
  48659. menu: string;
  48660. grip: string;
  48661. thumbstick: string;
  48662. trackpad: string;
  48663. };
  48664. buttonObservableNames: {
  48665. trigger: string;
  48666. menu: string;
  48667. grip: string;
  48668. thumbstick: string;
  48669. trackpad: string;
  48670. };
  48671. axisMeshNames: string[];
  48672. pointingPoseMeshName: string;
  48673. };
  48674. /**
  48675. * Construct a new XR-Based windows motion controller
  48676. *
  48677. * @param gamepadInfo the gamepad object from the browser
  48678. */
  48679. constructor(gamepadInfo: any);
  48680. /**
  48681. * holds the thumbstick values (X,Y)
  48682. */
  48683. thumbstickValues: StickValues;
  48684. /**
  48685. * Fired when the thumbstick on this controller is clicked
  48686. */
  48687. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48688. /**
  48689. * Fired when the thumbstick on this controller is modified
  48690. */
  48691. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48692. /**
  48693. * Fired when the touchpad button on this controller is modified
  48694. */
  48695. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48696. /**
  48697. * Fired when the touchpad values on this controller are modified
  48698. */
  48699. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48700. /**
  48701. * Fired when the thumbstick button on this controller is modified
  48702. * here to prevent breaking changes
  48703. */
  48704. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48705. /**
  48706. * updating the thumbstick(!) and not the trackpad.
  48707. * This is named this way due to the difference between WebVR and XR and to avoid
  48708. * changing the parent class.
  48709. */
  48710. protected _updateTrackpad(): void;
  48711. /**
  48712. * Disposes the class with joy
  48713. */
  48714. dispose(): void;
  48715. }
  48716. }
  48717. declare module BABYLON {
  48718. /**
  48719. * Class containing static functions to help procedurally build meshes
  48720. */
  48721. export class PolyhedronBuilder {
  48722. /**
  48723. * Creates a polyhedron mesh
  48724. * * 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
  48725. * * The parameter `size` (positive float, default 1) sets the polygon size
  48726. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48727. * * 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`
  48728. * * 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
  48729. * * 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)`)
  48730. * * 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
  48731. * * 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
  48732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48733. * * 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
  48734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48735. * @param name defines the name of the mesh
  48736. * @param options defines the options used to create the mesh
  48737. * @param scene defines the hosting scene
  48738. * @returns the polyhedron mesh
  48739. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48740. */
  48741. static CreatePolyhedron(name: string, options: {
  48742. type?: number;
  48743. size?: number;
  48744. sizeX?: number;
  48745. sizeY?: number;
  48746. sizeZ?: number;
  48747. custom?: any;
  48748. faceUV?: Vector4[];
  48749. faceColors?: Color4[];
  48750. flat?: boolean;
  48751. updatable?: boolean;
  48752. sideOrientation?: number;
  48753. frontUVs?: Vector4;
  48754. backUVs?: Vector4;
  48755. }, scene?: Nullable<Scene>): Mesh;
  48756. }
  48757. }
  48758. declare module BABYLON {
  48759. /**
  48760. * Gizmo that enables scaling a mesh along 3 axis
  48761. */
  48762. export class ScaleGizmo extends Gizmo {
  48763. /**
  48764. * Internal gizmo used for interactions on the x axis
  48765. */
  48766. xGizmo: AxisScaleGizmo;
  48767. /**
  48768. * Internal gizmo used for interactions on the y axis
  48769. */
  48770. yGizmo: AxisScaleGizmo;
  48771. /**
  48772. * Internal gizmo used for interactions on the z axis
  48773. */
  48774. zGizmo: AxisScaleGizmo;
  48775. /**
  48776. * Internal gizmo used to scale all axis equally
  48777. */
  48778. uniformScaleGizmo: AxisScaleGizmo;
  48779. private _meshAttached;
  48780. private _updateGizmoRotationToMatchAttachedMesh;
  48781. private _snapDistance;
  48782. private _scaleRatio;
  48783. private _uniformScalingMesh;
  48784. private _octahedron;
  48785. private _sensitivity;
  48786. /** Fires an event when any of it's sub gizmos are dragged */
  48787. onDragStartObservable: Observable<unknown>;
  48788. /** Fires an event when any of it's sub gizmos are released from dragging */
  48789. onDragEndObservable: Observable<unknown>;
  48790. get attachedMesh(): Nullable<AbstractMesh>;
  48791. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48792. /**
  48793. * Creates a ScaleGizmo
  48794. * @param gizmoLayer The utility layer the gizmo will be added to
  48795. */
  48796. constructor(gizmoLayer?: UtilityLayerRenderer);
  48797. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48798. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48799. /**
  48800. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48801. */
  48802. set snapDistance(value: number);
  48803. get snapDistance(): number;
  48804. /**
  48805. * Ratio for the scale of the gizmo (Default: 1)
  48806. */
  48807. set scaleRatio(value: number);
  48808. get scaleRatio(): number;
  48809. /**
  48810. * Sensitivity factor for dragging (Default: 1)
  48811. */
  48812. set sensitivity(value: number);
  48813. get sensitivity(): number;
  48814. /**
  48815. * Disposes of the gizmo
  48816. */
  48817. dispose(): void;
  48818. }
  48819. }
  48820. declare module BABYLON {
  48821. /**
  48822. * Single axis scale gizmo
  48823. */
  48824. export class AxisScaleGizmo extends Gizmo {
  48825. /**
  48826. * Drag behavior responsible for the gizmos dragging interactions
  48827. */
  48828. dragBehavior: PointerDragBehavior;
  48829. private _pointerObserver;
  48830. /**
  48831. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48832. */
  48833. snapDistance: number;
  48834. /**
  48835. * Event that fires each time the gizmo snaps to a new location.
  48836. * * snapDistance is the the change in distance
  48837. */
  48838. onSnapObservable: Observable<{
  48839. snapDistance: number;
  48840. }>;
  48841. /**
  48842. * If the scaling operation should be done on all axis (default: false)
  48843. */
  48844. uniformScaling: boolean;
  48845. /**
  48846. * Custom sensitivity value for the drag strength
  48847. */
  48848. sensitivity: number;
  48849. private _isEnabled;
  48850. private _parent;
  48851. private _arrow;
  48852. private _coloredMaterial;
  48853. private _hoverMaterial;
  48854. /**
  48855. * Creates an AxisScaleGizmo
  48856. * @param gizmoLayer The utility layer the gizmo will be added to
  48857. * @param dragAxis The axis which the gizmo will be able to scale on
  48858. * @param color The color of the gizmo
  48859. */
  48860. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48861. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48862. /**
  48863. * If the gizmo is enabled
  48864. */
  48865. set isEnabled(value: boolean);
  48866. get isEnabled(): boolean;
  48867. /**
  48868. * Disposes of the gizmo
  48869. */
  48870. dispose(): void;
  48871. /**
  48872. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48873. * @param mesh The mesh to replace the default mesh of the gizmo
  48874. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48875. */
  48876. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48877. }
  48878. }
  48879. declare module BABYLON {
  48880. /**
  48881. * Bounding box gizmo
  48882. */
  48883. export class BoundingBoxGizmo extends Gizmo {
  48884. private _lineBoundingBox;
  48885. private _rotateSpheresParent;
  48886. private _scaleBoxesParent;
  48887. private _boundingDimensions;
  48888. private _renderObserver;
  48889. private _pointerObserver;
  48890. private _scaleDragSpeed;
  48891. private _tmpQuaternion;
  48892. private _tmpVector;
  48893. private _tmpRotationMatrix;
  48894. /**
  48895. * 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)
  48896. */
  48897. ignoreChildren: boolean;
  48898. /**
  48899. * 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)
  48900. */
  48901. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48902. /**
  48903. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48904. */
  48905. rotationSphereSize: number;
  48906. /**
  48907. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48908. */
  48909. scaleBoxSize: number;
  48910. /**
  48911. * 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)
  48912. */
  48913. fixedDragMeshScreenSize: boolean;
  48914. /**
  48915. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48916. */
  48917. fixedDragMeshScreenSizeDistanceFactor: number;
  48918. /**
  48919. * Fired when a rotation sphere or scale box is dragged
  48920. */
  48921. onDragStartObservable: Observable<{}>;
  48922. /**
  48923. * Fired when a scale box is dragged
  48924. */
  48925. onScaleBoxDragObservable: Observable<{}>;
  48926. /**
  48927. * Fired when a scale box drag is ended
  48928. */
  48929. onScaleBoxDragEndObservable: Observable<{}>;
  48930. /**
  48931. * Fired when a rotation sphere is dragged
  48932. */
  48933. onRotationSphereDragObservable: Observable<{}>;
  48934. /**
  48935. * Fired when a rotation sphere drag is ended
  48936. */
  48937. onRotationSphereDragEndObservable: Observable<{}>;
  48938. /**
  48939. * 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)
  48940. */
  48941. scalePivot: Nullable<Vector3>;
  48942. /**
  48943. * Mesh used as a pivot to rotate the attached mesh
  48944. */
  48945. private _anchorMesh;
  48946. private _existingMeshScale;
  48947. private _dragMesh;
  48948. private pointerDragBehavior;
  48949. private coloredMaterial;
  48950. private hoverColoredMaterial;
  48951. /**
  48952. * Sets the color of the bounding box gizmo
  48953. * @param color the color to set
  48954. */
  48955. setColor(color: Color3): void;
  48956. /**
  48957. * Creates an BoundingBoxGizmo
  48958. * @param gizmoLayer The utility layer the gizmo will be added to
  48959. * @param color The color of the gizmo
  48960. */
  48961. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48962. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48963. private _selectNode;
  48964. /**
  48965. * Updates the bounding box information for the Gizmo
  48966. */
  48967. updateBoundingBox(): void;
  48968. private _updateRotationSpheres;
  48969. private _updateScaleBoxes;
  48970. /**
  48971. * Enables rotation on the specified axis and disables rotation on the others
  48972. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48973. */
  48974. setEnabledRotationAxis(axis: string): void;
  48975. /**
  48976. * Enables/disables scaling
  48977. * @param enable if scaling should be enabled
  48978. * @param homogeneousScaling defines if scaling should only be homogeneous
  48979. */
  48980. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  48981. private _updateDummy;
  48982. /**
  48983. * Enables a pointer drag behavior on the bounding box of the gizmo
  48984. */
  48985. enableDragBehavior(): void;
  48986. /**
  48987. * Disposes of the gizmo
  48988. */
  48989. dispose(): void;
  48990. /**
  48991. * 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)
  48992. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48993. * @returns the bounding box mesh with the passed in mesh as a child
  48994. */
  48995. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48996. /**
  48997. * CustomMeshes are not supported by this gizmo
  48998. * @param mesh The mesh to replace the default mesh of the gizmo
  48999. */
  49000. setCustomMesh(mesh: Mesh): void;
  49001. }
  49002. }
  49003. declare module BABYLON {
  49004. /**
  49005. * Single plane rotation gizmo
  49006. */
  49007. export class PlaneRotationGizmo extends Gizmo {
  49008. /**
  49009. * Drag behavior responsible for the gizmos dragging interactions
  49010. */
  49011. dragBehavior: PointerDragBehavior;
  49012. private _pointerObserver;
  49013. /**
  49014. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49015. */
  49016. snapDistance: number;
  49017. /**
  49018. * Event that fires each time the gizmo snaps to a new location.
  49019. * * snapDistance is the the change in distance
  49020. */
  49021. onSnapObservable: Observable<{
  49022. snapDistance: number;
  49023. }>;
  49024. private _isEnabled;
  49025. private _parent;
  49026. /**
  49027. * Creates a PlaneRotationGizmo
  49028. * @param gizmoLayer The utility layer the gizmo will be added to
  49029. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49030. * @param color The color of the gizmo
  49031. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49032. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49033. */
  49034. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49035. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49036. /**
  49037. * If the gizmo is enabled
  49038. */
  49039. set isEnabled(value: boolean);
  49040. get isEnabled(): boolean;
  49041. /**
  49042. * Disposes of the gizmo
  49043. */
  49044. dispose(): void;
  49045. }
  49046. }
  49047. declare module BABYLON {
  49048. /**
  49049. * Gizmo that enables rotating a mesh along 3 axis
  49050. */
  49051. export class RotationGizmo extends Gizmo {
  49052. /**
  49053. * Internal gizmo used for interactions on the x axis
  49054. */
  49055. xGizmo: PlaneRotationGizmo;
  49056. /**
  49057. * Internal gizmo used for interactions on the y axis
  49058. */
  49059. yGizmo: PlaneRotationGizmo;
  49060. /**
  49061. * Internal gizmo used for interactions on the z axis
  49062. */
  49063. zGizmo: PlaneRotationGizmo;
  49064. /** Fires an event when any of it's sub gizmos are dragged */
  49065. onDragStartObservable: Observable<unknown>;
  49066. /** Fires an event when any of it's sub gizmos are released from dragging */
  49067. onDragEndObservable: Observable<unknown>;
  49068. private _meshAttached;
  49069. get attachedMesh(): Nullable<AbstractMesh>;
  49070. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49071. /**
  49072. * Creates a RotationGizmo
  49073. * @param gizmoLayer The utility layer the gizmo will be added to
  49074. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49075. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49076. */
  49077. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49078. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49079. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49080. /**
  49081. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49082. */
  49083. set snapDistance(value: number);
  49084. get snapDistance(): number;
  49085. /**
  49086. * Ratio for the scale of the gizmo (Default: 1)
  49087. */
  49088. set scaleRatio(value: number);
  49089. get scaleRatio(): number;
  49090. /**
  49091. * Disposes of the gizmo
  49092. */
  49093. dispose(): void;
  49094. /**
  49095. * CustomMeshes are not supported by this gizmo
  49096. * @param mesh The mesh to replace the default mesh of the gizmo
  49097. */
  49098. setCustomMesh(mesh: Mesh): void;
  49099. }
  49100. }
  49101. declare module BABYLON {
  49102. /**
  49103. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49104. */
  49105. export class GizmoManager implements IDisposable {
  49106. private scene;
  49107. /**
  49108. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49109. */
  49110. gizmos: {
  49111. positionGizmo: Nullable<PositionGizmo>;
  49112. rotationGizmo: Nullable<RotationGizmo>;
  49113. scaleGizmo: Nullable<ScaleGizmo>;
  49114. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49115. };
  49116. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49117. clearGizmoOnEmptyPointerEvent: boolean;
  49118. /** Fires an event when the manager is attached to a mesh */
  49119. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49120. private _gizmosEnabled;
  49121. private _pointerObserver;
  49122. private _attachedMesh;
  49123. private _boundingBoxColor;
  49124. private _defaultUtilityLayer;
  49125. private _defaultKeepDepthUtilityLayer;
  49126. /**
  49127. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49128. */
  49129. boundingBoxDragBehavior: SixDofDragBehavior;
  49130. /**
  49131. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49132. */
  49133. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49134. /**
  49135. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49136. */
  49137. usePointerToAttachGizmos: boolean;
  49138. /**
  49139. * Utility layer that the bounding box gizmo belongs to
  49140. */
  49141. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49142. /**
  49143. * Utility layer that all gizmos besides bounding box belong to
  49144. */
  49145. get utilityLayer(): UtilityLayerRenderer;
  49146. /**
  49147. * Instatiates a gizmo manager
  49148. * @param scene the scene to overlay the gizmos on top of
  49149. */
  49150. constructor(scene: Scene);
  49151. /**
  49152. * Attaches a set of gizmos to the specified mesh
  49153. * @param mesh The mesh the gizmo's should be attached to
  49154. */
  49155. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49156. /**
  49157. * If the position gizmo is enabled
  49158. */
  49159. set positionGizmoEnabled(value: boolean);
  49160. get positionGizmoEnabled(): boolean;
  49161. /**
  49162. * If the rotation gizmo is enabled
  49163. */
  49164. set rotationGizmoEnabled(value: boolean);
  49165. get rotationGizmoEnabled(): boolean;
  49166. /**
  49167. * If the scale gizmo is enabled
  49168. */
  49169. set scaleGizmoEnabled(value: boolean);
  49170. get scaleGizmoEnabled(): boolean;
  49171. /**
  49172. * If the boundingBox gizmo is enabled
  49173. */
  49174. set boundingBoxGizmoEnabled(value: boolean);
  49175. get boundingBoxGizmoEnabled(): boolean;
  49176. /**
  49177. * Disposes of the gizmo manager
  49178. */
  49179. dispose(): void;
  49180. }
  49181. }
  49182. declare module BABYLON {
  49183. /**
  49184. * A directional light is defined by a direction (what a surprise!).
  49185. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49186. * 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.
  49187. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49188. */
  49189. export class DirectionalLight extends ShadowLight {
  49190. private _shadowFrustumSize;
  49191. /**
  49192. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49193. */
  49194. get shadowFrustumSize(): number;
  49195. /**
  49196. * Specifies a fix frustum size for the shadow generation.
  49197. */
  49198. set shadowFrustumSize(value: number);
  49199. private _shadowOrthoScale;
  49200. /**
  49201. * Gets the shadow projection scale against the optimal computed one.
  49202. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49203. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49204. */
  49205. get shadowOrthoScale(): number;
  49206. /**
  49207. * Sets the shadow projection scale against the optimal computed one.
  49208. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49209. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49210. */
  49211. set shadowOrthoScale(value: number);
  49212. /**
  49213. * Automatically compute the projection matrix to best fit (including all the casters)
  49214. * on each frame.
  49215. */
  49216. autoUpdateExtends: boolean;
  49217. /**
  49218. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49219. * on each frame. autoUpdateExtends must be set to true for this to work
  49220. */
  49221. autoCalcShadowZBounds: boolean;
  49222. private _orthoLeft;
  49223. private _orthoRight;
  49224. private _orthoTop;
  49225. private _orthoBottom;
  49226. /**
  49227. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49228. * The directional light is emitted from everywhere in the given direction.
  49229. * It can cast shadows.
  49230. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49231. * @param name The friendly name of the light
  49232. * @param direction The direction of the light
  49233. * @param scene The scene the light belongs to
  49234. */
  49235. constructor(name: string, direction: Vector3, scene: Scene);
  49236. /**
  49237. * Returns the string "DirectionalLight".
  49238. * @return The class name
  49239. */
  49240. getClassName(): string;
  49241. /**
  49242. * Returns the integer 1.
  49243. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49244. */
  49245. getTypeID(): number;
  49246. /**
  49247. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49248. * Returns the DirectionalLight Shadow projection matrix.
  49249. */
  49250. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49251. /**
  49252. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49253. * Returns the DirectionalLight Shadow projection matrix.
  49254. */
  49255. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49256. /**
  49257. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49258. * Returns the DirectionalLight Shadow projection matrix.
  49259. */
  49260. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49261. protected _buildUniformLayout(): void;
  49262. /**
  49263. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49264. * @param effect The effect to update
  49265. * @param lightIndex The index of the light in the effect to update
  49266. * @returns The directional light
  49267. */
  49268. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49269. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49270. /**
  49271. * Gets the minZ used for shadow according to both the scene and the light.
  49272. *
  49273. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49274. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49275. * @param activeCamera The camera we are returning the min for
  49276. * @returns the depth min z
  49277. */
  49278. getDepthMinZ(activeCamera: Camera): number;
  49279. /**
  49280. * Gets the maxZ used for shadow according to both the scene and the light.
  49281. *
  49282. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49283. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49284. * @param activeCamera The camera we are returning the max for
  49285. * @returns the depth max z
  49286. */
  49287. getDepthMaxZ(activeCamera: Camera): number;
  49288. /**
  49289. * Prepares the list of defines specific to the light type.
  49290. * @param defines the list of defines
  49291. * @param lightIndex defines the index of the light for the effect
  49292. */
  49293. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49294. }
  49295. }
  49296. declare module BABYLON {
  49297. /**
  49298. * Class containing static functions to help procedurally build meshes
  49299. */
  49300. export class HemisphereBuilder {
  49301. /**
  49302. * Creates a hemisphere mesh
  49303. * @param name defines the name of the mesh
  49304. * @param options defines the options used to create the mesh
  49305. * @param scene defines the hosting scene
  49306. * @returns the hemisphere mesh
  49307. */
  49308. static CreateHemisphere(name: string, options: {
  49309. segments?: number;
  49310. diameter?: number;
  49311. sideOrientation?: number;
  49312. }, scene: any): Mesh;
  49313. }
  49314. }
  49315. declare module BABYLON {
  49316. /**
  49317. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49318. * These values define a cone of light starting from the position, emitting toward the direction.
  49319. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49320. * and the exponent defines the speed of the decay of the light with distance (reach).
  49321. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49322. */
  49323. export class SpotLight extends ShadowLight {
  49324. private _angle;
  49325. private _innerAngle;
  49326. private _cosHalfAngle;
  49327. private _lightAngleScale;
  49328. private _lightAngleOffset;
  49329. /**
  49330. * Gets the cone angle of the spot light in Radians.
  49331. */
  49332. get angle(): number;
  49333. /**
  49334. * Sets the cone angle of the spot light in Radians.
  49335. */
  49336. set angle(value: number);
  49337. /**
  49338. * Only used in gltf falloff mode, this defines the angle where
  49339. * the directional falloff will start before cutting at angle which could be seen
  49340. * as outer angle.
  49341. */
  49342. get innerAngle(): number;
  49343. /**
  49344. * Only used in gltf falloff mode, this defines the angle where
  49345. * the directional falloff will start before cutting at angle which could be seen
  49346. * as outer angle.
  49347. */
  49348. set innerAngle(value: number);
  49349. private _shadowAngleScale;
  49350. /**
  49351. * Allows scaling the angle of the light for shadow generation only.
  49352. */
  49353. get shadowAngleScale(): number;
  49354. /**
  49355. * Allows scaling the angle of the light for shadow generation only.
  49356. */
  49357. set shadowAngleScale(value: number);
  49358. /**
  49359. * The light decay speed with the distance from the emission spot.
  49360. */
  49361. exponent: number;
  49362. private _projectionTextureMatrix;
  49363. /**
  49364. * Allows reading the projecton texture
  49365. */
  49366. get projectionTextureMatrix(): Matrix;
  49367. protected _projectionTextureLightNear: number;
  49368. /**
  49369. * Gets the near clip of the Spotlight for texture projection.
  49370. */
  49371. get projectionTextureLightNear(): number;
  49372. /**
  49373. * Sets the near clip of the Spotlight for texture projection.
  49374. */
  49375. set projectionTextureLightNear(value: number);
  49376. protected _projectionTextureLightFar: number;
  49377. /**
  49378. * Gets the far clip of the Spotlight for texture projection.
  49379. */
  49380. get projectionTextureLightFar(): number;
  49381. /**
  49382. * Sets the far clip of the Spotlight for texture projection.
  49383. */
  49384. set projectionTextureLightFar(value: number);
  49385. protected _projectionTextureUpDirection: Vector3;
  49386. /**
  49387. * Gets the Up vector of the Spotlight for texture projection.
  49388. */
  49389. get projectionTextureUpDirection(): Vector3;
  49390. /**
  49391. * Sets the Up vector of the Spotlight for texture projection.
  49392. */
  49393. set projectionTextureUpDirection(value: Vector3);
  49394. private _projectionTexture;
  49395. /**
  49396. * Gets the projection texture of the light.
  49397. */
  49398. get projectionTexture(): Nullable<BaseTexture>;
  49399. /**
  49400. * Sets the projection texture of the light.
  49401. */
  49402. set projectionTexture(value: Nullable<BaseTexture>);
  49403. private _projectionTextureViewLightDirty;
  49404. private _projectionTextureProjectionLightDirty;
  49405. private _projectionTextureDirty;
  49406. private _projectionTextureViewTargetVector;
  49407. private _projectionTextureViewLightMatrix;
  49408. private _projectionTextureProjectionLightMatrix;
  49409. private _projectionTextureScalingMatrix;
  49410. /**
  49411. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49412. * It can cast shadows.
  49413. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49414. * @param name The light friendly name
  49415. * @param position The position of the spot light in the scene
  49416. * @param direction The direction of the light in the scene
  49417. * @param angle The cone angle of the light in Radians
  49418. * @param exponent The light decay speed with the distance from the emission spot
  49419. * @param scene The scene the lights belongs to
  49420. */
  49421. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49422. /**
  49423. * Returns the string "SpotLight".
  49424. * @returns the class name
  49425. */
  49426. getClassName(): string;
  49427. /**
  49428. * Returns the integer 2.
  49429. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49430. */
  49431. getTypeID(): number;
  49432. /**
  49433. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49434. */
  49435. protected _setDirection(value: Vector3): void;
  49436. /**
  49437. * Overrides the position setter to recompute the projection texture view light Matrix.
  49438. */
  49439. protected _setPosition(value: Vector3): void;
  49440. /**
  49441. * 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.
  49442. * Returns the SpotLight.
  49443. */
  49444. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49445. protected _computeProjectionTextureViewLightMatrix(): void;
  49446. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49447. /**
  49448. * Main function for light texture projection matrix computing.
  49449. */
  49450. protected _computeProjectionTextureMatrix(): void;
  49451. protected _buildUniformLayout(): void;
  49452. private _computeAngleValues;
  49453. /**
  49454. * Sets the passed Effect "effect" with the Light textures.
  49455. * @param effect The effect to update
  49456. * @param lightIndex The index of the light in the effect to update
  49457. * @returns The light
  49458. */
  49459. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49460. /**
  49461. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49462. * @param effect The effect to update
  49463. * @param lightIndex The index of the light in the effect to update
  49464. * @returns The spot light
  49465. */
  49466. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49467. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49468. /**
  49469. * Disposes the light and the associated resources.
  49470. */
  49471. dispose(): void;
  49472. /**
  49473. * Prepares the list of defines specific to the light type.
  49474. * @param defines the list of defines
  49475. * @param lightIndex defines the index of the light for the effect
  49476. */
  49477. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49478. }
  49479. }
  49480. declare module BABYLON {
  49481. /**
  49482. * Gizmo that enables viewing a light
  49483. */
  49484. export class LightGizmo extends Gizmo {
  49485. private _lightMesh;
  49486. private _material;
  49487. private _cachedPosition;
  49488. private _cachedForward;
  49489. private _attachedMeshParent;
  49490. /**
  49491. * Creates a LightGizmo
  49492. * @param gizmoLayer The utility layer the gizmo will be added to
  49493. */
  49494. constructor(gizmoLayer?: UtilityLayerRenderer);
  49495. private _light;
  49496. /**
  49497. * The light that the gizmo is attached to
  49498. */
  49499. set light(light: Nullable<Light>);
  49500. get light(): Nullable<Light>;
  49501. /**
  49502. * Gets the material used to render the light gizmo
  49503. */
  49504. get material(): StandardMaterial;
  49505. /**
  49506. * @hidden
  49507. * Updates the gizmo to match the attached mesh's position/rotation
  49508. */
  49509. protected _update(): void;
  49510. private static _Scale;
  49511. /**
  49512. * Creates the lines for a light mesh
  49513. */
  49514. private static _CreateLightLines;
  49515. /**
  49516. * Disposes of the light gizmo
  49517. */
  49518. dispose(): void;
  49519. private static _CreateHemisphericLightMesh;
  49520. private static _CreatePointLightMesh;
  49521. private static _CreateSpotLightMesh;
  49522. private static _CreateDirectionalLightMesh;
  49523. }
  49524. }
  49525. declare module BABYLON {
  49526. /** @hidden */
  49527. export var backgroundFragmentDeclaration: {
  49528. name: string;
  49529. shader: string;
  49530. };
  49531. }
  49532. declare module BABYLON {
  49533. /** @hidden */
  49534. export var backgroundUboDeclaration: {
  49535. name: string;
  49536. shader: string;
  49537. };
  49538. }
  49539. declare module BABYLON {
  49540. /** @hidden */
  49541. export var backgroundPixelShader: {
  49542. name: string;
  49543. shader: string;
  49544. };
  49545. }
  49546. declare module BABYLON {
  49547. /** @hidden */
  49548. export var backgroundVertexDeclaration: {
  49549. name: string;
  49550. shader: string;
  49551. };
  49552. }
  49553. declare module BABYLON {
  49554. /** @hidden */
  49555. export var backgroundVertexShader: {
  49556. name: string;
  49557. shader: string;
  49558. };
  49559. }
  49560. declare module BABYLON {
  49561. /**
  49562. * Background material used to create an efficient environement around your scene.
  49563. */
  49564. export class BackgroundMaterial extends PushMaterial {
  49565. /**
  49566. * Standard reflectance value at parallel view angle.
  49567. */
  49568. static StandardReflectance0: number;
  49569. /**
  49570. * Standard reflectance value at grazing angle.
  49571. */
  49572. static StandardReflectance90: number;
  49573. protected _primaryColor: Color3;
  49574. /**
  49575. * Key light Color (multiply against the environement texture)
  49576. */
  49577. primaryColor: Color3;
  49578. protected __perceptualColor: Nullable<Color3>;
  49579. /**
  49580. * Experimental Internal Use Only.
  49581. *
  49582. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49583. * This acts as a helper to set the primary color to a more "human friendly" value.
  49584. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49585. * output color as close as possible from the chosen value.
  49586. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49587. * part of lighting setup.)
  49588. */
  49589. get _perceptualColor(): Nullable<Color3>;
  49590. set _perceptualColor(value: Nullable<Color3>);
  49591. protected _primaryColorShadowLevel: float;
  49592. /**
  49593. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49594. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49595. */
  49596. get primaryColorShadowLevel(): float;
  49597. set primaryColorShadowLevel(value: float);
  49598. protected _primaryColorHighlightLevel: float;
  49599. /**
  49600. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49601. * The primary color is used at the level chosen to define what the white area would look.
  49602. */
  49603. get primaryColorHighlightLevel(): float;
  49604. set primaryColorHighlightLevel(value: float);
  49605. protected _reflectionTexture: Nullable<BaseTexture>;
  49606. /**
  49607. * Reflection Texture used in the material.
  49608. * Should be author in a specific way for the best result (refer to the documentation).
  49609. */
  49610. reflectionTexture: Nullable<BaseTexture>;
  49611. protected _reflectionBlur: float;
  49612. /**
  49613. * Reflection Texture level of blur.
  49614. *
  49615. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49616. * texture twice.
  49617. */
  49618. reflectionBlur: float;
  49619. protected _diffuseTexture: Nullable<BaseTexture>;
  49620. /**
  49621. * Diffuse Texture used in the material.
  49622. * Should be author in a specific way for the best result (refer to the documentation).
  49623. */
  49624. diffuseTexture: Nullable<BaseTexture>;
  49625. protected _shadowLights: Nullable<IShadowLight[]>;
  49626. /**
  49627. * Specify the list of lights casting shadow on the material.
  49628. * All scene shadow lights will be included if null.
  49629. */
  49630. shadowLights: Nullable<IShadowLight[]>;
  49631. protected _shadowLevel: float;
  49632. /**
  49633. * Helps adjusting the shadow to a softer level if required.
  49634. * 0 means black shadows and 1 means no shadows.
  49635. */
  49636. shadowLevel: float;
  49637. protected _sceneCenter: Vector3;
  49638. /**
  49639. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49640. * It is usually zero but might be interesting to modify according to your setup.
  49641. */
  49642. sceneCenter: Vector3;
  49643. protected _opacityFresnel: boolean;
  49644. /**
  49645. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49646. * This helps ensuring a nice transition when the camera goes under the ground.
  49647. */
  49648. opacityFresnel: boolean;
  49649. protected _reflectionFresnel: boolean;
  49650. /**
  49651. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49652. * This helps adding a mirror texture on the ground.
  49653. */
  49654. reflectionFresnel: boolean;
  49655. protected _reflectionFalloffDistance: number;
  49656. /**
  49657. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49658. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49659. */
  49660. reflectionFalloffDistance: number;
  49661. protected _reflectionAmount: number;
  49662. /**
  49663. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49664. */
  49665. reflectionAmount: number;
  49666. protected _reflectionReflectance0: number;
  49667. /**
  49668. * This specifies the weight of the reflection at grazing angle.
  49669. */
  49670. reflectionReflectance0: number;
  49671. protected _reflectionReflectance90: number;
  49672. /**
  49673. * This specifies the weight of the reflection at a perpendicular point of view.
  49674. */
  49675. reflectionReflectance90: number;
  49676. /**
  49677. * Sets the reflection reflectance fresnel values according to the default standard
  49678. * empirically know to work well :-)
  49679. */
  49680. set reflectionStandardFresnelWeight(value: number);
  49681. protected _useRGBColor: boolean;
  49682. /**
  49683. * Helps to directly use the maps channels instead of their level.
  49684. */
  49685. useRGBColor: boolean;
  49686. protected _enableNoise: boolean;
  49687. /**
  49688. * This helps reducing the banding effect that could occur on the background.
  49689. */
  49690. enableNoise: boolean;
  49691. /**
  49692. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49693. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49694. * Recommended to be keep at 1.0 except for special cases.
  49695. */
  49696. get fovMultiplier(): number;
  49697. set fovMultiplier(value: number);
  49698. private _fovMultiplier;
  49699. /**
  49700. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49701. */
  49702. useEquirectangularFOV: boolean;
  49703. private _maxSimultaneousLights;
  49704. /**
  49705. * Number of Simultaneous lights allowed on the material.
  49706. */
  49707. maxSimultaneousLights: int;
  49708. /**
  49709. * Default configuration related to image processing available in the Background Material.
  49710. */
  49711. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49712. /**
  49713. * Keep track of the image processing observer to allow dispose and replace.
  49714. */
  49715. private _imageProcessingObserver;
  49716. /**
  49717. * Attaches a new image processing configuration to the PBR Material.
  49718. * @param configuration (if null the scene configuration will be use)
  49719. */
  49720. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49721. /**
  49722. * Gets the image processing configuration used either in this material.
  49723. */
  49724. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49725. /**
  49726. * Sets the Default image processing configuration used either in the this material.
  49727. *
  49728. * If sets to null, the scene one is in use.
  49729. */
  49730. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49731. /**
  49732. * Gets wether the color curves effect is enabled.
  49733. */
  49734. get cameraColorCurvesEnabled(): boolean;
  49735. /**
  49736. * Sets wether the color curves effect is enabled.
  49737. */
  49738. set cameraColorCurvesEnabled(value: boolean);
  49739. /**
  49740. * Gets wether the color grading effect is enabled.
  49741. */
  49742. get cameraColorGradingEnabled(): boolean;
  49743. /**
  49744. * Gets wether the color grading effect is enabled.
  49745. */
  49746. set cameraColorGradingEnabled(value: boolean);
  49747. /**
  49748. * Gets wether tonemapping is enabled or not.
  49749. */
  49750. get cameraToneMappingEnabled(): boolean;
  49751. /**
  49752. * Sets wether tonemapping is enabled or not
  49753. */
  49754. set cameraToneMappingEnabled(value: boolean);
  49755. /**
  49756. * The camera exposure used on this material.
  49757. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49758. * This corresponds to a photographic exposure.
  49759. */
  49760. get cameraExposure(): float;
  49761. /**
  49762. * The camera exposure used on this material.
  49763. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49764. * This corresponds to a photographic exposure.
  49765. */
  49766. set cameraExposure(value: float);
  49767. /**
  49768. * Gets The camera contrast used on this material.
  49769. */
  49770. get cameraContrast(): float;
  49771. /**
  49772. * Sets The camera contrast used on this material.
  49773. */
  49774. set cameraContrast(value: float);
  49775. /**
  49776. * Gets the Color Grading 2D Lookup Texture.
  49777. */
  49778. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49779. /**
  49780. * Sets the Color Grading 2D Lookup Texture.
  49781. */
  49782. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49783. /**
  49784. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49785. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49786. * 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;
  49787. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49788. */
  49789. get cameraColorCurves(): Nullable<ColorCurves>;
  49790. /**
  49791. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49792. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49793. * 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;
  49794. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49795. */
  49796. set cameraColorCurves(value: Nullable<ColorCurves>);
  49797. /**
  49798. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49799. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49800. */
  49801. switchToBGR: boolean;
  49802. private _renderTargets;
  49803. private _reflectionControls;
  49804. private _white;
  49805. private _primaryShadowColor;
  49806. private _primaryHighlightColor;
  49807. /**
  49808. * Instantiates a Background Material in the given scene
  49809. * @param name The friendly name of the material
  49810. * @param scene The scene to add the material to
  49811. */
  49812. constructor(name: string, scene: Scene);
  49813. /**
  49814. * Gets a boolean indicating that current material needs to register RTT
  49815. */
  49816. get hasRenderTargetTextures(): boolean;
  49817. /**
  49818. * The entire material has been created in order to prevent overdraw.
  49819. * @returns false
  49820. */
  49821. needAlphaTesting(): boolean;
  49822. /**
  49823. * The entire material has been created in order to prevent overdraw.
  49824. * @returns true if blending is enable
  49825. */
  49826. needAlphaBlending(): boolean;
  49827. /**
  49828. * Checks wether the material is ready to be rendered for a given mesh.
  49829. * @param mesh The mesh to render
  49830. * @param subMesh The submesh to check against
  49831. * @param useInstances Specify wether or not the material is used with instances
  49832. * @returns true if all the dependencies are ready (Textures, Effects...)
  49833. */
  49834. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49835. /**
  49836. * Compute the primary color according to the chosen perceptual color.
  49837. */
  49838. private _computePrimaryColorFromPerceptualColor;
  49839. /**
  49840. * Compute the highlights and shadow colors according to their chosen levels.
  49841. */
  49842. private _computePrimaryColors;
  49843. /**
  49844. * Build the uniform buffer used in the material.
  49845. */
  49846. buildUniformLayout(): void;
  49847. /**
  49848. * Unbind the material.
  49849. */
  49850. unbind(): void;
  49851. /**
  49852. * Bind only the world matrix to the material.
  49853. * @param world The world matrix to bind.
  49854. */
  49855. bindOnlyWorldMatrix(world: Matrix): void;
  49856. /**
  49857. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49858. * @param world The world matrix to bind.
  49859. * @param subMesh The submesh to bind for.
  49860. */
  49861. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49862. /**
  49863. * Checks to see if a texture is used in the material.
  49864. * @param texture - Base texture to use.
  49865. * @returns - Boolean specifying if a texture is used in the material.
  49866. */
  49867. hasTexture(texture: BaseTexture): boolean;
  49868. /**
  49869. * Dispose the material.
  49870. * @param forceDisposeEffect Force disposal of the associated effect.
  49871. * @param forceDisposeTextures Force disposal of the associated textures.
  49872. */
  49873. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49874. /**
  49875. * Clones the material.
  49876. * @param name The cloned name.
  49877. * @returns The cloned material.
  49878. */
  49879. clone(name: string): BackgroundMaterial;
  49880. /**
  49881. * Serializes the current material to its JSON representation.
  49882. * @returns The JSON representation.
  49883. */
  49884. serialize(): any;
  49885. /**
  49886. * Gets the class name of the material
  49887. * @returns "BackgroundMaterial"
  49888. */
  49889. getClassName(): string;
  49890. /**
  49891. * Parse a JSON input to create back a background material.
  49892. * @param source The JSON data to parse
  49893. * @param scene The scene to create the parsed material in
  49894. * @param rootUrl The root url of the assets the material depends upon
  49895. * @returns the instantiated BackgroundMaterial.
  49896. */
  49897. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49898. }
  49899. }
  49900. declare module BABYLON {
  49901. /**
  49902. * Represents the different options available during the creation of
  49903. * a Environment helper.
  49904. *
  49905. * This can control the default ground, skybox and image processing setup of your scene.
  49906. */
  49907. export interface IEnvironmentHelperOptions {
  49908. /**
  49909. * Specifies whether or not to create a ground.
  49910. * True by default.
  49911. */
  49912. createGround: boolean;
  49913. /**
  49914. * Specifies the ground size.
  49915. * 15 by default.
  49916. */
  49917. groundSize: number;
  49918. /**
  49919. * The texture used on the ground for the main color.
  49920. * Comes from the BabylonJS CDN by default.
  49921. *
  49922. * Remarks: Can be either a texture or a url.
  49923. */
  49924. groundTexture: string | BaseTexture;
  49925. /**
  49926. * The color mixed in the ground texture by default.
  49927. * BabylonJS clearColor by default.
  49928. */
  49929. groundColor: Color3;
  49930. /**
  49931. * Specifies the ground opacity.
  49932. * 1 by default.
  49933. */
  49934. groundOpacity: number;
  49935. /**
  49936. * Enables the ground to receive shadows.
  49937. * True by default.
  49938. */
  49939. enableGroundShadow: boolean;
  49940. /**
  49941. * Helps preventing the shadow to be fully black on the ground.
  49942. * 0.5 by default.
  49943. */
  49944. groundShadowLevel: number;
  49945. /**
  49946. * Creates a mirror texture attach to the ground.
  49947. * false by default.
  49948. */
  49949. enableGroundMirror: boolean;
  49950. /**
  49951. * Specifies the ground mirror size ratio.
  49952. * 0.3 by default as the default kernel is 64.
  49953. */
  49954. groundMirrorSizeRatio: number;
  49955. /**
  49956. * Specifies the ground mirror blur kernel size.
  49957. * 64 by default.
  49958. */
  49959. groundMirrorBlurKernel: number;
  49960. /**
  49961. * Specifies the ground mirror visibility amount.
  49962. * 1 by default
  49963. */
  49964. groundMirrorAmount: number;
  49965. /**
  49966. * Specifies the ground mirror reflectance weight.
  49967. * This uses the standard weight of the background material to setup the fresnel effect
  49968. * of the mirror.
  49969. * 1 by default.
  49970. */
  49971. groundMirrorFresnelWeight: number;
  49972. /**
  49973. * Specifies the ground mirror Falloff distance.
  49974. * This can helps reducing the size of the reflection.
  49975. * 0 by Default.
  49976. */
  49977. groundMirrorFallOffDistance: number;
  49978. /**
  49979. * Specifies the ground mirror texture type.
  49980. * Unsigned Int by Default.
  49981. */
  49982. groundMirrorTextureType: number;
  49983. /**
  49984. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49985. * the shown objects.
  49986. */
  49987. groundYBias: number;
  49988. /**
  49989. * Specifies whether or not to create a skybox.
  49990. * True by default.
  49991. */
  49992. createSkybox: boolean;
  49993. /**
  49994. * Specifies the skybox size.
  49995. * 20 by default.
  49996. */
  49997. skyboxSize: number;
  49998. /**
  49999. * The texture used on the skybox for the main color.
  50000. * Comes from the BabylonJS CDN by default.
  50001. *
  50002. * Remarks: Can be either a texture or a url.
  50003. */
  50004. skyboxTexture: string | BaseTexture;
  50005. /**
  50006. * The color mixed in the skybox texture by default.
  50007. * BabylonJS clearColor by default.
  50008. */
  50009. skyboxColor: Color3;
  50010. /**
  50011. * The background rotation around the Y axis of the scene.
  50012. * This helps aligning the key lights of your scene with the background.
  50013. * 0 by default.
  50014. */
  50015. backgroundYRotation: number;
  50016. /**
  50017. * Compute automatically the size of the elements to best fit with the scene.
  50018. */
  50019. sizeAuto: boolean;
  50020. /**
  50021. * Default position of the rootMesh if autoSize is not true.
  50022. */
  50023. rootPosition: Vector3;
  50024. /**
  50025. * Sets up the image processing in the scene.
  50026. * true by default.
  50027. */
  50028. setupImageProcessing: boolean;
  50029. /**
  50030. * The texture used as your environment texture in the scene.
  50031. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50032. *
  50033. * Remarks: Can be either a texture or a url.
  50034. */
  50035. environmentTexture: string | BaseTexture;
  50036. /**
  50037. * The value of the exposure to apply to the scene.
  50038. * 0.6 by default if setupImageProcessing is true.
  50039. */
  50040. cameraExposure: number;
  50041. /**
  50042. * The value of the contrast to apply to the scene.
  50043. * 1.6 by default if setupImageProcessing is true.
  50044. */
  50045. cameraContrast: number;
  50046. /**
  50047. * Specifies whether or not tonemapping should be enabled in the scene.
  50048. * true by default if setupImageProcessing is true.
  50049. */
  50050. toneMappingEnabled: boolean;
  50051. }
  50052. /**
  50053. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50054. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50055. * It also helps with the default setup of your imageProcessing configuration.
  50056. */
  50057. export class EnvironmentHelper {
  50058. /**
  50059. * Default ground texture URL.
  50060. */
  50061. private static _groundTextureCDNUrl;
  50062. /**
  50063. * Default skybox texture URL.
  50064. */
  50065. private static _skyboxTextureCDNUrl;
  50066. /**
  50067. * Default environment texture URL.
  50068. */
  50069. private static _environmentTextureCDNUrl;
  50070. /**
  50071. * Creates the default options for the helper.
  50072. */
  50073. private static _getDefaultOptions;
  50074. private _rootMesh;
  50075. /**
  50076. * Gets the root mesh created by the helper.
  50077. */
  50078. get rootMesh(): Mesh;
  50079. private _skybox;
  50080. /**
  50081. * Gets the skybox created by the helper.
  50082. */
  50083. get skybox(): Nullable<Mesh>;
  50084. private _skyboxTexture;
  50085. /**
  50086. * Gets the skybox texture created by the helper.
  50087. */
  50088. get skyboxTexture(): Nullable<BaseTexture>;
  50089. private _skyboxMaterial;
  50090. /**
  50091. * Gets the skybox material created by the helper.
  50092. */
  50093. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50094. private _ground;
  50095. /**
  50096. * Gets the ground mesh created by the helper.
  50097. */
  50098. get ground(): Nullable<Mesh>;
  50099. private _groundTexture;
  50100. /**
  50101. * Gets the ground texture created by the helper.
  50102. */
  50103. get groundTexture(): Nullable<BaseTexture>;
  50104. private _groundMirror;
  50105. /**
  50106. * Gets the ground mirror created by the helper.
  50107. */
  50108. get groundMirror(): Nullable<MirrorTexture>;
  50109. /**
  50110. * Gets the ground mirror render list to helps pushing the meshes
  50111. * you wish in the ground reflection.
  50112. */
  50113. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50114. private _groundMaterial;
  50115. /**
  50116. * Gets the ground material created by the helper.
  50117. */
  50118. get groundMaterial(): Nullable<BackgroundMaterial>;
  50119. /**
  50120. * Stores the creation options.
  50121. */
  50122. private readonly _scene;
  50123. private _options;
  50124. /**
  50125. * This observable will be notified with any error during the creation of the environment,
  50126. * mainly texture creation errors.
  50127. */
  50128. onErrorObservable: Observable<{
  50129. message?: string;
  50130. exception?: any;
  50131. }>;
  50132. /**
  50133. * constructor
  50134. * @param options Defines the options we want to customize the helper
  50135. * @param scene The scene to add the material to
  50136. */
  50137. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50138. /**
  50139. * Updates the background according to the new options
  50140. * @param options
  50141. */
  50142. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50143. /**
  50144. * Sets the primary color of all the available elements.
  50145. * @param color the main color to affect to the ground and the background
  50146. */
  50147. setMainColor(color: Color3): void;
  50148. /**
  50149. * Setup the image processing according to the specified options.
  50150. */
  50151. private _setupImageProcessing;
  50152. /**
  50153. * Setup the environment texture according to the specified options.
  50154. */
  50155. private _setupEnvironmentTexture;
  50156. /**
  50157. * Setup the background according to the specified options.
  50158. */
  50159. private _setupBackground;
  50160. /**
  50161. * Get the scene sizes according to the setup.
  50162. */
  50163. private _getSceneSize;
  50164. /**
  50165. * Setup the ground according to the specified options.
  50166. */
  50167. private _setupGround;
  50168. /**
  50169. * Setup the ground material according to the specified options.
  50170. */
  50171. private _setupGroundMaterial;
  50172. /**
  50173. * Setup the ground diffuse texture according to the specified options.
  50174. */
  50175. private _setupGroundDiffuseTexture;
  50176. /**
  50177. * Setup the ground mirror texture according to the specified options.
  50178. */
  50179. private _setupGroundMirrorTexture;
  50180. /**
  50181. * Setup the ground to receive the mirror texture.
  50182. */
  50183. private _setupMirrorInGroundMaterial;
  50184. /**
  50185. * Setup the skybox according to the specified options.
  50186. */
  50187. private _setupSkybox;
  50188. /**
  50189. * Setup the skybox material according to the specified options.
  50190. */
  50191. private _setupSkyboxMaterial;
  50192. /**
  50193. * Setup the skybox reflection texture according to the specified options.
  50194. */
  50195. private _setupSkyboxReflectionTexture;
  50196. private _errorHandler;
  50197. /**
  50198. * Dispose all the elements created by the Helper.
  50199. */
  50200. dispose(): void;
  50201. }
  50202. }
  50203. declare module BABYLON {
  50204. /**
  50205. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50206. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50207. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50208. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50209. */
  50210. export class PhotoDome extends TransformNode {
  50211. /**
  50212. * Define the image as a Monoscopic panoramic 360 image.
  50213. */
  50214. static readonly MODE_MONOSCOPIC: number;
  50215. /**
  50216. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50217. */
  50218. static readonly MODE_TOPBOTTOM: number;
  50219. /**
  50220. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50221. */
  50222. static readonly MODE_SIDEBYSIDE: number;
  50223. private _useDirectMapping;
  50224. /**
  50225. * The texture being displayed on the sphere
  50226. */
  50227. protected _photoTexture: Texture;
  50228. /**
  50229. * Gets or sets the texture being displayed on the sphere
  50230. */
  50231. get photoTexture(): Texture;
  50232. set photoTexture(value: Texture);
  50233. /**
  50234. * Observable raised when an error occured while loading the 360 image
  50235. */
  50236. onLoadErrorObservable: Observable<string>;
  50237. /**
  50238. * The skybox material
  50239. */
  50240. protected _material: BackgroundMaterial;
  50241. /**
  50242. * The surface used for the skybox
  50243. */
  50244. protected _mesh: Mesh;
  50245. /**
  50246. * Gets the mesh used for the skybox.
  50247. */
  50248. get mesh(): Mesh;
  50249. /**
  50250. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50251. * Also see the options.resolution property.
  50252. */
  50253. get fovMultiplier(): number;
  50254. set fovMultiplier(value: number);
  50255. private _imageMode;
  50256. /**
  50257. * Gets or set the current video mode for the video. It can be:
  50258. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50259. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50260. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50261. */
  50262. get imageMode(): number;
  50263. set imageMode(value: number);
  50264. /**
  50265. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50266. * @param name Element's name, child elements will append suffixes for their own names.
  50267. * @param urlsOfPhoto defines the url of the photo to display
  50268. * @param options defines an object containing optional or exposed sub element properties
  50269. * @param onError defines a callback called when an error occured while loading the texture
  50270. */
  50271. constructor(name: string, urlOfPhoto: string, options: {
  50272. resolution?: number;
  50273. size?: number;
  50274. useDirectMapping?: boolean;
  50275. faceForward?: boolean;
  50276. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50277. private _onBeforeCameraRenderObserver;
  50278. private _changeImageMode;
  50279. /**
  50280. * Releases resources associated with this node.
  50281. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50282. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50283. */
  50284. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50285. }
  50286. }
  50287. declare module BABYLON {
  50288. /**
  50289. * Class used to host RGBD texture specific utilities
  50290. */
  50291. export class RGBDTextureTools {
  50292. /**
  50293. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50294. * @param texture the texture to expand.
  50295. */
  50296. static ExpandRGBDTexture(texture: Texture): void;
  50297. }
  50298. }
  50299. declare module BABYLON {
  50300. /**
  50301. * Class used to host texture specific utilities
  50302. */
  50303. export class BRDFTextureTools {
  50304. /**
  50305. * Prevents texture cache collision
  50306. */
  50307. private static _instanceNumber;
  50308. /**
  50309. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50310. * @param scene defines the hosting scene
  50311. * @returns the environment BRDF texture
  50312. */
  50313. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50314. private static _environmentBRDFBase64Texture;
  50315. }
  50316. }
  50317. declare module BABYLON {
  50318. /**
  50319. * @hidden
  50320. */
  50321. export interface IMaterialClearCoatDefines {
  50322. CLEARCOAT: boolean;
  50323. CLEARCOAT_DEFAULTIOR: boolean;
  50324. CLEARCOAT_TEXTURE: boolean;
  50325. CLEARCOAT_TEXTUREDIRECTUV: number;
  50326. CLEARCOAT_BUMP: boolean;
  50327. CLEARCOAT_BUMPDIRECTUV: number;
  50328. CLEARCOAT_TINT: boolean;
  50329. CLEARCOAT_TINT_TEXTURE: boolean;
  50330. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50331. /** @hidden */
  50332. _areTexturesDirty: boolean;
  50333. }
  50334. /**
  50335. * Define the code related to the clear coat parameters of the pbr material.
  50336. */
  50337. export class PBRClearCoatConfiguration {
  50338. /**
  50339. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50340. * The default fits with a polyurethane material.
  50341. */
  50342. private static readonly _DefaultIndexOfRefraction;
  50343. private _isEnabled;
  50344. /**
  50345. * Defines if the clear coat is enabled in the material.
  50346. */
  50347. isEnabled: boolean;
  50348. /**
  50349. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50350. */
  50351. intensity: number;
  50352. /**
  50353. * Defines the clear coat layer roughness.
  50354. */
  50355. roughness: number;
  50356. private _indexOfRefraction;
  50357. /**
  50358. * Defines the index of refraction of the clear coat.
  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. * Changing the default value is more performance intensive.
  50362. */
  50363. indexOfRefraction: number;
  50364. private _texture;
  50365. /**
  50366. * Stores the clear coat values in a texture.
  50367. */
  50368. texture: Nullable<BaseTexture>;
  50369. private _bumpTexture;
  50370. /**
  50371. * Define the clear coat specific bump texture.
  50372. */
  50373. bumpTexture: Nullable<BaseTexture>;
  50374. private _isTintEnabled;
  50375. /**
  50376. * Defines if the clear coat tint is enabled in the material.
  50377. */
  50378. isTintEnabled: boolean;
  50379. /**
  50380. * Defines the clear coat tint of the material.
  50381. * This is only use if tint is enabled
  50382. */
  50383. tintColor: Color3;
  50384. /**
  50385. * Defines the distance at which the tint color should be found in the
  50386. * clear coat media.
  50387. * This is only use if tint is enabled
  50388. */
  50389. tintColorAtDistance: number;
  50390. /**
  50391. * Defines the clear coat layer thickness.
  50392. * This is only use if tint is enabled
  50393. */
  50394. tintThickness: number;
  50395. private _tintTexture;
  50396. /**
  50397. * Stores the clear tint values in a texture.
  50398. * rgb is tint
  50399. * a is a thickness factor
  50400. */
  50401. tintTexture: Nullable<BaseTexture>;
  50402. /** @hidden */
  50403. private _internalMarkAllSubMeshesAsTexturesDirty;
  50404. /** @hidden */
  50405. _markAllSubMeshesAsTexturesDirty(): void;
  50406. /**
  50407. * Instantiate a new istance of clear coat configuration.
  50408. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50409. */
  50410. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50411. /**
  50412. * Gets wehter the submesh is ready to be used or not.
  50413. * @param defines the list of "defines" to update.
  50414. * @param scene defines the scene the material belongs to.
  50415. * @param engine defines the engine the material belongs to.
  50416. * @param disableBumpMap defines wether the material disables bump or not.
  50417. * @returns - boolean indicating that the submesh is ready or not.
  50418. */
  50419. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50420. /**
  50421. * Checks to see if a texture is used in the material.
  50422. * @param defines the list of "defines" to update.
  50423. * @param scene defines the scene to the material belongs to.
  50424. */
  50425. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50426. /**
  50427. * Binds the material data.
  50428. * @param uniformBuffer defines the Uniform buffer to fill in.
  50429. * @param scene defines the scene the material belongs to.
  50430. * @param engine defines the engine the material belongs to.
  50431. * @param disableBumpMap defines wether the material disables bump or not.
  50432. * @param isFrozen defines wether the material is frozen or not.
  50433. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50434. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50435. */
  50436. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50437. /**
  50438. * Checks to see if a texture is used in the material.
  50439. * @param texture - Base texture to use.
  50440. * @returns - Boolean specifying if a texture is used in the material.
  50441. */
  50442. hasTexture(texture: BaseTexture): boolean;
  50443. /**
  50444. * Returns an array of the actively used textures.
  50445. * @param activeTextures Array of BaseTextures
  50446. */
  50447. getActiveTextures(activeTextures: BaseTexture[]): void;
  50448. /**
  50449. * Returns the animatable textures.
  50450. * @param animatables Array of animatable textures.
  50451. */
  50452. getAnimatables(animatables: IAnimatable[]): void;
  50453. /**
  50454. * Disposes the resources of the material.
  50455. * @param forceDisposeTextures - Forces the disposal of all textures.
  50456. */
  50457. dispose(forceDisposeTextures?: boolean): void;
  50458. /**
  50459. * Get the current class name of the texture useful for serialization or dynamic coding.
  50460. * @returns "PBRClearCoatConfiguration"
  50461. */
  50462. getClassName(): string;
  50463. /**
  50464. * Add fallbacks to the effect fallbacks list.
  50465. * @param defines defines the Base texture to use.
  50466. * @param fallbacks defines the current fallback list.
  50467. * @param currentRank defines the current fallback rank.
  50468. * @returns the new fallback rank.
  50469. */
  50470. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50471. /**
  50472. * Add the required uniforms to the current list.
  50473. * @param uniforms defines the current uniform list.
  50474. */
  50475. static AddUniforms(uniforms: string[]): void;
  50476. /**
  50477. * Add the required samplers to the current list.
  50478. * @param samplers defines the current sampler list.
  50479. */
  50480. static AddSamplers(samplers: string[]): void;
  50481. /**
  50482. * Add the required uniforms to the current buffer.
  50483. * @param uniformBuffer defines the current uniform buffer.
  50484. */
  50485. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50486. /**
  50487. * Makes a duplicate of the current configuration into another one.
  50488. * @param clearCoatConfiguration define the config where to copy the info
  50489. */
  50490. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50491. /**
  50492. * Serializes this clear coat configuration.
  50493. * @returns - An object with the serialized config.
  50494. */
  50495. serialize(): any;
  50496. /**
  50497. * Parses a anisotropy Configuration from a serialized object.
  50498. * @param source - Serialized object.
  50499. * @param scene Defines the scene we are parsing for
  50500. * @param rootUrl Defines the rootUrl to load from
  50501. */
  50502. parse(source: any, scene: Scene, rootUrl: string): void;
  50503. }
  50504. }
  50505. declare module BABYLON {
  50506. /**
  50507. * @hidden
  50508. */
  50509. export interface IMaterialAnisotropicDefines {
  50510. ANISOTROPIC: boolean;
  50511. ANISOTROPIC_TEXTURE: boolean;
  50512. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50513. MAINUV1: boolean;
  50514. _areTexturesDirty: boolean;
  50515. _needUVs: boolean;
  50516. }
  50517. /**
  50518. * Define the code related to the anisotropic parameters of the pbr material.
  50519. */
  50520. export class PBRAnisotropicConfiguration {
  50521. private _isEnabled;
  50522. /**
  50523. * Defines if the anisotropy is enabled in the material.
  50524. */
  50525. isEnabled: boolean;
  50526. /**
  50527. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50528. */
  50529. intensity: number;
  50530. /**
  50531. * Defines if the effect is along the tangents, bitangents or in between.
  50532. * By default, the effect is "strectching" the highlights along the tangents.
  50533. */
  50534. direction: Vector2;
  50535. private _texture;
  50536. /**
  50537. * Stores the anisotropy values in a texture.
  50538. * rg is direction (like normal from -1 to 1)
  50539. * b is a intensity
  50540. */
  50541. texture: Nullable<BaseTexture>;
  50542. /** @hidden */
  50543. private _internalMarkAllSubMeshesAsTexturesDirty;
  50544. /** @hidden */
  50545. _markAllSubMeshesAsTexturesDirty(): void;
  50546. /**
  50547. * Instantiate a new istance of anisotropy configuration.
  50548. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50549. */
  50550. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50551. /**
  50552. * Specifies that the submesh is ready to be used.
  50553. * @param defines the list of "defines" to update.
  50554. * @param scene defines the scene the material belongs to.
  50555. * @returns - boolean indicating that the submesh is ready or not.
  50556. */
  50557. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50558. /**
  50559. * Checks to see if a texture is used in the material.
  50560. * @param defines the list of "defines" to update.
  50561. * @param mesh the mesh we are preparing the defines for.
  50562. * @param scene defines the scene the material belongs to.
  50563. */
  50564. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50565. /**
  50566. * Binds the material data.
  50567. * @param uniformBuffer defines the Uniform buffer to fill in.
  50568. * @param scene defines the scene the material belongs to.
  50569. * @param isFrozen defines wether the material is frozen or not.
  50570. */
  50571. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50572. /**
  50573. * Checks to see if a texture is used in the material.
  50574. * @param texture - Base texture to use.
  50575. * @returns - Boolean specifying if a texture is used in the material.
  50576. */
  50577. hasTexture(texture: BaseTexture): boolean;
  50578. /**
  50579. * Returns an array of the actively used textures.
  50580. * @param activeTextures Array of BaseTextures
  50581. */
  50582. getActiveTextures(activeTextures: BaseTexture[]): void;
  50583. /**
  50584. * Returns the animatable textures.
  50585. * @param animatables Array of animatable textures.
  50586. */
  50587. getAnimatables(animatables: IAnimatable[]): void;
  50588. /**
  50589. * Disposes the resources of the material.
  50590. * @param forceDisposeTextures - Forces the disposal of all textures.
  50591. */
  50592. dispose(forceDisposeTextures?: boolean): void;
  50593. /**
  50594. * Get the current class name of the texture useful for serialization or dynamic coding.
  50595. * @returns "PBRAnisotropicConfiguration"
  50596. */
  50597. getClassName(): string;
  50598. /**
  50599. * Add fallbacks to the effect fallbacks list.
  50600. * @param defines defines the Base texture to use.
  50601. * @param fallbacks defines the current fallback list.
  50602. * @param currentRank defines the current fallback rank.
  50603. * @returns the new fallback rank.
  50604. */
  50605. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50606. /**
  50607. * Add the required uniforms to the current list.
  50608. * @param uniforms defines the current uniform list.
  50609. */
  50610. static AddUniforms(uniforms: string[]): void;
  50611. /**
  50612. * Add the required uniforms to the current buffer.
  50613. * @param uniformBuffer defines the current uniform buffer.
  50614. */
  50615. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50616. /**
  50617. * Add the required samplers to the current list.
  50618. * @param samplers defines the current sampler list.
  50619. */
  50620. static AddSamplers(samplers: string[]): void;
  50621. /**
  50622. * Makes a duplicate of the current configuration into another one.
  50623. * @param anisotropicConfiguration define the config where to copy the info
  50624. */
  50625. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50626. /**
  50627. * Serializes this anisotropy configuration.
  50628. * @returns - An object with the serialized config.
  50629. */
  50630. serialize(): any;
  50631. /**
  50632. * Parses a anisotropy Configuration from a serialized object.
  50633. * @param source - Serialized object.
  50634. * @param scene Defines the scene we are parsing for
  50635. * @param rootUrl Defines the rootUrl to load from
  50636. */
  50637. parse(source: any, scene: Scene, rootUrl: string): void;
  50638. }
  50639. }
  50640. declare module BABYLON {
  50641. /**
  50642. * @hidden
  50643. */
  50644. export interface IMaterialBRDFDefines {
  50645. BRDF_V_HEIGHT_CORRELATED: boolean;
  50646. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50647. SPHERICAL_HARMONICS: boolean;
  50648. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50649. /** @hidden */
  50650. _areMiscDirty: boolean;
  50651. }
  50652. /**
  50653. * Define the code related to the BRDF parameters of the pbr material.
  50654. */
  50655. export class PBRBRDFConfiguration {
  50656. /**
  50657. * Default value used for the energy conservation.
  50658. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50659. */
  50660. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50661. /**
  50662. * Default value used for the Smith Visibility Height Correlated mode.
  50663. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50664. */
  50665. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50666. /**
  50667. * Default value used for the IBL diffuse part.
  50668. * This can help switching back to the polynomials mode globally which is a tiny bit
  50669. * less GPU intensive at the drawback of a lower quality.
  50670. */
  50671. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50672. /**
  50673. * Default value used for activating energy conservation for the specular workflow.
  50674. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50675. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50676. */
  50677. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50678. private _useEnergyConservation;
  50679. /**
  50680. * Defines if the material uses energy conservation.
  50681. */
  50682. useEnergyConservation: boolean;
  50683. private _useSmithVisibilityHeightCorrelated;
  50684. /**
  50685. * LEGACY Mode set to false
  50686. * Defines if the material uses height smith correlated visibility term.
  50687. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50688. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50689. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50690. * Not relying on height correlated will also disable energy conservation.
  50691. */
  50692. useSmithVisibilityHeightCorrelated: boolean;
  50693. private _useSphericalHarmonics;
  50694. /**
  50695. * LEGACY Mode set to false
  50696. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50697. * diffuse part of the IBL.
  50698. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50699. * to the ground truth.
  50700. */
  50701. useSphericalHarmonics: boolean;
  50702. private _useSpecularGlossinessInputEnergyConservation;
  50703. /**
  50704. * Defines if the material uses energy conservation, when the specular workflow is active.
  50705. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50706. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50707. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50708. */
  50709. useSpecularGlossinessInputEnergyConservation: boolean;
  50710. /** @hidden */
  50711. private _internalMarkAllSubMeshesAsMiscDirty;
  50712. /** @hidden */
  50713. _markAllSubMeshesAsMiscDirty(): void;
  50714. /**
  50715. * Instantiate a new istance of clear coat configuration.
  50716. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50717. */
  50718. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50719. /**
  50720. * Checks to see if a texture is used in the material.
  50721. * @param defines the list of "defines" to update.
  50722. */
  50723. prepareDefines(defines: IMaterialBRDFDefines): void;
  50724. /**
  50725. * Get the current class name of the texture useful for serialization or dynamic coding.
  50726. * @returns "PBRClearCoatConfiguration"
  50727. */
  50728. getClassName(): string;
  50729. /**
  50730. * Makes a duplicate of the current configuration into another one.
  50731. * @param brdfConfiguration define the config where to copy the info
  50732. */
  50733. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50734. /**
  50735. * Serializes this BRDF configuration.
  50736. * @returns - An object with the serialized config.
  50737. */
  50738. serialize(): any;
  50739. /**
  50740. * Parses a anisotropy Configuration from a serialized object.
  50741. * @param source - Serialized object.
  50742. * @param scene Defines the scene we are parsing for
  50743. * @param rootUrl Defines the rootUrl to load from
  50744. */
  50745. parse(source: any, scene: Scene, rootUrl: string): void;
  50746. }
  50747. }
  50748. declare module BABYLON {
  50749. /**
  50750. * @hidden
  50751. */
  50752. export interface IMaterialSheenDefines {
  50753. SHEEN: boolean;
  50754. SHEEN_TEXTURE: boolean;
  50755. SHEEN_TEXTUREDIRECTUV: number;
  50756. SHEEN_LINKWITHALBEDO: boolean;
  50757. SHEEN_ROUGHNESS: boolean;
  50758. SHEEN_ALBEDOSCALING: boolean;
  50759. /** @hidden */
  50760. _areTexturesDirty: boolean;
  50761. }
  50762. /**
  50763. * Define the code related to the Sheen parameters of the pbr material.
  50764. */
  50765. export class PBRSheenConfiguration {
  50766. private _isEnabled;
  50767. /**
  50768. * Defines if the material uses sheen.
  50769. */
  50770. isEnabled: boolean;
  50771. private _linkSheenWithAlbedo;
  50772. /**
  50773. * Defines if the sheen is linked to the sheen color.
  50774. */
  50775. linkSheenWithAlbedo: boolean;
  50776. /**
  50777. * Defines the sheen intensity.
  50778. */
  50779. intensity: number;
  50780. /**
  50781. * Defines the sheen color.
  50782. */
  50783. color: Color3;
  50784. private _texture;
  50785. /**
  50786. * Stores the sheen tint values in a texture.
  50787. * rgb is tint
  50788. * a is a intensity
  50789. */
  50790. texture: Nullable<BaseTexture>;
  50791. private _roughness;
  50792. /**
  50793. * Defines the sheen roughness.
  50794. * It is not taken into account if linkSheenWithAlbedo is true.
  50795. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50796. */
  50797. roughness: Nullable<number>;
  50798. private _albedoScaling;
  50799. /**
  50800. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50801. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50802. * making it easier to setup and tweak the effect
  50803. */
  50804. albedoScaling: boolean;
  50805. /** @hidden */
  50806. private _internalMarkAllSubMeshesAsTexturesDirty;
  50807. /** @hidden */
  50808. _markAllSubMeshesAsTexturesDirty(): void;
  50809. /**
  50810. * Instantiate a new istance of clear coat configuration.
  50811. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50812. */
  50813. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50814. /**
  50815. * Specifies that the submesh is ready to be used.
  50816. * @param defines the list of "defines" to update.
  50817. * @param scene defines the scene the material belongs to.
  50818. * @returns - boolean indicating that the submesh is ready or not.
  50819. */
  50820. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50821. /**
  50822. * Checks to see if a texture is used in the material.
  50823. * @param defines the list of "defines" to update.
  50824. * @param scene defines the scene the material belongs to.
  50825. */
  50826. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50827. /**
  50828. * Binds the material data.
  50829. * @param uniformBuffer defines the Uniform buffer to fill in.
  50830. * @param scene defines the scene the material belongs to.
  50831. * @param isFrozen defines wether the material is frozen or not.
  50832. */
  50833. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50834. /**
  50835. * Checks to see if a texture is used in the material.
  50836. * @param texture - Base texture to use.
  50837. * @returns - Boolean specifying if a texture is used in the material.
  50838. */
  50839. hasTexture(texture: BaseTexture): boolean;
  50840. /**
  50841. * Returns an array of the actively used textures.
  50842. * @param activeTextures Array of BaseTextures
  50843. */
  50844. getActiveTextures(activeTextures: BaseTexture[]): void;
  50845. /**
  50846. * Returns the animatable textures.
  50847. * @param animatables Array of animatable textures.
  50848. */
  50849. getAnimatables(animatables: IAnimatable[]): void;
  50850. /**
  50851. * Disposes the resources of the material.
  50852. * @param forceDisposeTextures - Forces the disposal of all textures.
  50853. */
  50854. dispose(forceDisposeTextures?: boolean): void;
  50855. /**
  50856. * Get the current class name of the texture useful for serialization or dynamic coding.
  50857. * @returns "PBRSheenConfiguration"
  50858. */
  50859. getClassName(): string;
  50860. /**
  50861. * Add fallbacks to the effect fallbacks list.
  50862. * @param defines defines the Base texture to use.
  50863. * @param fallbacks defines the current fallback list.
  50864. * @param currentRank defines the current fallback rank.
  50865. * @returns the new fallback rank.
  50866. */
  50867. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50868. /**
  50869. * Add the required uniforms to the current list.
  50870. * @param uniforms defines the current uniform list.
  50871. */
  50872. static AddUniforms(uniforms: string[]): void;
  50873. /**
  50874. * Add the required uniforms to the current buffer.
  50875. * @param uniformBuffer defines the current uniform buffer.
  50876. */
  50877. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50878. /**
  50879. * Add the required samplers to the current list.
  50880. * @param samplers defines the current sampler list.
  50881. */
  50882. static AddSamplers(samplers: string[]): void;
  50883. /**
  50884. * Makes a duplicate of the current configuration into another one.
  50885. * @param sheenConfiguration define the config where to copy the info
  50886. */
  50887. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50888. /**
  50889. * Serializes this BRDF configuration.
  50890. * @returns - An object with the serialized config.
  50891. */
  50892. serialize(): any;
  50893. /**
  50894. * Parses a anisotropy Configuration from a serialized object.
  50895. * @param source - Serialized object.
  50896. * @param scene Defines the scene we are parsing for
  50897. * @param rootUrl Defines the rootUrl to load from
  50898. */
  50899. parse(source: any, scene: Scene, rootUrl: string): void;
  50900. }
  50901. }
  50902. declare module BABYLON {
  50903. /**
  50904. * @hidden
  50905. */
  50906. export interface IMaterialSubSurfaceDefines {
  50907. SUBSURFACE: boolean;
  50908. SS_REFRACTION: boolean;
  50909. SS_TRANSLUCENCY: boolean;
  50910. SS_SCATERRING: boolean;
  50911. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50912. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50913. SS_REFRACTIONMAP_3D: boolean;
  50914. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50915. SS_LODINREFRACTIONALPHA: boolean;
  50916. SS_GAMMAREFRACTION: boolean;
  50917. SS_RGBDREFRACTION: boolean;
  50918. SS_LINEARSPECULARREFRACTION: boolean;
  50919. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50920. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50921. /** @hidden */
  50922. _areTexturesDirty: boolean;
  50923. }
  50924. /**
  50925. * Define the code related to the sub surface parameters of the pbr material.
  50926. */
  50927. export class PBRSubSurfaceConfiguration {
  50928. private _isRefractionEnabled;
  50929. /**
  50930. * Defines if the refraction is enabled in the material.
  50931. */
  50932. isRefractionEnabled: boolean;
  50933. private _isTranslucencyEnabled;
  50934. /**
  50935. * Defines if the translucency is enabled in the material.
  50936. */
  50937. isTranslucencyEnabled: boolean;
  50938. private _isScatteringEnabled;
  50939. /**
  50940. * Defines the refraction intensity of the material.
  50941. * The refraction when enabled replaces the Diffuse part of the material.
  50942. * The intensity helps transitionning between diffuse and refraction.
  50943. */
  50944. refractionIntensity: number;
  50945. /**
  50946. * Defines the translucency intensity of the material.
  50947. * When translucency has been enabled, this defines how much of the "translucency"
  50948. * is addded to the diffuse part of the material.
  50949. */
  50950. translucencyIntensity: number;
  50951. /**
  50952. * Defines the scattering intensity of the material.
  50953. * When scattering has been enabled, this defines how much of the "scattered light"
  50954. * is addded to the diffuse part of the material.
  50955. */
  50956. scatteringIntensity: number;
  50957. private _thicknessTexture;
  50958. /**
  50959. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50960. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50961. * 0 would mean minimumThickness
  50962. * 1 would mean maximumThickness
  50963. * The other channels might be use as a mask to vary the different effects intensity.
  50964. */
  50965. thicknessTexture: Nullable<BaseTexture>;
  50966. private _refractionTexture;
  50967. /**
  50968. * Defines the texture to use for refraction.
  50969. */
  50970. refractionTexture: Nullable<BaseTexture>;
  50971. private _indexOfRefraction;
  50972. /**
  50973. * Defines the index of refraction used in the material.
  50974. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50975. */
  50976. indexOfRefraction: number;
  50977. private _invertRefractionY;
  50978. /**
  50979. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50980. */
  50981. invertRefractionY: boolean;
  50982. private _linkRefractionWithTransparency;
  50983. /**
  50984. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50985. * Materials half opaque for instance using refraction could benefit from this control.
  50986. */
  50987. linkRefractionWithTransparency: boolean;
  50988. /**
  50989. * Defines the minimum thickness stored in the thickness map.
  50990. * If no thickness map is defined, this value will be used to simulate thickness.
  50991. */
  50992. minimumThickness: number;
  50993. /**
  50994. * Defines the maximum thickness stored in the thickness map.
  50995. */
  50996. maximumThickness: number;
  50997. /**
  50998. * Defines the volume tint of the material.
  50999. * This is used for both translucency and scattering.
  51000. */
  51001. tintColor: Color3;
  51002. /**
  51003. * Defines the distance at which the tint color should be found in the media.
  51004. * This is used for refraction only.
  51005. */
  51006. tintColorAtDistance: number;
  51007. /**
  51008. * Defines how far each channel transmit through the media.
  51009. * It is defined as a color to simplify it selection.
  51010. */
  51011. diffusionDistance: Color3;
  51012. private _useMaskFromThicknessTexture;
  51013. /**
  51014. * Stores the intensity of the different subsurface effects in the thickness texture.
  51015. * * the green channel is the translucency intensity.
  51016. * * the blue channel is the scattering intensity.
  51017. * * the alpha channel is the refraction intensity.
  51018. */
  51019. useMaskFromThicknessTexture: boolean;
  51020. /** @hidden */
  51021. private _internalMarkAllSubMeshesAsTexturesDirty;
  51022. /** @hidden */
  51023. _markAllSubMeshesAsTexturesDirty(): void;
  51024. /**
  51025. * Instantiate a new istance of sub surface configuration.
  51026. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51027. */
  51028. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51029. /**
  51030. * Gets wehter the submesh is ready to be used or not.
  51031. * @param defines the list of "defines" to update.
  51032. * @param scene defines the scene the material belongs to.
  51033. * @returns - boolean indicating that the submesh is ready or not.
  51034. */
  51035. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51036. /**
  51037. * Checks to see if a texture is used in the material.
  51038. * @param defines the list of "defines" to update.
  51039. * @param scene defines the scene to the material belongs to.
  51040. */
  51041. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51042. /**
  51043. * Binds the material data.
  51044. * @param uniformBuffer defines the Uniform buffer to fill in.
  51045. * @param scene defines the scene the material belongs to.
  51046. * @param engine defines the engine the material belongs to.
  51047. * @param isFrozen defines wether the material is frozen or not.
  51048. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51049. */
  51050. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51051. /**
  51052. * Unbinds the material from the mesh.
  51053. * @param activeEffect defines the effect that should be unbound from.
  51054. * @returns true if unbound, otherwise false
  51055. */
  51056. unbind(activeEffect: Effect): boolean;
  51057. /**
  51058. * Returns the texture used for refraction or null if none is used.
  51059. * @param scene defines the scene the material belongs to.
  51060. * @returns - Refraction texture if present. If no refraction texture and refraction
  51061. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51062. */
  51063. private _getRefractionTexture;
  51064. /**
  51065. * Returns true if alpha blending should be disabled.
  51066. */
  51067. get disableAlphaBlending(): boolean;
  51068. /**
  51069. * Fills the list of render target textures.
  51070. * @param renderTargets the list of render targets to update
  51071. */
  51072. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51073. /**
  51074. * Checks to see if a texture is used in the material.
  51075. * @param texture - Base texture to use.
  51076. * @returns - Boolean specifying if a texture is used in the material.
  51077. */
  51078. hasTexture(texture: BaseTexture): boolean;
  51079. /**
  51080. * Gets a boolean indicating that current material needs to register RTT
  51081. * @returns true if this uses a render target otherwise false.
  51082. */
  51083. hasRenderTargetTextures(): boolean;
  51084. /**
  51085. * Returns an array of the actively used textures.
  51086. * @param activeTextures Array of BaseTextures
  51087. */
  51088. getActiveTextures(activeTextures: BaseTexture[]): void;
  51089. /**
  51090. * Returns the animatable textures.
  51091. * @param animatables Array of animatable textures.
  51092. */
  51093. getAnimatables(animatables: IAnimatable[]): void;
  51094. /**
  51095. * Disposes the resources of the material.
  51096. * @param forceDisposeTextures - Forces the disposal of all textures.
  51097. */
  51098. dispose(forceDisposeTextures?: boolean): void;
  51099. /**
  51100. * Get the current class name of the texture useful for serialization or dynamic coding.
  51101. * @returns "PBRSubSurfaceConfiguration"
  51102. */
  51103. getClassName(): string;
  51104. /**
  51105. * Add fallbacks to the effect fallbacks list.
  51106. * @param defines defines the Base texture to use.
  51107. * @param fallbacks defines the current fallback list.
  51108. * @param currentRank defines the current fallback rank.
  51109. * @returns the new fallback rank.
  51110. */
  51111. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51112. /**
  51113. * Add the required uniforms to the current list.
  51114. * @param uniforms defines the current uniform list.
  51115. */
  51116. static AddUniforms(uniforms: string[]): void;
  51117. /**
  51118. * Add the required samplers to the current list.
  51119. * @param samplers defines the current sampler list.
  51120. */
  51121. static AddSamplers(samplers: string[]): void;
  51122. /**
  51123. * Add the required uniforms to the current buffer.
  51124. * @param uniformBuffer defines the current uniform buffer.
  51125. */
  51126. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51127. /**
  51128. * Makes a duplicate of the current configuration into another one.
  51129. * @param configuration define the config where to copy the info
  51130. */
  51131. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51132. /**
  51133. * Serializes this Sub Surface configuration.
  51134. * @returns - An object with the serialized config.
  51135. */
  51136. serialize(): any;
  51137. /**
  51138. * Parses a anisotropy Configuration from a serialized object.
  51139. * @param source - Serialized object.
  51140. * @param scene Defines the scene we are parsing for
  51141. * @param rootUrl Defines the rootUrl to load from
  51142. */
  51143. parse(source: any, scene: Scene, rootUrl: string): void;
  51144. }
  51145. }
  51146. declare module BABYLON {
  51147. /** @hidden */
  51148. export var pbrFragmentDeclaration: {
  51149. name: string;
  51150. shader: string;
  51151. };
  51152. }
  51153. declare module BABYLON {
  51154. /** @hidden */
  51155. export var pbrUboDeclaration: {
  51156. name: string;
  51157. shader: string;
  51158. };
  51159. }
  51160. declare module BABYLON {
  51161. /** @hidden */
  51162. export var pbrFragmentExtraDeclaration: {
  51163. name: string;
  51164. shader: string;
  51165. };
  51166. }
  51167. declare module BABYLON {
  51168. /** @hidden */
  51169. export var pbrFragmentSamplersDeclaration: {
  51170. name: string;
  51171. shader: string;
  51172. };
  51173. }
  51174. declare module BABYLON {
  51175. /** @hidden */
  51176. export var pbrHelperFunctions: {
  51177. name: string;
  51178. shader: string;
  51179. };
  51180. }
  51181. declare module BABYLON {
  51182. /** @hidden */
  51183. export var harmonicsFunctions: {
  51184. name: string;
  51185. shader: string;
  51186. };
  51187. }
  51188. declare module BABYLON {
  51189. /** @hidden */
  51190. export var pbrDirectLightingSetupFunctions: {
  51191. name: string;
  51192. shader: string;
  51193. };
  51194. }
  51195. declare module BABYLON {
  51196. /** @hidden */
  51197. export var pbrDirectLightingFalloffFunctions: {
  51198. name: string;
  51199. shader: string;
  51200. };
  51201. }
  51202. declare module BABYLON {
  51203. /** @hidden */
  51204. export var pbrBRDFFunctions: {
  51205. name: string;
  51206. shader: string;
  51207. };
  51208. }
  51209. declare module BABYLON {
  51210. /** @hidden */
  51211. export var pbrDirectLightingFunctions: {
  51212. name: string;
  51213. shader: string;
  51214. };
  51215. }
  51216. declare module BABYLON {
  51217. /** @hidden */
  51218. export var pbrIBLFunctions: {
  51219. name: string;
  51220. shader: string;
  51221. };
  51222. }
  51223. declare module BABYLON {
  51224. /** @hidden */
  51225. export var pbrBlockAlbedoOpacity: {
  51226. name: string;
  51227. shader: string;
  51228. };
  51229. }
  51230. declare module BABYLON {
  51231. /** @hidden */
  51232. export var pbrBlockReflectivity: {
  51233. name: string;
  51234. shader: string;
  51235. };
  51236. }
  51237. declare module BABYLON {
  51238. /** @hidden */
  51239. export var pbrBlockAmbientOcclusion: {
  51240. name: string;
  51241. shader: string;
  51242. };
  51243. }
  51244. declare module BABYLON {
  51245. /** @hidden */
  51246. export var pbrBlockAlphaFresnel: {
  51247. name: string;
  51248. shader: string;
  51249. };
  51250. }
  51251. declare module BABYLON {
  51252. /** @hidden */
  51253. export var pbrBlockAnisotropic: {
  51254. name: string;
  51255. shader: string;
  51256. };
  51257. }
  51258. declare module BABYLON {
  51259. /** @hidden */
  51260. export var pbrBlockReflection: {
  51261. name: string;
  51262. shader: string;
  51263. };
  51264. }
  51265. declare module BABYLON {
  51266. /** @hidden */
  51267. export var pbrBlockSheen: {
  51268. name: string;
  51269. shader: string;
  51270. };
  51271. }
  51272. declare module BABYLON {
  51273. /** @hidden */
  51274. export var pbrBlockClearcoat: {
  51275. name: string;
  51276. shader: string;
  51277. };
  51278. }
  51279. declare module BABYLON {
  51280. /** @hidden */
  51281. export var pbrBlockSubSurface: {
  51282. name: string;
  51283. shader: string;
  51284. };
  51285. }
  51286. declare module BABYLON {
  51287. /** @hidden */
  51288. export var pbrBlockNormalGeometric: {
  51289. name: string;
  51290. shader: string;
  51291. };
  51292. }
  51293. declare module BABYLON {
  51294. /** @hidden */
  51295. export var pbrBlockNormalFinal: {
  51296. name: string;
  51297. shader: string;
  51298. };
  51299. }
  51300. declare module BABYLON {
  51301. /** @hidden */
  51302. export var pbrBlockGeometryInfo: {
  51303. name: string;
  51304. shader: string;
  51305. };
  51306. }
  51307. declare module BABYLON {
  51308. /** @hidden */
  51309. export var pbrBlockReflectance0: {
  51310. name: string;
  51311. shader: string;
  51312. };
  51313. }
  51314. declare module BABYLON {
  51315. /** @hidden */
  51316. export var pbrBlockReflectance: {
  51317. name: string;
  51318. shader: string;
  51319. };
  51320. }
  51321. declare module BABYLON {
  51322. /** @hidden */
  51323. export var pbrBlockDirectLighting: {
  51324. name: string;
  51325. shader: string;
  51326. };
  51327. }
  51328. declare module BABYLON {
  51329. /** @hidden */
  51330. export var pbrBlockFinalLitComponents: {
  51331. name: string;
  51332. shader: string;
  51333. };
  51334. }
  51335. declare module BABYLON {
  51336. /** @hidden */
  51337. export var pbrBlockFinalUnlitComponents: {
  51338. name: string;
  51339. shader: string;
  51340. };
  51341. }
  51342. declare module BABYLON {
  51343. /** @hidden */
  51344. export var pbrBlockFinalColorComposition: {
  51345. name: string;
  51346. shader: string;
  51347. };
  51348. }
  51349. declare module BABYLON {
  51350. /** @hidden */
  51351. export var pbrBlockImageProcessing: {
  51352. name: string;
  51353. shader: string;
  51354. };
  51355. }
  51356. declare module BABYLON {
  51357. /** @hidden */
  51358. export var pbrDebug: {
  51359. name: string;
  51360. shader: string;
  51361. };
  51362. }
  51363. declare module BABYLON {
  51364. /** @hidden */
  51365. export var pbrPixelShader: {
  51366. name: string;
  51367. shader: string;
  51368. };
  51369. }
  51370. declare module BABYLON {
  51371. /** @hidden */
  51372. export var pbrVertexDeclaration: {
  51373. name: string;
  51374. shader: string;
  51375. };
  51376. }
  51377. declare module BABYLON {
  51378. /** @hidden */
  51379. export var pbrVertexShader: {
  51380. name: string;
  51381. shader: string;
  51382. };
  51383. }
  51384. declare module BABYLON {
  51385. /**
  51386. * Manages the defines for the PBR Material.
  51387. * @hidden
  51388. */
  51389. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51390. PBR: boolean;
  51391. MAINUV1: boolean;
  51392. MAINUV2: boolean;
  51393. UV1: boolean;
  51394. UV2: boolean;
  51395. ALBEDO: boolean;
  51396. GAMMAALBEDO: boolean;
  51397. ALBEDODIRECTUV: number;
  51398. VERTEXCOLOR: boolean;
  51399. AMBIENT: boolean;
  51400. AMBIENTDIRECTUV: number;
  51401. AMBIENTINGRAYSCALE: boolean;
  51402. OPACITY: boolean;
  51403. VERTEXALPHA: boolean;
  51404. OPACITYDIRECTUV: number;
  51405. OPACITYRGB: boolean;
  51406. ALPHATEST: boolean;
  51407. DEPTHPREPASS: boolean;
  51408. ALPHABLEND: boolean;
  51409. ALPHAFROMALBEDO: boolean;
  51410. ALPHATESTVALUE: string;
  51411. SPECULAROVERALPHA: boolean;
  51412. RADIANCEOVERALPHA: boolean;
  51413. ALPHAFRESNEL: boolean;
  51414. LINEARALPHAFRESNEL: boolean;
  51415. PREMULTIPLYALPHA: boolean;
  51416. EMISSIVE: boolean;
  51417. EMISSIVEDIRECTUV: number;
  51418. REFLECTIVITY: boolean;
  51419. REFLECTIVITYDIRECTUV: number;
  51420. SPECULARTERM: boolean;
  51421. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51422. MICROSURFACEAUTOMATIC: boolean;
  51423. LODBASEDMICROSFURACE: boolean;
  51424. MICROSURFACEMAP: boolean;
  51425. MICROSURFACEMAPDIRECTUV: number;
  51426. METALLICWORKFLOW: boolean;
  51427. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51428. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51429. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51430. AOSTOREINMETALMAPRED: boolean;
  51431. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51432. ENVIRONMENTBRDF: boolean;
  51433. ENVIRONMENTBRDF_RGBD: boolean;
  51434. NORMAL: boolean;
  51435. TANGENT: boolean;
  51436. BUMP: boolean;
  51437. BUMPDIRECTUV: number;
  51438. OBJECTSPACE_NORMALMAP: boolean;
  51439. PARALLAX: boolean;
  51440. PARALLAXOCCLUSION: boolean;
  51441. NORMALXYSCALE: boolean;
  51442. LIGHTMAP: boolean;
  51443. LIGHTMAPDIRECTUV: number;
  51444. USELIGHTMAPASSHADOWMAP: boolean;
  51445. GAMMALIGHTMAP: boolean;
  51446. RGBDLIGHTMAP: boolean;
  51447. REFLECTION: boolean;
  51448. REFLECTIONMAP_3D: boolean;
  51449. REFLECTIONMAP_SPHERICAL: boolean;
  51450. REFLECTIONMAP_PLANAR: boolean;
  51451. REFLECTIONMAP_CUBIC: boolean;
  51452. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51453. REFLECTIONMAP_PROJECTION: boolean;
  51454. REFLECTIONMAP_SKYBOX: boolean;
  51455. REFLECTIONMAP_EXPLICIT: boolean;
  51456. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51457. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51458. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51459. INVERTCUBICMAP: boolean;
  51460. USESPHERICALFROMREFLECTIONMAP: boolean;
  51461. USEIRRADIANCEMAP: boolean;
  51462. SPHERICAL_HARMONICS: boolean;
  51463. USESPHERICALINVERTEX: boolean;
  51464. REFLECTIONMAP_OPPOSITEZ: boolean;
  51465. LODINREFLECTIONALPHA: boolean;
  51466. GAMMAREFLECTION: boolean;
  51467. RGBDREFLECTION: boolean;
  51468. LINEARSPECULARREFLECTION: boolean;
  51469. RADIANCEOCCLUSION: boolean;
  51470. HORIZONOCCLUSION: boolean;
  51471. INSTANCES: boolean;
  51472. NUM_BONE_INFLUENCERS: number;
  51473. BonesPerMesh: number;
  51474. BONETEXTURE: boolean;
  51475. NONUNIFORMSCALING: boolean;
  51476. MORPHTARGETS: boolean;
  51477. MORPHTARGETS_NORMAL: boolean;
  51478. MORPHTARGETS_TANGENT: boolean;
  51479. MORPHTARGETS_UV: boolean;
  51480. NUM_MORPH_INFLUENCERS: number;
  51481. IMAGEPROCESSING: boolean;
  51482. VIGNETTE: boolean;
  51483. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51484. VIGNETTEBLENDMODEOPAQUE: boolean;
  51485. TONEMAPPING: boolean;
  51486. TONEMAPPING_ACES: boolean;
  51487. CONTRAST: boolean;
  51488. COLORCURVES: boolean;
  51489. COLORGRADING: boolean;
  51490. COLORGRADING3D: boolean;
  51491. SAMPLER3DGREENDEPTH: boolean;
  51492. SAMPLER3DBGRMAP: boolean;
  51493. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51494. EXPOSURE: boolean;
  51495. MULTIVIEW: boolean;
  51496. USEPHYSICALLIGHTFALLOFF: boolean;
  51497. USEGLTFLIGHTFALLOFF: boolean;
  51498. TWOSIDEDLIGHTING: boolean;
  51499. SHADOWFLOAT: boolean;
  51500. CLIPPLANE: boolean;
  51501. CLIPPLANE2: boolean;
  51502. CLIPPLANE3: boolean;
  51503. CLIPPLANE4: boolean;
  51504. CLIPPLANE5: boolean;
  51505. CLIPPLANE6: boolean;
  51506. POINTSIZE: boolean;
  51507. FOG: boolean;
  51508. LOGARITHMICDEPTH: boolean;
  51509. FORCENORMALFORWARD: boolean;
  51510. SPECULARAA: boolean;
  51511. CLEARCOAT: boolean;
  51512. CLEARCOAT_DEFAULTIOR: boolean;
  51513. CLEARCOAT_TEXTURE: boolean;
  51514. CLEARCOAT_TEXTUREDIRECTUV: number;
  51515. CLEARCOAT_BUMP: boolean;
  51516. CLEARCOAT_BUMPDIRECTUV: number;
  51517. CLEARCOAT_TINT: boolean;
  51518. CLEARCOAT_TINT_TEXTURE: boolean;
  51519. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51520. ANISOTROPIC: boolean;
  51521. ANISOTROPIC_TEXTURE: boolean;
  51522. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51523. BRDF_V_HEIGHT_CORRELATED: boolean;
  51524. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51525. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51526. SHEEN: boolean;
  51527. SHEEN_TEXTURE: boolean;
  51528. SHEEN_TEXTUREDIRECTUV: number;
  51529. SHEEN_LINKWITHALBEDO: boolean;
  51530. SHEEN_ROUGHNESS: boolean;
  51531. SHEEN_ALBEDOSCALING: boolean;
  51532. SUBSURFACE: boolean;
  51533. SS_REFRACTION: boolean;
  51534. SS_TRANSLUCENCY: boolean;
  51535. SS_SCATERRING: boolean;
  51536. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51537. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51538. SS_REFRACTIONMAP_3D: boolean;
  51539. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51540. SS_LODINREFRACTIONALPHA: boolean;
  51541. SS_GAMMAREFRACTION: boolean;
  51542. SS_RGBDREFRACTION: boolean;
  51543. SS_LINEARSPECULARREFRACTION: boolean;
  51544. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51545. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51546. UNLIT: boolean;
  51547. DEBUGMODE: number;
  51548. /**
  51549. * Initializes the PBR Material defines.
  51550. */
  51551. constructor();
  51552. /**
  51553. * Resets the PBR Material defines.
  51554. */
  51555. reset(): void;
  51556. }
  51557. /**
  51558. * The Physically based material base class of BJS.
  51559. *
  51560. * This offers the main features of a standard PBR material.
  51561. * For more information, please refer to the documentation :
  51562. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51563. */
  51564. export abstract class PBRBaseMaterial extends PushMaterial {
  51565. /**
  51566. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51567. */
  51568. static readonly PBRMATERIAL_OPAQUE: number;
  51569. /**
  51570. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51571. */
  51572. static readonly PBRMATERIAL_ALPHATEST: number;
  51573. /**
  51574. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51575. */
  51576. static readonly PBRMATERIAL_ALPHABLEND: number;
  51577. /**
  51578. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51579. * They are also discarded below the alpha cutoff threshold to improve performances.
  51580. */
  51581. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51582. /**
  51583. * Defines the default value of how much AO map is occluding the analytical lights
  51584. * (point spot...).
  51585. */
  51586. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51587. /**
  51588. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51589. */
  51590. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51591. /**
  51592. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51593. * to enhance interoperability with other engines.
  51594. */
  51595. static readonly LIGHTFALLOFF_GLTF: number;
  51596. /**
  51597. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51598. * to enhance interoperability with other materials.
  51599. */
  51600. static readonly LIGHTFALLOFF_STANDARD: number;
  51601. /**
  51602. * Intensity of the direct lights e.g. the four lights available in your scene.
  51603. * This impacts both the direct diffuse and specular highlights.
  51604. */
  51605. protected _directIntensity: number;
  51606. /**
  51607. * Intensity of the emissive part of the material.
  51608. * This helps controlling the emissive effect without modifying the emissive color.
  51609. */
  51610. protected _emissiveIntensity: number;
  51611. /**
  51612. * Intensity of the environment e.g. how much the environment will light the object
  51613. * either through harmonics for rough material or through the refelction for shiny ones.
  51614. */
  51615. protected _environmentIntensity: number;
  51616. /**
  51617. * This is a special control allowing the reduction of the specular highlights coming from the
  51618. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51619. */
  51620. protected _specularIntensity: number;
  51621. /**
  51622. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51623. */
  51624. private _lightingInfos;
  51625. /**
  51626. * Debug Control allowing disabling the bump map on this material.
  51627. */
  51628. protected _disableBumpMap: boolean;
  51629. /**
  51630. * AKA Diffuse Texture in standard nomenclature.
  51631. */
  51632. protected _albedoTexture: Nullable<BaseTexture>;
  51633. /**
  51634. * AKA Occlusion Texture in other nomenclature.
  51635. */
  51636. protected _ambientTexture: Nullable<BaseTexture>;
  51637. /**
  51638. * AKA Occlusion Texture Intensity in other nomenclature.
  51639. */
  51640. protected _ambientTextureStrength: number;
  51641. /**
  51642. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51643. * 1 means it completely occludes it
  51644. * 0 mean it has no impact
  51645. */
  51646. protected _ambientTextureImpactOnAnalyticalLights: number;
  51647. /**
  51648. * Stores the alpha values in a texture.
  51649. */
  51650. protected _opacityTexture: Nullable<BaseTexture>;
  51651. /**
  51652. * Stores the reflection values in a texture.
  51653. */
  51654. protected _reflectionTexture: Nullable<BaseTexture>;
  51655. /**
  51656. * Stores the emissive values in a texture.
  51657. */
  51658. protected _emissiveTexture: Nullable<BaseTexture>;
  51659. /**
  51660. * AKA Specular texture in other nomenclature.
  51661. */
  51662. protected _reflectivityTexture: Nullable<BaseTexture>;
  51663. /**
  51664. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51665. */
  51666. protected _metallicTexture: Nullable<BaseTexture>;
  51667. /**
  51668. * Specifies the metallic scalar of the metallic/roughness workflow.
  51669. * Can also be used to scale the metalness values of the metallic texture.
  51670. */
  51671. protected _metallic: Nullable<number>;
  51672. /**
  51673. * Specifies the roughness scalar of the metallic/roughness workflow.
  51674. * Can also be used to scale the roughness values of the metallic texture.
  51675. */
  51676. protected _roughness: Nullable<number>;
  51677. /**
  51678. * Specifies the an F0 factor to help configuring the material F0.
  51679. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51680. * to 0.5 the previously hard coded value stays the same.
  51681. * Can also be used to scale the F0 values of the metallic texture.
  51682. */
  51683. protected _metallicF0Factor: number;
  51684. /**
  51685. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51686. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51687. * your expectation as it multiplies with the texture data.
  51688. */
  51689. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51690. /**
  51691. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51692. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51693. */
  51694. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51695. /**
  51696. * Stores surface normal data used to displace a mesh in a texture.
  51697. */
  51698. protected _bumpTexture: Nullable<BaseTexture>;
  51699. /**
  51700. * Stores the pre-calculated light information of a mesh in a texture.
  51701. */
  51702. protected _lightmapTexture: Nullable<BaseTexture>;
  51703. /**
  51704. * The color of a material in ambient lighting.
  51705. */
  51706. protected _ambientColor: Color3;
  51707. /**
  51708. * AKA Diffuse Color in other nomenclature.
  51709. */
  51710. protected _albedoColor: Color3;
  51711. /**
  51712. * AKA Specular Color in other nomenclature.
  51713. */
  51714. protected _reflectivityColor: Color3;
  51715. /**
  51716. * The color applied when light is reflected from a material.
  51717. */
  51718. protected _reflectionColor: Color3;
  51719. /**
  51720. * The color applied when light is emitted from a material.
  51721. */
  51722. protected _emissiveColor: Color3;
  51723. /**
  51724. * AKA Glossiness in other nomenclature.
  51725. */
  51726. protected _microSurface: number;
  51727. /**
  51728. * Specifies that the material will use the light map as a show map.
  51729. */
  51730. protected _useLightmapAsShadowmap: boolean;
  51731. /**
  51732. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51733. * makes the reflect vector face the model (under horizon).
  51734. */
  51735. protected _useHorizonOcclusion: boolean;
  51736. /**
  51737. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51738. * too much the area relying on ambient texture to define their ambient occlusion.
  51739. */
  51740. protected _useRadianceOcclusion: boolean;
  51741. /**
  51742. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51743. */
  51744. protected _useAlphaFromAlbedoTexture: boolean;
  51745. /**
  51746. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51747. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51748. */
  51749. protected _useSpecularOverAlpha: boolean;
  51750. /**
  51751. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51752. */
  51753. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51754. /**
  51755. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51756. */
  51757. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51758. /**
  51759. * Specifies if the metallic texture contains the roughness information in its green channel.
  51760. */
  51761. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51762. /**
  51763. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51764. */
  51765. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51766. /**
  51767. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51768. */
  51769. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51770. /**
  51771. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51772. */
  51773. protected _useAmbientInGrayScale: boolean;
  51774. /**
  51775. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51776. * The material will try to infer what glossiness each pixel should be.
  51777. */
  51778. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51779. /**
  51780. * Defines the falloff type used in this material.
  51781. * It by default is Physical.
  51782. */
  51783. protected _lightFalloff: number;
  51784. /**
  51785. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51786. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51787. */
  51788. protected _useRadianceOverAlpha: boolean;
  51789. /**
  51790. * Allows using an object space normal map (instead of tangent space).
  51791. */
  51792. protected _useObjectSpaceNormalMap: boolean;
  51793. /**
  51794. * Allows using the bump map in parallax mode.
  51795. */
  51796. protected _useParallax: boolean;
  51797. /**
  51798. * Allows using the bump map in parallax occlusion mode.
  51799. */
  51800. protected _useParallaxOcclusion: boolean;
  51801. /**
  51802. * Controls the scale bias of the parallax mode.
  51803. */
  51804. protected _parallaxScaleBias: number;
  51805. /**
  51806. * If sets to true, disables all the lights affecting the material.
  51807. */
  51808. protected _disableLighting: boolean;
  51809. /**
  51810. * Number of Simultaneous lights allowed on the material.
  51811. */
  51812. protected _maxSimultaneousLights: number;
  51813. /**
  51814. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51815. */
  51816. protected _invertNormalMapX: boolean;
  51817. /**
  51818. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51819. */
  51820. protected _invertNormalMapY: boolean;
  51821. /**
  51822. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51823. */
  51824. protected _twoSidedLighting: boolean;
  51825. /**
  51826. * Defines the alpha limits in alpha test mode.
  51827. */
  51828. protected _alphaCutOff: number;
  51829. /**
  51830. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51831. */
  51832. protected _forceAlphaTest: boolean;
  51833. /**
  51834. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51835. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51836. */
  51837. protected _useAlphaFresnel: boolean;
  51838. /**
  51839. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51840. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51841. */
  51842. protected _useLinearAlphaFresnel: boolean;
  51843. /**
  51844. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51845. * from cos thetav and roughness:
  51846. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51847. */
  51848. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51849. /**
  51850. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51851. */
  51852. protected _forceIrradianceInFragment: boolean;
  51853. /**
  51854. * Force normal to face away from face.
  51855. */
  51856. protected _forceNormalForward: boolean;
  51857. /**
  51858. * Enables specular anti aliasing in the PBR shader.
  51859. * It will both interacts on the Geometry for analytical and IBL lighting.
  51860. * It also prefilter the roughness map based on the bump values.
  51861. */
  51862. protected _enableSpecularAntiAliasing: boolean;
  51863. /**
  51864. * Default configuration related to image processing available in the PBR Material.
  51865. */
  51866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51867. /**
  51868. * Keep track of the image processing observer to allow dispose and replace.
  51869. */
  51870. private _imageProcessingObserver;
  51871. /**
  51872. * Attaches a new image processing configuration to the PBR Material.
  51873. * @param configuration
  51874. */
  51875. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51876. /**
  51877. * Stores the available render targets.
  51878. */
  51879. private _renderTargets;
  51880. /**
  51881. * Sets the global ambient color for the material used in lighting calculations.
  51882. */
  51883. private _globalAmbientColor;
  51884. /**
  51885. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51886. */
  51887. private _useLogarithmicDepth;
  51888. /**
  51889. * If set to true, no lighting calculations will be applied.
  51890. */
  51891. private _unlit;
  51892. private _debugMode;
  51893. /**
  51894. * @hidden
  51895. * This is reserved for the inspector.
  51896. * Defines the material debug mode.
  51897. * It helps seeing only some components of the material while troubleshooting.
  51898. */
  51899. debugMode: number;
  51900. /**
  51901. * @hidden
  51902. * This is reserved for the inspector.
  51903. * Specify from where on screen the debug mode should start.
  51904. * The value goes from -1 (full screen) to 1 (not visible)
  51905. * It helps with side by side comparison against the final render
  51906. * This defaults to -1
  51907. */
  51908. private debugLimit;
  51909. /**
  51910. * @hidden
  51911. * This is reserved for the inspector.
  51912. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51913. * You can use the factor to better multiply the final value.
  51914. */
  51915. private debugFactor;
  51916. /**
  51917. * Defines the clear coat layer parameters for the material.
  51918. */
  51919. readonly clearCoat: PBRClearCoatConfiguration;
  51920. /**
  51921. * Defines the anisotropic parameters for the material.
  51922. */
  51923. readonly anisotropy: PBRAnisotropicConfiguration;
  51924. /**
  51925. * Defines the BRDF parameters for the material.
  51926. */
  51927. readonly brdf: PBRBRDFConfiguration;
  51928. /**
  51929. * Defines the Sheen parameters for the material.
  51930. */
  51931. readonly sheen: PBRSheenConfiguration;
  51932. /**
  51933. * Defines the SubSurface parameters for the material.
  51934. */
  51935. readonly subSurface: PBRSubSurfaceConfiguration;
  51936. /**
  51937. * Custom callback helping to override the default shader used in the material.
  51938. */
  51939. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  51940. protected _rebuildInParallel: boolean;
  51941. /**
  51942. * Instantiates a new PBRMaterial instance.
  51943. *
  51944. * @param name The material name
  51945. * @param scene The scene the material will be use in.
  51946. */
  51947. constructor(name: string, scene: Scene);
  51948. /**
  51949. * Gets a boolean indicating that current material needs to register RTT
  51950. */
  51951. get hasRenderTargetTextures(): boolean;
  51952. /**
  51953. * Gets the name of the material class.
  51954. */
  51955. getClassName(): string;
  51956. /**
  51957. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51958. */
  51959. get useLogarithmicDepth(): boolean;
  51960. /**
  51961. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51962. */
  51963. set useLogarithmicDepth(value: boolean);
  51964. /**
  51965. * Returns true if alpha blending should be disabled.
  51966. */
  51967. protected get _disableAlphaBlending(): boolean;
  51968. /**
  51969. * Specifies whether or not this material should be rendered in alpha blend mode.
  51970. */
  51971. needAlphaBlending(): boolean;
  51972. /**
  51973. * Specifies whether or not this material should be rendered in alpha test mode.
  51974. */
  51975. needAlphaTesting(): boolean;
  51976. /**
  51977. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51978. */
  51979. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51980. /**
  51981. * Gets the texture used for the alpha test.
  51982. */
  51983. getAlphaTestTexture(): Nullable<BaseTexture>;
  51984. /**
  51985. * Specifies that the submesh is ready to be used.
  51986. * @param mesh - BJS mesh.
  51987. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51988. * @param useInstances - Specifies that instances should be used.
  51989. * @returns - boolean indicating that the submesh is ready or not.
  51990. */
  51991. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51992. /**
  51993. * Specifies if the material uses metallic roughness workflow.
  51994. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51995. */
  51996. isMetallicWorkflow(): boolean;
  51997. private _prepareEffect;
  51998. private _prepareDefines;
  51999. /**
  52000. * Force shader compilation
  52001. */
  52002. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52003. /**
  52004. * Initializes the uniform buffer layout for the shader.
  52005. */
  52006. buildUniformLayout(): void;
  52007. /**
  52008. * Unbinds the material from the mesh
  52009. */
  52010. unbind(): void;
  52011. /**
  52012. * Binds the submesh data.
  52013. * @param world - The world matrix.
  52014. * @param mesh - The BJS mesh.
  52015. * @param subMesh - A submesh of the BJS mesh.
  52016. */
  52017. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52018. /**
  52019. * Returns the animatable textures.
  52020. * @returns - Array of animatable textures.
  52021. */
  52022. getAnimatables(): IAnimatable[];
  52023. /**
  52024. * Returns the texture used for reflections.
  52025. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52026. */
  52027. private _getReflectionTexture;
  52028. /**
  52029. * Returns an array of the actively used textures.
  52030. * @returns - Array of BaseTextures
  52031. */
  52032. getActiveTextures(): BaseTexture[];
  52033. /**
  52034. * Checks to see if a texture is used in the material.
  52035. * @param texture - Base texture to use.
  52036. * @returns - Boolean specifying if a texture is used in the material.
  52037. */
  52038. hasTexture(texture: BaseTexture): boolean;
  52039. /**
  52040. * Disposes the resources of the material.
  52041. * @param forceDisposeEffect - Forces the disposal of effects.
  52042. * @param forceDisposeTextures - Forces the disposal of all textures.
  52043. */
  52044. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52045. }
  52046. }
  52047. declare module BABYLON {
  52048. /**
  52049. * The Physically based material of BJS.
  52050. *
  52051. * This offers the main features of a standard PBR material.
  52052. * For more information, please refer to the documentation :
  52053. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52054. */
  52055. export class PBRMaterial extends PBRBaseMaterial {
  52056. /**
  52057. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52058. */
  52059. static readonly PBRMATERIAL_OPAQUE: number;
  52060. /**
  52061. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52062. */
  52063. static readonly PBRMATERIAL_ALPHATEST: number;
  52064. /**
  52065. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52066. */
  52067. static readonly PBRMATERIAL_ALPHABLEND: number;
  52068. /**
  52069. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52070. * They are also discarded below the alpha cutoff threshold to improve performances.
  52071. */
  52072. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52073. /**
  52074. * Defines the default value of how much AO map is occluding the analytical lights
  52075. * (point spot...).
  52076. */
  52077. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52078. /**
  52079. * Intensity of the direct lights e.g. the four lights available in your scene.
  52080. * This impacts both the direct diffuse and specular highlights.
  52081. */
  52082. directIntensity: number;
  52083. /**
  52084. * Intensity of the emissive part of the material.
  52085. * This helps controlling the emissive effect without modifying the emissive color.
  52086. */
  52087. emissiveIntensity: number;
  52088. /**
  52089. * Intensity of the environment e.g. how much the environment will light the object
  52090. * either through harmonics for rough material or through the refelction for shiny ones.
  52091. */
  52092. environmentIntensity: number;
  52093. /**
  52094. * This is a special control allowing the reduction of the specular highlights coming from the
  52095. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52096. */
  52097. specularIntensity: number;
  52098. /**
  52099. * Debug Control allowing disabling the bump map on this material.
  52100. */
  52101. disableBumpMap: boolean;
  52102. /**
  52103. * AKA Diffuse Texture in standard nomenclature.
  52104. */
  52105. albedoTexture: BaseTexture;
  52106. /**
  52107. * AKA Occlusion Texture in other nomenclature.
  52108. */
  52109. ambientTexture: BaseTexture;
  52110. /**
  52111. * AKA Occlusion Texture Intensity in other nomenclature.
  52112. */
  52113. ambientTextureStrength: number;
  52114. /**
  52115. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52116. * 1 means it completely occludes it
  52117. * 0 mean it has no impact
  52118. */
  52119. ambientTextureImpactOnAnalyticalLights: number;
  52120. /**
  52121. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52122. */
  52123. opacityTexture: BaseTexture;
  52124. /**
  52125. * Stores the reflection values in a texture.
  52126. */
  52127. reflectionTexture: Nullable<BaseTexture>;
  52128. /**
  52129. * Stores the emissive values in a texture.
  52130. */
  52131. emissiveTexture: BaseTexture;
  52132. /**
  52133. * AKA Specular texture in other nomenclature.
  52134. */
  52135. reflectivityTexture: BaseTexture;
  52136. /**
  52137. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52138. */
  52139. metallicTexture: BaseTexture;
  52140. /**
  52141. * Specifies the metallic scalar of the metallic/roughness workflow.
  52142. * Can also be used to scale the metalness values of the metallic texture.
  52143. */
  52144. metallic: Nullable<number>;
  52145. /**
  52146. * Specifies the roughness scalar of the metallic/roughness workflow.
  52147. * Can also be used to scale the roughness values of the metallic texture.
  52148. */
  52149. roughness: Nullable<number>;
  52150. /**
  52151. * Specifies the an F0 factor to help configuring the material F0.
  52152. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52153. * to 0.5 the previously hard coded value stays the same.
  52154. * Can also be used to scale the F0 values of the metallic texture.
  52155. */
  52156. metallicF0Factor: number;
  52157. /**
  52158. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52159. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52160. * your expectation as it multiplies with the texture data.
  52161. */
  52162. useMetallicF0FactorFromMetallicTexture: boolean;
  52163. /**
  52164. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52165. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52166. */
  52167. microSurfaceTexture: BaseTexture;
  52168. /**
  52169. * Stores surface normal data used to displace a mesh in a texture.
  52170. */
  52171. bumpTexture: BaseTexture;
  52172. /**
  52173. * Stores the pre-calculated light information of a mesh in a texture.
  52174. */
  52175. lightmapTexture: BaseTexture;
  52176. /**
  52177. * Stores the refracted light information in a texture.
  52178. */
  52179. get refractionTexture(): Nullable<BaseTexture>;
  52180. set refractionTexture(value: Nullable<BaseTexture>);
  52181. /**
  52182. * The color of a material in ambient lighting.
  52183. */
  52184. ambientColor: Color3;
  52185. /**
  52186. * AKA Diffuse Color in other nomenclature.
  52187. */
  52188. albedoColor: Color3;
  52189. /**
  52190. * AKA Specular Color in other nomenclature.
  52191. */
  52192. reflectivityColor: Color3;
  52193. /**
  52194. * The color reflected from the material.
  52195. */
  52196. reflectionColor: Color3;
  52197. /**
  52198. * The color emitted from the material.
  52199. */
  52200. emissiveColor: Color3;
  52201. /**
  52202. * AKA Glossiness in other nomenclature.
  52203. */
  52204. microSurface: number;
  52205. /**
  52206. * source material index of refraction (IOR)' / 'destination material IOR.
  52207. */
  52208. get indexOfRefraction(): number;
  52209. set indexOfRefraction(value: number);
  52210. /**
  52211. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52212. */
  52213. get invertRefractionY(): boolean;
  52214. set invertRefractionY(value: boolean);
  52215. /**
  52216. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52217. * Materials half opaque for instance using refraction could benefit from this control.
  52218. */
  52219. get linkRefractionWithTransparency(): boolean;
  52220. set linkRefractionWithTransparency(value: boolean);
  52221. /**
  52222. * If true, the light map contains occlusion information instead of lighting info.
  52223. */
  52224. useLightmapAsShadowmap: boolean;
  52225. /**
  52226. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52227. */
  52228. useAlphaFromAlbedoTexture: boolean;
  52229. /**
  52230. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52231. */
  52232. forceAlphaTest: boolean;
  52233. /**
  52234. * Defines the alpha limits in alpha test mode.
  52235. */
  52236. alphaCutOff: number;
  52237. /**
  52238. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52239. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52240. */
  52241. useSpecularOverAlpha: boolean;
  52242. /**
  52243. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52244. */
  52245. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52246. /**
  52247. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52248. */
  52249. useRoughnessFromMetallicTextureAlpha: boolean;
  52250. /**
  52251. * Specifies if the metallic texture contains the roughness information in its green channel.
  52252. */
  52253. useRoughnessFromMetallicTextureGreen: boolean;
  52254. /**
  52255. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52256. */
  52257. useMetallnessFromMetallicTextureBlue: boolean;
  52258. /**
  52259. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52260. */
  52261. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52262. /**
  52263. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52264. */
  52265. useAmbientInGrayScale: boolean;
  52266. /**
  52267. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52268. * The material will try to infer what glossiness each pixel should be.
  52269. */
  52270. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52271. /**
  52272. * BJS is using an harcoded light falloff based on a manually sets up range.
  52273. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52274. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52275. */
  52276. get usePhysicalLightFalloff(): boolean;
  52277. /**
  52278. * BJS is using an harcoded light falloff based on a manually sets up range.
  52279. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52280. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52281. */
  52282. set usePhysicalLightFalloff(value: boolean);
  52283. /**
  52284. * In order to support the falloff compatibility with gltf, a special mode has been added
  52285. * to reproduce the gltf light falloff.
  52286. */
  52287. get useGLTFLightFalloff(): boolean;
  52288. /**
  52289. * In order to support the falloff compatibility with gltf, a special mode has been added
  52290. * to reproduce the gltf light falloff.
  52291. */
  52292. set useGLTFLightFalloff(value: boolean);
  52293. /**
  52294. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52295. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52296. */
  52297. useRadianceOverAlpha: boolean;
  52298. /**
  52299. * Allows using an object space normal map (instead of tangent space).
  52300. */
  52301. useObjectSpaceNormalMap: boolean;
  52302. /**
  52303. * Allows using the bump map in parallax mode.
  52304. */
  52305. useParallax: boolean;
  52306. /**
  52307. * Allows using the bump map in parallax occlusion mode.
  52308. */
  52309. useParallaxOcclusion: boolean;
  52310. /**
  52311. * Controls the scale bias of the parallax mode.
  52312. */
  52313. parallaxScaleBias: number;
  52314. /**
  52315. * If sets to true, disables all the lights affecting the material.
  52316. */
  52317. disableLighting: boolean;
  52318. /**
  52319. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52320. */
  52321. forceIrradianceInFragment: boolean;
  52322. /**
  52323. * Number of Simultaneous lights allowed on the material.
  52324. */
  52325. maxSimultaneousLights: number;
  52326. /**
  52327. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52328. */
  52329. invertNormalMapX: boolean;
  52330. /**
  52331. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52332. */
  52333. invertNormalMapY: boolean;
  52334. /**
  52335. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52336. */
  52337. twoSidedLighting: boolean;
  52338. /**
  52339. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52340. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52341. */
  52342. useAlphaFresnel: boolean;
  52343. /**
  52344. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52345. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52346. */
  52347. useLinearAlphaFresnel: boolean;
  52348. /**
  52349. * Let user defines the brdf lookup texture used for IBL.
  52350. * A default 8bit version is embedded but you could point at :
  52351. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52352. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52353. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52354. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52355. */
  52356. environmentBRDFTexture: Nullable<BaseTexture>;
  52357. /**
  52358. * Force normal to face away from face.
  52359. */
  52360. forceNormalForward: boolean;
  52361. /**
  52362. * Enables specular anti aliasing in the PBR shader.
  52363. * It will both interacts on the Geometry for analytical and IBL lighting.
  52364. * It also prefilter the roughness map based on the bump values.
  52365. */
  52366. enableSpecularAntiAliasing: boolean;
  52367. /**
  52368. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52369. * makes the reflect vector face the model (under horizon).
  52370. */
  52371. useHorizonOcclusion: boolean;
  52372. /**
  52373. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52374. * too much the area relying on ambient texture to define their ambient occlusion.
  52375. */
  52376. useRadianceOcclusion: boolean;
  52377. /**
  52378. * If set to true, no lighting calculations will be applied.
  52379. */
  52380. unlit: boolean;
  52381. /**
  52382. * Gets the image processing configuration used either in this material.
  52383. */
  52384. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52385. /**
  52386. * Sets the Default image processing configuration used either in the this material.
  52387. *
  52388. * If sets to null, the scene one is in use.
  52389. */
  52390. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52391. /**
  52392. * Gets wether the color curves effect is enabled.
  52393. */
  52394. get cameraColorCurvesEnabled(): boolean;
  52395. /**
  52396. * Sets wether the color curves effect is enabled.
  52397. */
  52398. set cameraColorCurvesEnabled(value: boolean);
  52399. /**
  52400. * Gets wether the color grading effect is enabled.
  52401. */
  52402. get cameraColorGradingEnabled(): boolean;
  52403. /**
  52404. * Gets wether the color grading effect is enabled.
  52405. */
  52406. set cameraColorGradingEnabled(value: boolean);
  52407. /**
  52408. * Gets wether tonemapping is enabled or not.
  52409. */
  52410. get cameraToneMappingEnabled(): boolean;
  52411. /**
  52412. * Sets wether tonemapping is enabled or not
  52413. */
  52414. set cameraToneMappingEnabled(value: boolean);
  52415. /**
  52416. * The camera exposure used on this material.
  52417. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52418. * This corresponds to a photographic exposure.
  52419. */
  52420. get cameraExposure(): number;
  52421. /**
  52422. * The camera exposure used on this material.
  52423. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52424. * This corresponds to a photographic exposure.
  52425. */
  52426. set cameraExposure(value: number);
  52427. /**
  52428. * Gets The camera contrast used on this material.
  52429. */
  52430. get cameraContrast(): number;
  52431. /**
  52432. * Sets The camera contrast used on this material.
  52433. */
  52434. set cameraContrast(value: number);
  52435. /**
  52436. * Gets the Color Grading 2D Lookup Texture.
  52437. */
  52438. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52439. /**
  52440. * Sets the Color Grading 2D Lookup Texture.
  52441. */
  52442. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52443. /**
  52444. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52445. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52446. * 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;
  52447. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52448. */
  52449. get cameraColorCurves(): Nullable<ColorCurves>;
  52450. /**
  52451. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52452. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52453. * 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;
  52454. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52455. */
  52456. set cameraColorCurves(value: Nullable<ColorCurves>);
  52457. /**
  52458. * Instantiates a new PBRMaterial instance.
  52459. *
  52460. * @param name The material name
  52461. * @param scene The scene the material will be use in.
  52462. */
  52463. constructor(name: string, scene: Scene);
  52464. /**
  52465. * Returns the name of this material class.
  52466. */
  52467. getClassName(): string;
  52468. /**
  52469. * Makes a duplicate of the current material.
  52470. * @param name - name to use for the new material.
  52471. */
  52472. clone(name: string): PBRMaterial;
  52473. /**
  52474. * Serializes this PBR Material.
  52475. * @returns - An object with the serialized material.
  52476. */
  52477. serialize(): any;
  52478. /**
  52479. * Parses a PBR Material from a serialized object.
  52480. * @param source - Serialized object.
  52481. * @param scene - BJS scene instance.
  52482. * @param rootUrl - url for the scene object
  52483. * @returns - PBRMaterial
  52484. */
  52485. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52486. }
  52487. }
  52488. declare module BABYLON {
  52489. /**
  52490. * Direct draw surface info
  52491. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52492. */
  52493. export interface DDSInfo {
  52494. /**
  52495. * Width of the texture
  52496. */
  52497. width: number;
  52498. /**
  52499. * Width of the texture
  52500. */
  52501. height: number;
  52502. /**
  52503. * Number of Mipmaps for the texture
  52504. * @see https://en.wikipedia.org/wiki/Mipmap
  52505. */
  52506. mipmapCount: number;
  52507. /**
  52508. * If the textures format is a known fourCC format
  52509. * @see https://www.fourcc.org/
  52510. */
  52511. isFourCC: boolean;
  52512. /**
  52513. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52514. */
  52515. isRGB: boolean;
  52516. /**
  52517. * If the texture is a lumincance format
  52518. */
  52519. isLuminance: boolean;
  52520. /**
  52521. * If this is a cube texture
  52522. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52523. */
  52524. isCube: boolean;
  52525. /**
  52526. * If the texture is a compressed format eg. FOURCC_DXT1
  52527. */
  52528. isCompressed: boolean;
  52529. /**
  52530. * The dxgiFormat of the texture
  52531. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52532. */
  52533. dxgiFormat: number;
  52534. /**
  52535. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52536. */
  52537. textureType: number;
  52538. /**
  52539. * Sphericle polynomial created for the dds texture
  52540. */
  52541. sphericalPolynomial?: SphericalPolynomial;
  52542. }
  52543. /**
  52544. * Class used to provide DDS decompression tools
  52545. */
  52546. export class DDSTools {
  52547. /**
  52548. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52549. */
  52550. static StoreLODInAlphaChannel: boolean;
  52551. /**
  52552. * Gets DDS information from an array buffer
  52553. * @param data defines the array buffer view to read data from
  52554. * @returns the DDS information
  52555. */
  52556. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52557. private static _FloatView;
  52558. private static _Int32View;
  52559. private static _ToHalfFloat;
  52560. private static _FromHalfFloat;
  52561. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52562. private static _GetHalfFloatRGBAArrayBuffer;
  52563. private static _GetFloatRGBAArrayBuffer;
  52564. private static _GetFloatAsUIntRGBAArrayBuffer;
  52565. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52566. private static _GetRGBAArrayBuffer;
  52567. private static _ExtractLongWordOrder;
  52568. private static _GetRGBArrayBuffer;
  52569. private static _GetLuminanceArrayBuffer;
  52570. /**
  52571. * Uploads DDS Levels to a Babylon Texture
  52572. * @hidden
  52573. */
  52574. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52575. }
  52576. interface ThinEngine {
  52577. /**
  52578. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52579. * @param rootUrl defines the url where the file to load is located
  52580. * @param scene defines the current scene
  52581. * @param lodScale defines scale to apply to the mip map selection
  52582. * @param lodOffset defines offset to apply to the mip map selection
  52583. * @param onLoad defines an optional callback raised when the texture is loaded
  52584. * @param onError defines an optional callback raised if there is an issue to load the texture
  52585. * @param format defines the format of the data
  52586. * @param forcedExtension defines the extension to use to pick the right loader
  52587. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52588. * @returns the cube texture as an InternalTexture
  52589. */
  52590. 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;
  52591. }
  52592. }
  52593. declare module BABYLON {
  52594. /**
  52595. * Implementation of the DDS Texture Loader.
  52596. * @hidden
  52597. */
  52598. export class _DDSTextureLoader implements IInternalTextureLoader {
  52599. /**
  52600. * Defines wether the loader supports cascade loading the different faces.
  52601. */
  52602. readonly supportCascades: boolean;
  52603. /**
  52604. * This returns if the loader support the current file information.
  52605. * @param extension defines the file extension of the file being loaded
  52606. * @returns true if the loader can load the specified file
  52607. */
  52608. canLoad(extension: string): boolean;
  52609. /**
  52610. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52611. * @param data contains the texture data
  52612. * @param texture defines the BabylonJS internal texture
  52613. * @param createPolynomials will be true if polynomials have been requested
  52614. * @param onLoad defines the callback to trigger once the texture is ready
  52615. * @param onError defines the callback to trigger in case of error
  52616. */
  52617. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52618. /**
  52619. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52620. * @param data contains the texture data
  52621. * @param texture defines the BabylonJS internal texture
  52622. * @param callback defines the method to call once ready to upload
  52623. */
  52624. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52625. }
  52626. }
  52627. declare module BABYLON {
  52628. /**
  52629. * Implementation of the ENV Texture Loader.
  52630. * @hidden
  52631. */
  52632. export class _ENVTextureLoader implements IInternalTextureLoader {
  52633. /**
  52634. * Defines wether the loader supports cascade loading the different faces.
  52635. */
  52636. readonly supportCascades: boolean;
  52637. /**
  52638. * This returns if the loader support the current file information.
  52639. * @param extension defines the file extension of the file being loaded
  52640. * @returns true if the loader can load the specified file
  52641. */
  52642. canLoad(extension: string): boolean;
  52643. /**
  52644. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52645. * @param data contains the texture data
  52646. * @param texture defines the BabylonJS internal texture
  52647. * @param createPolynomials will be true if polynomials have been requested
  52648. * @param onLoad defines the callback to trigger once the texture is ready
  52649. * @param onError defines the callback to trigger in case of error
  52650. */
  52651. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52652. /**
  52653. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52654. * @param data contains the texture data
  52655. * @param texture defines the BabylonJS internal texture
  52656. * @param callback defines the method to call once ready to upload
  52657. */
  52658. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52659. }
  52660. }
  52661. declare module BABYLON {
  52662. /**
  52663. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52664. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52665. */
  52666. export class KhronosTextureContainer {
  52667. /** contents of the KTX container file */
  52668. data: ArrayBufferView;
  52669. private static HEADER_LEN;
  52670. private static COMPRESSED_2D;
  52671. private static COMPRESSED_3D;
  52672. private static TEX_2D;
  52673. private static TEX_3D;
  52674. /**
  52675. * Gets the openGL type
  52676. */
  52677. glType: number;
  52678. /**
  52679. * Gets the openGL type size
  52680. */
  52681. glTypeSize: number;
  52682. /**
  52683. * Gets the openGL format
  52684. */
  52685. glFormat: number;
  52686. /**
  52687. * Gets the openGL internal format
  52688. */
  52689. glInternalFormat: number;
  52690. /**
  52691. * Gets the base internal format
  52692. */
  52693. glBaseInternalFormat: number;
  52694. /**
  52695. * Gets image width in pixel
  52696. */
  52697. pixelWidth: number;
  52698. /**
  52699. * Gets image height in pixel
  52700. */
  52701. pixelHeight: number;
  52702. /**
  52703. * Gets image depth in pixels
  52704. */
  52705. pixelDepth: number;
  52706. /**
  52707. * Gets the number of array elements
  52708. */
  52709. numberOfArrayElements: number;
  52710. /**
  52711. * Gets the number of faces
  52712. */
  52713. numberOfFaces: number;
  52714. /**
  52715. * Gets the number of mipmap levels
  52716. */
  52717. numberOfMipmapLevels: number;
  52718. /**
  52719. * Gets the bytes of key value data
  52720. */
  52721. bytesOfKeyValueData: number;
  52722. /**
  52723. * Gets the load type
  52724. */
  52725. loadType: number;
  52726. /**
  52727. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52728. */
  52729. isInvalid: boolean;
  52730. /**
  52731. * Creates a new KhronosTextureContainer
  52732. * @param data contents of the KTX container file
  52733. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52734. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52735. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52736. */
  52737. constructor(
  52738. /** contents of the KTX container file */
  52739. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52740. /**
  52741. * Uploads KTX content to a Babylon Texture.
  52742. * It is assumed that the texture has already been created & is currently bound
  52743. * @hidden
  52744. */
  52745. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52746. private _upload2DCompressedLevels;
  52747. /**
  52748. * Checks if the given data starts with a KTX file identifier.
  52749. * @param data the data to check
  52750. * @returns true if the data is a KTX file or false otherwise
  52751. */
  52752. static IsValid(data: ArrayBufferView): boolean;
  52753. }
  52754. }
  52755. declare module BABYLON {
  52756. /**
  52757. * Class for loading KTX2 files
  52758. * !!! Experimental Extension Subject to Changes !!!
  52759. * @hidden
  52760. */
  52761. export class KhronosTextureContainer2 {
  52762. private static _ModulePromise;
  52763. private static _TranscodeFormat;
  52764. constructor(engine: ThinEngine);
  52765. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52766. private _determineTranscodeFormat;
  52767. /**
  52768. * Checks if the given data starts with a KTX2 file identifier.
  52769. * @param data the data to check
  52770. * @returns true if the data is a KTX2 file or false otherwise
  52771. */
  52772. static IsValid(data: ArrayBufferView): boolean;
  52773. }
  52774. }
  52775. declare module BABYLON {
  52776. /**
  52777. * Implementation of the KTX Texture Loader.
  52778. * @hidden
  52779. */
  52780. export class _KTXTextureLoader implements IInternalTextureLoader {
  52781. /**
  52782. * Defines wether the loader supports cascade loading the different faces.
  52783. */
  52784. readonly supportCascades: boolean;
  52785. /**
  52786. * This returns if the loader support the current file information.
  52787. * @param extension defines the file extension of the file being loaded
  52788. * @returns true if the loader can load the specified file
  52789. */
  52790. canLoad(extension: string): boolean;
  52791. /**
  52792. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52793. * @param data contains the texture data
  52794. * @param texture defines the BabylonJS internal texture
  52795. * @param createPolynomials will be true if polynomials have been requested
  52796. * @param onLoad defines the callback to trigger once the texture is ready
  52797. * @param onError defines the callback to trigger in case of error
  52798. */
  52799. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52800. /**
  52801. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52802. * @param data contains the texture data
  52803. * @param texture defines the BabylonJS internal texture
  52804. * @param callback defines the method to call once ready to upload
  52805. */
  52806. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52807. }
  52808. }
  52809. declare module BABYLON {
  52810. /** @hidden */
  52811. export var _forceSceneHelpersToBundle: boolean;
  52812. interface Scene {
  52813. /**
  52814. * Creates a default light for the scene.
  52815. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52816. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52817. */
  52818. createDefaultLight(replace?: boolean): void;
  52819. /**
  52820. * Creates a default camera for the scene.
  52821. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52822. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52823. * @param replace has default false, when true replaces the active camera in the scene
  52824. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52825. */
  52826. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52827. /**
  52828. * Creates a default camera and a default light.
  52829. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52830. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52831. * @param replace has the default false, when true replaces the active camera/light in the scene
  52832. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52833. */
  52834. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52835. /**
  52836. * Creates a new sky box
  52837. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52838. * @param environmentTexture defines the texture to use as environment texture
  52839. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52840. * @param scale defines the overall scale of the skybox
  52841. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52842. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52843. * @returns a new mesh holding the sky box
  52844. */
  52845. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52846. /**
  52847. * Creates a new environment
  52848. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52849. * @param options defines the options you can use to configure the environment
  52850. * @returns the new EnvironmentHelper
  52851. */
  52852. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52853. /**
  52854. * Creates a new VREXperienceHelper
  52855. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52856. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52857. * @returns a new VREXperienceHelper
  52858. */
  52859. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52860. /**
  52861. * Creates a new WebXRDefaultExperience
  52862. * @see http://doc.babylonjs.com/how_to/webxr
  52863. * @param options experience options
  52864. * @returns a promise for a new WebXRDefaultExperience
  52865. */
  52866. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52867. }
  52868. }
  52869. declare module BABYLON {
  52870. /**
  52871. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52872. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52873. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52874. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52875. */
  52876. export class VideoDome extends TransformNode {
  52877. /**
  52878. * Define the video source as a Monoscopic panoramic 360 video.
  52879. */
  52880. static readonly MODE_MONOSCOPIC: number;
  52881. /**
  52882. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52883. */
  52884. static readonly MODE_TOPBOTTOM: number;
  52885. /**
  52886. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52887. */
  52888. static readonly MODE_SIDEBYSIDE: number;
  52889. private _halfDome;
  52890. private _useDirectMapping;
  52891. /**
  52892. * The video texture being displayed on the sphere
  52893. */
  52894. protected _videoTexture: VideoTexture;
  52895. /**
  52896. * Gets the video texture being displayed on the sphere
  52897. */
  52898. get videoTexture(): VideoTexture;
  52899. /**
  52900. * The skybox material
  52901. */
  52902. protected _material: BackgroundMaterial;
  52903. /**
  52904. * The surface used for the skybox
  52905. */
  52906. protected _mesh: Mesh;
  52907. /**
  52908. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52909. */
  52910. private _halfDomeMask;
  52911. /**
  52912. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52913. * Also see the options.resolution property.
  52914. */
  52915. get fovMultiplier(): number;
  52916. set fovMultiplier(value: number);
  52917. private _videoMode;
  52918. /**
  52919. * Gets or set the current video mode for the video. It can be:
  52920. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52921. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52922. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52923. */
  52924. get videoMode(): number;
  52925. set videoMode(value: number);
  52926. /**
  52927. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52928. *
  52929. */
  52930. get halfDome(): boolean;
  52931. /**
  52932. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52933. */
  52934. set halfDome(enabled: boolean);
  52935. /**
  52936. * Oberserver used in Stereoscopic VR Mode.
  52937. */
  52938. private _onBeforeCameraRenderObserver;
  52939. /**
  52940. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52941. * @param name Element's name, child elements will append suffixes for their own names.
  52942. * @param urlsOrVideo defines the url(s) or the video element to use
  52943. * @param options An object containing optional or exposed sub element properties
  52944. */
  52945. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52946. resolution?: number;
  52947. clickToPlay?: boolean;
  52948. autoPlay?: boolean;
  52949. loop?: boolean;
  52950. size?: number;
  52951. poster?: string;
  52952. faceForward?: boolean;
  52953. useDirectMapping?: boolean;
  52954. halfDomeMode?: boolean;
  52955. }, scene: Scene);
  52956. private _changeVideoMode;
  52957. /**
  52958. * Releases resources associated with this node.
  52959. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52960. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52961. */
  52962. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52963. }
  52964. }
  52965. declare module BABYLON {
  52966. /**
  52967. * This class can be used to get instrumentation data from a Babylon engine
  52968. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52969. */
  52970. export class EngineInstrumentation implements IDisposable {
  52971. /**
  52972. * Define the instrumented engine.
  52973. */
  52974. engine: Engine;
  52975. private _captureGPUFrameTime;
  52976. private _gpuFrameTimeToken;
  52977. private _gpuFrameTime;
  52978. private _captureShaderCompilationTime;
  52979. private _shaderCompilationTime;
  52980. private _onBeginFrameObserver;
  52981. private _onEndFrameObserver;
  52982. private _onBeforeShaderCompilationObserver;
  52983. private _onAfterShaderCompilationObserver;
  52984. /**
  52985. * Gets the perf counter used for GPU frame time
  52986. */
  52987. get gpuFrameTimeCounter(): PerfCounter;
  52988. /**
  52989. * Gets the GPU frame time capture status
  52990. */
  52991. get captureGPUFrameTime(): boolean;
  52992. /**
  52993. * Enable or disable the GPU frame time capture
  52994. */
  52995. set captureGPUFrameTime(value: boolean);
  52996. /**
  52997. * Gets the perf counter used for shader compilation time
  52998. */
  52999. get shaderCompilationTimeCounter(): PerfCounter;
  53000. /**
  53001. * Gets the shader compilation time capture status
  53002. */
  53003. get captureShaderCompilationTime(): boolean;
  53004. /**
  53005. * Enable or disable the shader compilation time capture
  53006. */
  53007. set captureShaderCompilationTime(value: boolean);
  53008. /**
  53009. * Instantiates a new engine instrumentation.
  53010. * This class can be used to get instrumentation data from a Babylon engine
  53011. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53012. * @param engine Defines the engine to instrument
  53013. */
  53014. constructor(
  53015. /**
  53016. * Define the instrumented engine.
  53017. */
  53018. engine: Engine);
  53019. /**
  53020. * Dispose and release associated resources.
  53021. */
  53022. dispose(): void;
  53023. }
  53024. }
  53025. declare module BABYLON {
  53026. /**
  53027. * This class can be used to get instrumentation data from a Babylon engine
  53028. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53029. */
  53030. export class SceneInstrumentation implements IDisposable {
  53031. /**
  53032. * Defines the scene to instrument
  53033. */
  53034. scene: Scene;
  53035. private _captureActiveMeshesEvaluationTime;
  53036. private _activeMeshesEvaluationTime;
  53037. private _captureRenderTargetsRenderTime;
  53038. private _renderTargetsRenderTime;
  53039. private _captureFrameTime;
  53040. private _frameTime;
  53041. private _captureRenderTime;
  53042. private _renderTime;
  53043. private _captureInterFrameTime;
  53044. private _interFrameTime;
  53045. private _captureParticlesRenderTime;
  53046. private _particlesRenderTime;
  53047. private _captureSpritesRenderTime;
  53048. private _spritesRenderTime;
  53049. private _capturePhysicsTime;
  53050. private _physicsTime;
  53051. private _captureAnimationsTime;
  53052. private _animationsTime;
  53053. private _captureCameraRenderTime;
  53054. private _cameraRenderTime;
  53055. private _onBeforeActiveMeshesEvaluationObserver;
  53056. private _onAfterActiveMeshesEvaluationObserver;
  53057. private _onBeforeRenderTargetsRenderObserver;
  53058. private _onAfterRenderTargetsRenderObserver;
  53059. private _onAfterRenderObserver;
  53060. private _onBeforeDrawPhaseObserver;
  53061. private _onAfterDrawPhaseObserver;
  53062. private _onBeforeAnimationsObserver;
  53063. private _onBeforeParticlesRenderingObserver;
  53064. private _onAfterParticlesRenderingObserver;
  53065. private _onBeforeSpritesRenderingObserver;
  53066. private _onAfterSpritesRenderingObserver;
  53067. private _onBeforePhysicsObserver;
  53068. private _onAfterPhysicsObserver;
  53069. private _onAfterAnimationsObserver;
  53070. private _onBeforeCameraRenderObserver;
  53071. private _onAfterCameraRenderObserver;
  53072. /**
  53073. * Gets the perf counter used for active meshes evaluation time
  53074. */
  53075. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53076. /**
  53077. * Gets the active meshes evaluation time capture status
  53078. */
  53079. get captureActiveMeshesEvaluationTime(): boolean;
  53080. /**
  53081. * Enable or disable the active meshes evaluation time capture
  53082. */
  53083. set captureActiveMeshesEvaluationTime(value: boolean);
  53084. /**
  53085. * Gets the perf counter used for render targets render time
  53086. */
  53087. get renderTargetsRenderTimeCounter(): PerfCounter;
  53088. /**
  53089. * Gets the render targets render time capture status
  53090. */
  53091. get captureRenderTargetsRenderTime(): boolean;
  53092. /**
  53093. * Enable or disable the render targets render time capture
  53094. */
  53095. set captureRenderTargetsRenderTime(value: boolean);
  53096. /**
  53097. * Gets the perf counter used for particles render time
  53098. */
  53099. get particlesRenderTimeCounter(): PerfCounter;
  53100. /**
  53101. * Gets the particles render time capture status
  53102. */
  53103. get captureParticlesRenderTime(): boolean;
  53104. /**
  53105. * Enable or disable the particles render time capture
  53106. */
  53107. set captureParticlesRenderTime(value: boolean);
  53108. /**
  53109. * Gets the perf counter used for sprites render time
  53110. */
  53111. get spritesRenderTimeCounter(): PerfCounter;
  53112. /**
  53113. * Gets the sprites render time capture status
  53114. */
  53115. get captureSpritesRenderTime(): boolean;
  53116. /**
  53117. * Enable or disable the sprites render time capture
  53118. */
  53119. set captureSpritesRenderTime(value: boolean);
  53120. /**
  53121. * Gets the perf counter used for physics time
  53122. */
  53123. get physicsTimeCounter(): PerfCounter;
  53124. /**
  53125. * Gets the physics time capture status
  53126. */
  53127. get capturePhysicsTime(): boolean;
  53128. /**
  53129. * Enable or disable the physics time capture
  53130. */
  53131. set capturePhysicsTime(value: boolean);
  53132. /**
  53133. * Gets the perf counter used for animations time
  53134. */
  53135. get animationsTimeCounter(): PerfCounter;
  53136. /**
  53137. * Gets the animations time capture status
  53138. */
  53139. get captureAnimationsTime(): boolean;
  53140. /**
  53141. * Enable or disable the animations time capture
  53142. */
  53143. set captureAnimationsTime(value: boolean);
  53144. /**
  53145. * Gets the perf counter used for frame time capture
  53146. */
  53147. get frameTimeCounter(): PerfCounter;
  53148. /**
  53149. * Gets the frame time capture status
  53150. */
  53151. get captureFrameTime(): boolean;
  53152. /**
  53153. * Enable or disable the frame time capture
  53154. */
  53155. set captureFrameTime(value: boolean);
  53156. /**
  53157. * Gets the perf counter used for inter-frames time capture
  53158. */
  53159. get interFrameTimeCounter(): PerfCounter;
  53160. /**
  53161. * Gets the inter-frames time capture status
  53162. */
  53163. get captureInterFrameTime(): boolean;
  53164. /**
  53165. * Enable or disable the inter-frames time capture
  53166. */
  53167. set captureInterFrameTime(value: boolean);
  53168. /**
  53169. * Gets the perf counter used for render time capture
  53170. */
  53171. get renderTimeCounter(): PerfCounter;
  53172. /**
  53173. * Gets the render time capture status
  53174. */
  53175. get captureRenderTime(): boolean;
  53176. /**
  53177. * Enable or disable the render time capture
  53178. */
  53179. set captureRenderTime(value: boolean);
  53180. /**
  53181. * Gets the perf counter used for camera render time capture
  53182. */
  53183. get cameraRenderTimeCounter(): PerfCounter;
  53184. /**
  53185. * Gets the camera render time capture status
  53186. */
  53187. get captureCameraRenderTime(): boolean;
  53188. /**
  53189. * Enable or disable the camera render time capture
  53190. */
  53191. set captureCameraRenderTime(value: boolean);
  53192. /**
  53193. * Gets the perf counter used for draw calls
  53194. */
  53195. get drawCallsCounter(): PerfCounter;
  53196. /**
  53197. * Instantiates a new scene instrumentation.
  53198. * This class can be used to get instrumentation data from a Babylon engine
  53199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53200. * @param scene Defines the scene to instrument
  53201. */
  53202. constructor(
  53203. /**
  53204. * Defines the scene to instrument
  53205. */
  53206. scene: Scene);
  53207. /**
  53208. * Dispose and release associated resources.
  53209. */
  53210. dispose(): void;
  53211. }
  53212. }
  53213. declare module BABYLON {
  53214. /** @hidden */
  53215. export var glowMapGenerationPixelShader: {
  53216. name: string;
  53217. shader: string;
  53218. };
  53219. }
  53220. declare module BABYLON {
  53221. /** @hidden */
  53222. export var glowMapGenerationVertexShader: {
  53223. name: string;
  53224. shader: string;
  53225. };
  53226. }
  53227. declare module BABYLON {
  53228. /**
  53229. * Effect layer options. This helps customizing the behaviour
  53230. * of the effect layer.
  53231. */
  53232. export interface IEffectLayerOptions {
  53233. /**
  53234. * Multiplication factor apply to the canvas size to compute the render target size
  53235. * used to generated the objects (the smaller the faster).
  53236. */
  53237. mainTextureRatio: number;
  53238. /**
  53239. * Enforces a fixed size texture to ensure effect stability across devices.
  53240. */
  53241. mainTextureFixedSize?: number;
  53242. /**
  53243. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53244. */
  53245. alphaBlendingMode: number;
  53246. /**
  53247. * The camera attached to the layer.
  53248. */
  53249. camera: Nullable<Camera>;
  53250. /**
  53251. * The rendering group to draw the layer in.
  53252. */
  53253. renderingGroupId: number;
  53254. }
  53255. /**
  53256. * The effect layer Helps adding post process effect blended with the main pass.
  53257. *
  53258. * This can be for instance use to generate glow or higlight effects on the scene.
  53259. *
  53260. * The effect layer class can not be used directly and is intented to inherited from to be
  53261. * customized per effects.
  53262. */
  53263. export abstract class EffectLayer {
  53264. private _vertexBuffers;
  53265. private _indexBuffer;
  53266. private _cachedDefines;
  53267. private _effectLayerMapGenerationEffect;
  53268. private _effectLayerOptions;
  53269. private _mergeEffect;
  53270. protected _scene: Scene;
  53271. protected _engine: Engine;
  53272. protected _maxSize: number;
  53273. protected _mainTextureDesiredSize: ISize;
  53274. protected _mainTexture: RenderTargetTexture;
  53275. protected _shouldRender: boolean;
  53276. protected _postProcesses: PostProcess[];
  53277. protected _textures: BaseTexture[];
  53278. protected _emissiveTextureAndColor: {
  53279. texture: Nullable<BaseTexture>;
  53280. color: Color4;
  53281. };
  53282. /**
  53283. * The name of the layer
  53284. */
  53285. name: string;
  53286. /**
  53287. * The clear color of the texture used to generate the glow map.
  53288. */
  53289. neutralColor: Color4;
  53290. /**
  53291. * Specifies whether the highlight layer is enabled or not.
  53292. */
  53293. isEnabled: boolean;
  53294. /**
  53295. * Gets the camera attached to the layer.
  53296. */
  53297. get camera(): Nullable<Camera>;
  53298. /**
  53299. * Gets the rendering group id the layer should render in.
  53300. */
  53301. get renderingGroupId(): number;
  53302. set renderingGroupId(renderingGroupId: number);
  53303. /**
  53304. * An event triggered when the effect layer has been disposed.
  53305. */
  53306. onDisposeObservable: Observable<EffectLayer>;
  53307. /**
  53308. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53309. */
  53310. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53311. /**
  53312. * An event triggered when the generated texture is being merged in the scene.
  53313. */
  53314. onBeforeComposeObservable: Observable<EffectLayer>;
  53315. /**
  53316. * An event triggered when the mesh is rendered into the effect render target.
  53317. */
  53318. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53319. /**
  53320. * An event triggered after the mesh has been rendered into the effect render target.
  53321. */
  53322. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53323. /**
  53324. * An event triggered when the generated texture has been merged in the scene.
  53325. */
  53326. onAfterComposeObservable: Observable<EffectLayer>;
  53327. /**
  53328. * An event triggered when the efffect layer changes its size.
  53329. */
  53330. onSizeChangedObservable: Observable<EffectLayer>;
  53331. /** @hidden */
  53332. static _SceneComponentInitialization: (scene: Scene) => void;
  53333. /**
  53334. * Instantiates a new effect Layer and references it in the scene.
  53335. * @param name The name of the layer
  53336. * @param scene The scene to use the layer in
  53337. */
  53338. constructor(
  53339. /** The Friendly of the effect in the scene */
  53340. name: string, scene: Scene);
  53341. /**
  53342. * Get the effect name of the layer.
  53343. * @return The effect name
  53344. */
  53345. abstract getEffectName(): string;
  53346. /**
  53347. * Checks for the readiness of the element composing the layer.
  53348. * @param subMesh the mesh to check for
  53349. * @param useInstances specify whether or not to use instances to render the mesh
  53350. * @return true if ready otherwise, false
  53351. */
  53352. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53353. /**
  53354. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53355. * @returns true if the effect requires stencil during the main canvas render pass.
  53356. */
  53357. abstract needStencil(): boolean;
  53358. /**
  53359. * Create the merge effect. This is the shader use to blit the information back
  53360. * to the main canvas at the end of the scene rendering.
  53361. * @returns The effect containing the shader used to merge the effect on the main canvas
  53362. */
  53363. protected abstract _createMergeEffect(): Effect;
  53364. /**
  53365. * Creates the render target textures and post processes used in the effect layer.
  53366. */
  53367. protected abstract _createTextureAndPostProcesses(): void;
  53368. /**
  53369. * Implementation specific of rendering the generating effect on the main canvas.
  53370. * @param effect The effect used to render through
  53371. */
  53372. protected abstract _internalRender(effect: Effect): void;
  53373. /**
  53374. * Sets the required values for both the emissive texture and and the main color.
  53375. */
  53376. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53377. /**
  53378. * Free any resources and references associated to a mesh.
  53379. * Internal use
  53380. * @param mesh The mesh to free.
  53381. */
  53382. abstract _disposeMesh(mesh: Mesh): void;
  53383. /**
  53384. * Serializes this layer (Glow or Highlight for example)
  53385. * @returns a serialized layer object
  53386. */
  53387. abstract serialize?(): any;
  53388. /**
  53389. * Initializes the effect layer with the required options.
  53390. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53391. */
  53392. protected _init(options: Partial<IEffectLayerOptions>): void;
  53393. /**
  53394. * Generates the index buffer of the full screen quad blending to the main canvas.
  53395. */
  53396. private _generateIndexBuffer;
  53397. /**
  53398. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53399. */
  53400. private _generateVertexBuffer;
  53401. /**
  53402. * Sets the main texture desired size which is the closest power of two
  53403. * of the engine canvas size.
  53404. */
  53405. private _setMainTextureSize;
  53406. /**
  53407. * Creates the main texture for the effect layer.
  53408. */
  53409. protected _createMainTexture(): void;
  53410. /**
  53411. * Adds specific effects defines.
  53412. * @param defines The defines to add specifics to.
  53413. */
  53414. protected _addCustomEffectDefines(defines: string[]): void;
  53415. /**
  53416. * Checks for the readiness of the element composing the layer.
  53417. * @param subMesh the mesh to check for
  53418. * @param useInstances specify whether or not to use instances to render the mesh
  53419. * @param emissiveTexture the associated emissive texture used to generate the glow
  53420. * @return true if ready otherwise, false
  53421. */
  53422. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53423. /**
  53424. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53425. */
  53426. render(): void;
  53427. /**
  53428. * Determine if a given mesh will be used in the current effect.
  53429. * @param mesh mesh to test
  53430. * @returns true if the mesh will be used
  53431. */
  53432. hasMesh(mesh: AbstractMesh): boolean;
  53433. /**
  53434. * Returns true if the layer contains information to display, otherwise false.
  53435. * @returns true if the glow layer should be rendered
  53436. */
  53437. shouldRender(): boolean;
  53438. /**
  53439. * Returns true if the mesh should render, otherwise false.
  53440. * @param mesh The mesh to render
  53441. * @returns true if it should render otherwise false
  53442. */
  53443. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53444. /**
  53445. * Returns true if the mesh can be rendered, otherwise false.
  53446. * @param mesh The mesh to render
  53447. * @param material The material used on the mesh
  53448. * @returns true if it can be rendered otherwise false
  53449. */
  53450. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53451. /**
  53452. * Returns true if the mesh should render, otherwise false.
  53453. * @param mesh The mesh to render
  53454. * @returns true if it should render otherwise false
  53455. */
  53456. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53457. /**
  53458. * Renders the submesh passed in parameter to the generation map.
  53459. */
  53460. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53461. /**
  53462. * Defines whether the current material of the mesh should be use to render the effect.
  53463. * @param mesh defines the current mesh to render
  53464. */
  53465. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53466. /**
  53467. * Rebuild the required buffers.
  53468. * @hidden Internal use only.
  53469. */
  53470. _rebuild(): void;
  53471. /**
  53472. * Dispose only the render target textures and post process.
  53473. */
  53474. private _disposeTextureAndPostProcesses;
  53475. /**
  53476. * Dispose the highlight layer and free resources.
  53477. */
  53478. dispose(): void;
  53479. /**
  53480. * Gets the class name of the effect layer
  53481. * @returns the string with the class name of the effect layer
  53482. */
  53483. getClassName(): string;
  53484. /**
  53485. * Creates an effect layer from parsed effect layer data
  53486. * @param parsedEffectLayer defines effect layer data
  53487. * @param scene defines the current scene
  53488. * @param rootUrl defines the root URL containing the effect layer information
  53489. * @returns a parsed effect Layer
  53490. */
  53491. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53492. }
  53493. }
  53494. declare module BABYLON {
  53495. interface AbstractScene {
  53496. /**
  53497. * The list of effect layers (highlights/glow) added to the scene
  53498. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53499. * @see http://doc.babylonjs.com/how_to/glow_layer
  53500. */
  53501. effectLayers: Array<EffectLayer>;
  53502. /**
  53503. * Removes the given effect layer from this scene.
  53504. * @param toRemove defines the effect layer to remove
  53505. * @returns the index of the removed effect layer
  53506. */
  53507. removeEffectLayer(toRemove: EffectLayer): number;
  53508. /**
  53509. * Adds the given effect layer to this scene
  53510. * @param newEffectLayer defines the effect layer to add
  53511. */
  53512. addEffectLayer(newEffectLayer: EffectLayer): void;
  53513. }
  53514. /**
  53515. * Defines the layer scene component responsible to manage any effect layers
  53516. * in a given scene.
  53517. */
  53518. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53519. /**
  53520. * The component name helpfull to identify the component in the list of scene components.
  53521. */
  53522. readonly name: string;
  53523. /**
  53524. * The scene the component belongs to.
  53525. */
  53526. scene: Scene;
  53527. private _engine;
  53528. private _renderEffects;
  53529. private _needStencil;
  53530. private _previousStencilState;
  53531. /**
  53532. * Creates a new instance of the component for the given scene
  53533. * @param scene Defines the scene to register the component in
  53534. */
  53535. constructor(scene: Scene);
  53536. /**
  53537. * Registers the component in a given scene
  53538. */
  53539. register(): void;
  53540. /**
  53541. * Rebuilds the elements related to this component in case of
  53542. * context lost for instance.
  53543. */
  53544. rebuild(): void;
  53545. /**
  53546. * Serializes the component data to the specified json object
  53547. * @param serializationObject The object to serialize to
  53548. */
  53549. serialize(serializationObject: any): void;
  53550. /**
  53551. * Adds all the elements from the container to the scene
  53552. * @param container the container holding the elements
  53553. */
  53554. addFromContainer(container: AbstractScene): void;
  53555. /**
  53556. * Removes all the elements in the container from the scene
  53557. * @param container contains the elements to remove
  53558. * @param dispose if the removed element should be disposed (default: false)
  53559. */
  53560. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53561. /**
  53562. * Disposes the component and the associated ressources.
  53563. */
  53564. dispose(): void;
  53565. private _isReadyForMesh;
  53566. private _renderMainTexture;
  53567. private _setStencil;
  53568. private _setStencilBack;
  53569. private _draw;
  53570. private _drawCamera;
  53571. private _drawRenderingGroup;
  53572. }
  53573. }
  53574. declare module BABYLON {
  53575. /** @hidden */
  53576. export var glowMapMergePixelShader: {
  53577. name: string;
  53578. shader: string;
  53579. };
  53580. }
  53581. declare module BABYLON {
  53582. /** @hidden */
  53583. export var glowMapMergeVertexShader: {
  53584. name: string;
  53585. shader: string;
  53586. };
  53587. }
  53588. declare module BABYLON {
  53589. interface AbstractScene {
  53590. /**
  53591. * Return a the first highlight layer of the scene with a given name.
  53592. * @param name The name of the highlight layer to look for.
  53593. * @return The highlight layer if found otherwise null.
  53594. */
  53595. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53596. }
  53597. /**
  53598. * Glow layer options. This helps customizing the behaviour
  53599. * of the glow layer.
  53600. */
  53601. export interface IGlowLayerOptions {
  53602. /**
  53603. * Multiplication factor apply to the canvas size to compute the render target size
  53604. * used to generated the glowing objects (the smaller the faster).
  53605. */
  53606. mainTextureRatio: number;
  53607. /**
  53608. * Enforces a fixed size texture to ensure resize independant blur.
  53609. */
  53610. mainTextureFixedSize?: number;
  53611. /**
  53612. * How big is the kernel of the blur texture.
  53613. */
  53614. blurKernelSize: number;
  53615. /**
  53616. * The camera attached to the layer.
  53617. */
  53618. camera: Nullable<Camera>;
  53619. /**
  53620. * Enable MSAA by chosing the number of samples.
  53621. */
  53622. mainTextureSamples?: number;
  53623. /**
  53624. * The rendering group to draw the layer in.
  53625. */
  53626. renderingGroupId: number;
  53627. }
  53628. /**
  53629. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53630. *
  53631. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53632. *
  53633. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53634. */
  53635. export class GlowLayer extends EffectLayer {
  53636. /**
  53637. * Effect Name of the layer.
  53638. */
  53639. static readonly EffectName: string;
  53640. /**
  53641. * The default blur kernel size used for the glow.
  53642. */
  53643. static DefaultBlurKernelSize: number;
  53644. /**
  53645. * The default texture size ratio used for the glow.
  53646. */
  53647. static DefaultTextureRatio: number;
  53648. /**
  53649. * Sets the kernel size of the blur.
  53650. */
  53651. set blurKernelSize(value: number);
  53652. /**
  53653. * Gets the kernel size of the blur.
  53654. */
  53655. get blurKernelSize(): number;
  53656. /**
  53657. * Sets the glow intensity.
  53658. */
  53659. set intensity(value: number);
  53660. /**
  53661. * Gets the glow intensity.
  53662. */
  53663. get intensity(): number;
  53664. private _options;
  53665. private _intensity;
  53666. private _horizontalBlurPostprocess1;
  53667. private _verticalBlurPostprocess1;
  53668. private _horizontalBlurPostprocess2;
  53669. private _verticalBlurPostprocess2;
  53670. private _blurTexture1;
  53671. private _blurTexture2;
  53672. private _postProcesses1;
  53673. private _postProcesses2;
  53674. private _includedOnlyMeshes;
  53675. private _excludedMeshes;
  53676. private _meshesUsingTheirOwnMaterials;
  53677. /**
  53678. * Callback used to let the user override the color selection on a per mesh basis
  53679. */
  53680. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53681. /**
  53682. * Callback used to let the user override the texture selection on a per mesh basis
  53683. */
  53684. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53685. /**
  53686. * Instantiates a new glow Layer and references it to the scene.
  53687. * @param name The name of the layer
  53688. * @param scene The scene to use the layer in
  53689. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53690. */
  53691. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53692. /**
  53693. * Get the effect name of the layer.
  53694. * @return The effect name
  53695. */
  53696. getEffectName(): string;
  53697. /**
  53698. * Create the merge effect. This is the shader use to blit the information back
  53699. * to the main canvas at the end of the scene rendering.
  53700. */
  53701. protected _createMergeEffect(): Effect;
  53702. /**
  53703. * Creates the render target textures and post processes used in the glow layer.
  53704. */
  53705. protected _createTextureAndPostProcesses(): void;
  53706. /**
  53707. * Checks for the readiness of the element composing the layer.
  53708. * @param subMesh the mesh to check for
  53709. * @param useInstances specify wether or not to use instances to render the mesh
  53710. * @param emissiveTexture the associated emissive texture used to generate the glow
  53711. * @return true if ready otherwise, false
  53712. */
  53713. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53714. /**
  53715. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53716. */
  53717. needStencil(): boolean;
  53718. /**
  53719. * Returns true if the mesh can be rendered, otherwise false.
  53720. * @param mesh The mesh to render
  53721. * @param material The material used on the mesh
  53722. * @returns true if it can be rendered otherwise false
  53723. */
  53724. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53725. /**
  53726. * Implementation specific of rendering the generating effect on the main canvas.
  53727. * @param effect The effect used to render through
  53728. */
  53729. protected _internalRender(effect: Effect): void;
  53730. /**
  53731. * Sets the required values for both the emissive texture and and the main color.
  53732. */
  53733. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53734. /**
  53735. * Returns true if the mesh should render, otherwise false.
  53736. * @param mesh The mesh to render
  53737. * @returns true if it should render otherwise false
  53738. */
  53739. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53740. /**
  53741. * Adds specific effects defines.
  53742. * @param defines The defines to add specifics to.
  53743. */
  53744. protected _addCustomEffectDefines(defines: string[]): void;
  53745. /**
  53746. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53747. * @param mesh The mesh to exclude from the glow layer
  53748. */
  53749. addExcludedMesh(mesh: Mesh): void;
  53750. /**
  53751. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53752. * @param mesh The mesh to remove
  53753. */
  53754. removeExcludedMesh(mesh: Mesh): void;
  53755. /**
  53756. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53757. * @param mesh The mesh to include in the glow layer
  53758. */
  53759. addIncludedOnlyMesh(mesh: Mesh): void;
  53760. /**
  53761. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53762. * @param mesh The mesh to remove
  53763. */
  53764. removeIncludedOnlyMesh(mesh: Mesh): void;
  53765. /**
  53766. * Determine if a given mesh will be used in the glow layer
  53767. * @param mesh The mesh to test
  53768. * @returns true if the mesh will be highlighted by the current glow layer
  53769. */
  53770. hasMesh(mesh: AbstractMesh): boolean;
  53771. /**
  53772. * Defines whether the current material of the mesh should be use to render the effect.
  53773. * @param mesh defines the current mesh to render
  53774. */
  53775. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53776. /**
  53777. * Add a mesh to be rendered through its own material and not with emissive only.
  53778. * @param mesh The mesh for which we need to use its material
  53779. */
  53780. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53781. /**
  53782. * Remove a mesh from being rendered through its own material and not with emissive only.
  53783. * @param mesh The mesh for which we need to not use its material
  53784. */
  53785. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53786. /**
  53787. * Free any resources and references associated to a mesh.
  53788. * Internal use
  53789. * @param mesh The mesh to free.
  53790. * @hidden
  53791. */
  53792. _disposeMesh(mesh: Mesh): void;
  53793. /**
  53794. * Gets the class name of the effect layer
  53795. * @returns the string with the class name of the effect layer
  53796. */
  53797. getClassName(): string;
  53798. /**
  53799. * Serializes this glow layer
  53800. * @returns a serialized glow layer object
  53801. */
  53802. serialize(): any;
  53803. /**
  53804. * Creates a Glow Layer from parsed glow layer data
  53805. * @param parsedGlowLayer defines glow layer data
  53806. * @param scene defines the current scene
  53807. * @param rootUrl defines the root URL containing the glow layer information
  53808. * @returns a parsed Glow Layer
  53809. */
  53810. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53811. }
  53812. }
  53813. declare module BABYLON {
  53814. /** @hidden */
  53815. export var glowBlurPostProcessPixelShader: {
  53816. name: string;
  53817. shader: string;
  53818. };
  53819. }
  53820. declare module BABYLON {
  53821. interface AbstractScene {
  53822. /**
  53823. * Return a the first highlight layer of the scene with a given name.
  53824. * @param name The name of the highlight layer to look for.
  53825. * @return The highlight layer if found otherwise null.
  53826. */
  53827. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53828. }
  53829. /**
  53830. * Highlight layer options. This helps customizing the behaviour
  53831. * of the highlight layer.
  53832. */
  53833. export interface IHighlightLayerOptions {
  53834. /**
  53835. * Multiplication factor apply to the canvas size to compute the render target size
  53836. * used to generated the glowing objects (the smaller the faster).
  53837. */
  53838. mainTextureRatio: number;
  53839. /**
  53840. * Enforces a fixed size texture to ensure resize independant blur.
  53841. */
  53842. mainTextureFixedSize?: number;
  53843. /**
  53844. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53845. * of the picture to blur (the smaller the faster).
  53846. */
  53847. blurTextureSizeRatio: number;
  53848. /**
  53849. * How big in texel of the blur texture is the vertical blur.
  53850. */
  53851. blurVerticalSize: number;
  53852. /**
  53853. * How big in texel of the blur texture is the horizontal blur.
  53854. */
  53855. blurHorizontalSize: number;
  53856. /**
  53857. * Alpha blending mode used to apply the blur. Default is combine.
  53858. */
  53859. alphaBlendingMode: number;
  53860. /**
  53861. * The camera attached to the layer.
  53862. */
  53863. camera: Nullable<Camera>;
  53864. /**
  53865. * Should we display highlight as a solid stroke?
  53866. */
  53867. isStroke?: boolean;
  53868. /**
  53869. * The rendering group to draw the layer in.
  53870. */
  53871. renderingGroupId: number;
  53872. }
  53873. /**
  53874. * The highlight layer Helps adding a glow effect around a mesh.
  53875. *
  53876. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53877. * glowy meshes to your scene.
  53878. *
  53879. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53880. */
  53881. export class HighlightLayer extends EffectLayer {
  53882. name: string;
  53883. /**
  53884. * Effect Name of the highlight layer.
  53885. */
  53886. static readonly EffectName: string;
  53887. /**
  53888. * The neutral color used during the preparation of the glow effect.
  53889. * This is black by default as the blend operation is a blend operation.
  53890. */
  53891. static NeutralColor: Color4;
  53892. /**
  53893. * Stencil value used for glowing meshes.
  53894. */
  53895. static GlowingMeshStencilReference: number;
  53896. /**
  53897. * Stencil value used for the other meshes in the scene.
  53898. */
  53899. static NormalMeshStencilReference: number;
  53900. /**
  53901. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53902. */
  53903. innerGlow: boolean;
  53904. /**
  53905. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53906. */
  53907. outerGlow: boolean;
  53908. /**
  53909. * Specifies the horizontal size of the blur.
  53910. */
  53911. set blurHorizontalSize(value: number);
  53912. /**
  53913. * Specifies the vertical size of the blur.
  53914. */
  53915. set blurVerticalSize(value: number);
  53916. /**
  53917. * Gets the horizontal size of the blur.
  53918. */
  53919. get blurHorizontalSize(): number;
  53920. /**
  53921. * Gets the vertical size of the blur.
  53922. */
  53923. get blurVerticalSize(): number;
  53924. /**
  53925. * An event triggered when the highlight layer is being blurred.
  53926. */
  53927. onBeforeBlurObservable: Observable<HighlightLayer>;
  53928. /**
  53929. * An event triggered when the highlight layer has been blurred.
  53930. */
  53931. onAfterBlurObservable: Observable<HighlightLayer>;
  53932. private _instanceGlowingMeshStencilReference;
  53933. private _options;
  53934. private _downSamplePostprocess;
  53935. private _horizontalBlurPostprocess;
  53936. private _verticalBlurPostprocess;
  53937. private _blurTexture;
  53938. private _meshes;
  53939. private _excludedMeshes;
  53940. /**
  53941. * Instantiates a new highlight Layer and references it to the scene..
  53942. * @param name The name of the layer
  53943. * @param scene The scene to use the layer in
  53944. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53945. */
  53946. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53947. /**
  53948. * Get the effect name of the layer.
  53949. * @return The effect name
  53950. */
  53951. getEffectName(): string;
  53952. /**
  53953. * Create the merge effect. This is the shader use to blit the information back
  53954. * to the main canvas at the end of the scene rendering.
  53955. */
  53956. protected _createMergeEffect(): Effect;
  53957. /**
  53958. * Creates the render target textures and post processes used in the highlight layer.
  53959. */
  53960. protected _createTextureAndPostProcesses(): void;
  53961. /**
  53962. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53963. */
  53964. needStencil(): boolean;
  53965. /**
  53966. * Checks for the readiness of the element composing the layer.
  53967. * @param subMesh the mesh to check for
  53968. * @param useInstances specify wether or not to use instances to render the mesh
  53969. * @param emissiveTexture the associated emissive texture used to generate the glow
  53970. * @return true if ready otherwise, false
  53971. */
  53972. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53973. /**
  53974. * Implementation specific of rendering the generating effect on the main canvas.
  53975. * @param effect The effect used to render through
  53976. */
  53977. protected _internalRender(effect: Effect): void;
  53978. /**
  53979. * Returns true if the layer contains information to display, otherwise false.
  53980. */
  53981. shouldRender(): boolean;
  53982. /**
  53983. * Returns true if the mesh should render, otherwise false.
  53984. * @param mesh The mesh to render
  53985. * @returns true if it should render otherwise false
  53986. */
  53987. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53988. /**
  53989. * Adds specific effects defines.
  53990. * @param defines The defines to add specifics to.
  53991. */
  53992. protected _addCustomEffectDefines(defines: string[]): void;
  53993. /**
  53994. * Sets the required values for both the emissive texture and and the main color.
  53995. */
  53996. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53997. /**
  53998. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53999. * @param mesh The mesh to exclude from the highlight layer
  54000. */
  54001. addExcludedMesh(mesh: Mesh): void;
  54002. /**
  54003. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54004. * @param mesh The mesh to highlight
  54005. */
  54006. removeExcludedMesh(mesh: Mesh): void;
  54007. /**
  54008. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54009. * @param mesh mesh to test
  54010. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54011. */
  54012. hasMesh(mesh: AbstractMesh): boolean;
  54013. /**
  54014. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54015. * @param mesh The mesh to highlight
  54016. * @param color The color of the highlight
  54017. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54018. */
  54019. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54020. /**
  54021. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54022. * @param mesh The mesh to highlight
  54023. */
  54024. removeMesh(mesh: Mesh): void;
  54025. /**
  54026. * Remove all the meshes currently referenced in the highlight layer
  54027. */
  54028. removeAllMeshes(): void;
  54029. /**
  54030. * Force the stencil to the normal expected value for none glowing parts
  54031. */
  54032. private _defaultStencilReference;
  54033. /**
  54034. * Free any resources and references associated to a mesh.
  54035. * Internal use
  54036. * @param mesh The mesh to free.
  54037. * @hidden
  54038. */
  54039. _disposeMesh(mesh: Mesh): void;
  54040. /**
  54041. * Dispose the highlight layer and free resources.
  54042. */
  54043. dispose(): void;
  54044. /**
  54045. * Gets the class name of the effect layer
  54046. * @returns the string with the class name of the effect layer
  54047. */
  54048. getClassName(): string;
  54049. /**
  54050. * Serializes this Highlight layer
  54051. * @returns a serialized Highlight layer object
  54052. */
  54053. serialize(): any;
  54054. /**
  54055. * Creates a Highlight layer from parsed Highlight layer data
  54056. * @param parsedHightlightLayer defines the Highlight layer data
  54057. * @param scene defines the current scene
  54058. * @param rootUrl defines the root URL containing the Highlight layer information
  54059. * @returns a parsed Highlight layer
  54060. */
  54061. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54062. }
  54063. }
  54064. declare module BABYLON {
  54065. interface AbstractScene {
  54066. /**
  54067. * The list of layers (background and foreground) of the scene
  54068. */
  54069. layers: Array<Layer>;
  54070. }
  54071. /**
  54072. * Defines the layer scene component responsible to manage any layers
  54073. * in a given scene.
  54074. */
  54075. export class LayerSceneComponent implements ISceneComponent {
  54076. /**
  54077. * The component name helpfull to identify the component in the list of scene components.
  54078. */
  54079. readonly name: string;
  54080. /**
  54081. * The scene the component belongs to.
  54082. */
  54083. scene: Scene;
  54084. private _engine;
  54085. /**
  54086. * Creates a new instance of the component for the given scene
  54087. * @param scene Defines the scene to register the component in
  54088. */
  54089. constructor(scene: Scene);
  54090. /**
  54091. * Registers the component in a given scene
  54092. */
  54093. register(): void;
  54094. /**
  54095. * Rebuilds the elements related to this component in case of
  54096. * context lost for instance.
  54097. */
  54098. rebuild(): void;
  54099. /**
  54100. * Disposes the component and the associated ressources.
  54101. */
  54102. dispose(): void;
  54103. private _draw;
  54104. private _drawCameraPredicate;
  54105. private _drawCameraBackground;
  54106. private _drawCameraForeground;
  54107. private _drawRenderTargetPredicate;
  54108. private _drawRenderTargetBackground;
  54109. private _drawRenderTargetForeground;
  54110. /**
  54111. * Adds all the elements from the container to the scene
  54112. * @param container the container holding the elements
  54113. */
  54114. addFromContainer(container: AbstractScene): void;
  54115. /**
  54116. * Removes all the elements in the container from the scene
  54117. * @param container contains the elements to remove
  54118. * @param dispose if the removed element should be disposed (default: false)
  54119. */
  54120. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54121. }
  54122. }
  54123. declare module BABYLON {
  54124. /** @hidden */
  54125. export var layerPixelShader: {
  54126. name: string;
  54127. shader: string;
  54128. };
  54129. }
  54130. declare module BABYLON {
  54131. /** @hidden */
  54132. export var layerVertexShader: {
  54133. name: string;
  54134. shader: string;
  54135. };
  54136. }
  54137. declare module BABYLON {
  54138. /**
  54139. * This represents a full screen 2d layer.
  54140. * This can be useful to display a picture in the background of your scene for instance.
  54141. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54142. */
  54143. export class Layer {
  54144. /**
  54145. * Define the name of the layer.
  54146. */
  54147. name: string;
  54148. /**
  54149. * Define the texture the layer should display.
  54150. */
  54151. texture: Nullable<Texture>;
  54152. /**
  54153. * Is the layer in background or foreground.
  54154. */
  54155. isBackground: boolean;
  54156. /**
  54157. * Define the color of the layer (instead of texture).
  54158. */
  54159. color: Color4;
  54160. /**
  54161. * Define the scale of the layer in order to zoom in out of the texture.
  54162. */
  54163. scale: Vector2;
  54164. /**
  54165. * Define an offset for the layer in order to shift the texture.
  54166. */
  54167. offset: Vector2;
  54168. /**
  54169. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54170. */
  54171. alphaBlendingMode: number;
  54172. /**
  54173. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54174. * Alpha test will not mix with the background color in case of transparency.
  54175. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54176. */
  54177. alphaTest: boolean;
  54178. /**
  54179. * Define a mask to restrict the layer to only some of the scene cameras.
  54180. */
  54181. layerMask: number;
  54182. /**
  54183. * Define the list of render target the layer is visible into.
  54184. */
  54185. renderTargetTextures: RenderTargetTexture[];
  54186. /**
  54187. * Define if the layer is only used in renderTarget or if it also
  54188. * renders in the main frame buffer of the canvas.
  54189. */
  54190. renderOnlyInRenderTargetTextures: boolean;
  54191. private _scene;
  54192. private _vertexBuffers;
  54193. private _indexBuffer;
  54194. private _effect;
  54195. private _previousDefines;
  54196. /**
  54197. * An event triggered when the layer is disposed.
  54198. */
  54199. onDisposeObservable: Observable<Layer>;
  54200. private _onDisposeObserver;
  54201. /**
  54202. * Back compatibility with callback before the onDisposeObservable existed.
  54203. * The set callback will be triggered when the layer has been disposed.
  54204. */
  54205. set onDispose(callback: () => void);
  54206. /**
  54207. * An event triggered before rendering the scene
  54208. */
  54209. onBeforeRenderObservable: Observable<Layer>;
  54210. private _onBeforeRenderObserver;
  54211. /**
  54212. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54213. * The set callback will be triggered just before rendering the layer.
  54214. */
  54215. set onBeforeRender(callback: () => void);
  54216. /**
  54217. * An event triggered after rendering the scene
  54218. */
  54219. onAfterRenderObservable: Observable<Layer>;
  54220. private _onAfterRenderObserver;
  54221. /**
  54222. * Back compatibility with callback before the onAfterRenderObservable existed.
  54223. * The set callback will be triggered just after rendering the layer.
  54224. */
  54225. set onAfterRender(callback: () => void);
  54226. /**
  54227. * Instantiates a new layer.
  54228. * This represents a full screen 2d layer.
  54229. * This can be useful to display a picture in the background of your scene for instance.
  54230. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54231. * @param name Define the name of the layer in the scene
  54232. * @param imgUrl Define the url of the texture to display in the layer
  54233. * @param scene Define the scene the layer belongs to
  54234. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54235. * @param color Defines a color for the layer
  54236. */
  54237. constructor(
  54238. /**
  54239. * Define the name of the layer.
  54240. */
  54241. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54242. private _createIndexBuffer;
  54243. /** @hidden */
  54244. _rebuild(): void;
  54245. /**
  54246. * Renders the layer in the scene.
  54247. */
  54248. render(): void;
  54249. /**
  54250. * Disposes and releases the associated ressources.
  54251. */
  54252. dispose(): void;
  54253. }
  54254. }
  54255. declare module BABYLON {
  54256. /** @hidden */
  54257. export var lensFlarePixelShader: {
  54258. name: string;
  54259. shader: string;
  54260. };
  54261. }
  54262. declare module BABYLON {
  54263. /** @hidden */
  54264. export var lensFlareVertexShader: {
  54265. name: string;
  54266. shader: string;
  54267. };
  54268. }
  54269. declare module BABYLON {
  54270. /**
  54271. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54272. * It is usually composed of several `lensFlare`.
  54273. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54274. */
  54275. export class LensFlareSystem {
  54276. /**
  54277. * Define the name of the lens flare system
  54278. */
  54279. name: string;
  54280. /**
  54281. * List of lens flares used in this system.
  54282. */
  54283. lensFlares: LensFlare[];
  54284. /**
  54285. * Define a limit from the border the lens flare can be visible.
  54286. */
  54287. borderLimit: number;
  54288. /**
  54289. * Define a viewport border we do not want to see the lens flare in.
  54290. */
  54291. viewportBorder: number;
  54292. /**
  54293. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54294. */
  54295. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54296. /**
  54297. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54298. */
  54299. layerMask: number;
  54300. /**
  54301. * Define the id of the lens flare system in the scene.
  54302. * (equal to name by default)
  54303. */
  54304. id: string;
  54305. private _scene;
  54306. private _emitter;
  54307. private _vertexBuffers;
  54308. private _indexBuffer;
  54309. private _effect;
  54310. private _positionX;
  54311. private _positionY;
  54312. private _isEnabled;
  54313. /** @hidden */
  54314. static _SceneComponentInitialization: (scene: Scene) => void;
  54315. /**
  54316. * Instantiates a lens flare system.
  54317. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54318. * It is usually composed of several `lensFlare`.
  54319. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54320. * @param name Define the name of the lens flare system in the scene
  54321. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54322. * @param scene Define the scene the lens flare system belongs to
  54323. */
  54324. constructor(
  54325. /**
  54326. * Define the name of the lens flare system
  54327. */
  54328. name: string, emitter: any, scene: Scene);
  54329. /**
  54330. * Define if the lens flare system is enabled.
  54331. */
  54332. get isEnabled(): boolean;
  54333. set isEnabled(value: boolean);
  54334. /**
  54335. * Get the scene the effects belongs to.
  54336. * @returns the scene holding the lens flare system
  54337. */
  54338. getScene(): Scene;
  54339. /**
  54340. * Get the emitter of the lens flare system.
  54341. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54342. * @returns the emitter of the lens flare system
  54343. */
  54344. getEmitter(): any;
  54345. /**
  54346. * Set the emitter of the lens flare system.
  54347. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54348. * @param newEmitter Define the new emitter of the system
  54349. */
  54350. setEmitter(newEmitter: any): void;
  54351. /**
  54352. * Get the lens flare system emitter position.
  54353. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54354. * @returns the position
  54355. */
  54356. getEmitterPosition(): Vector3;
  54357. /**
  54358. * @hidden
  54359. */
  54360. computeEffectivePosition(globalViewport: Viewport): boolean;
  54361. /** @hidden */
  54362. _isVisible(): boolean;
  54363. /**
  54364. * @hidden
  54365. */
  54366. render(): boolean;
  54367. /**
  54368. * Dispose and release the lens flare with its associated resources.
  54369. */
  54370. dispose(): void;
  54371. /**
  54372. * Parse a lens flare system from a JSON repressentation
  54373. * @param parsedLensFlareSystem Define the JSON to parse
  54374. * @param scene Define the scene the parsed system should be instantiated in
  54375. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54376. * @returns the parsed system
  54377. */
  54378. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54379. /**
  54380. * Serialize the current Lens Flare System into a JSON representation.
  54381. * @returns the serialized JSON
  54382. */
  54383. serialize(): any;
  54384. }
  54385. }
  54386. declare module BABYLON {
  54387. /**
  54388. * This represents one of the lens effect in a `lensFlareSystem`.
  54389. * It controls one of the indiviual texture used in the effect.
  54390. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54391. */
  54392. export class LensFlare {
  54393. /**
  54394. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54395. */
  54396. size: number;
  54397. /**
  54398. * 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.
  54399. */
  54400. position: number;
  54401. /**
  54402. * Define the lens color.
  54403. */
  54404. color: Color3;
  54405. /**
  54406. * Define the lens texture.
  54407. */
  54408. texture: Nullable<Texture>;
  54409. /**
  54410. * Define the alpha mode to render this particular lens.
  54411. */
  54412. alphaMode: number;
  54413. private _system;
  54414. /**
  54415. * Creates a new Lens Flare.
  54416. * This represents one of the lens effect in a `lensFlareSystem`.
  54417. * It controls one of the indiviual texture used in the effect.
  54418. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54419. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54420. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  54421. * @param color Define the lens color
  54422. * @param imgUrl Define the lens texture url
  54423. * @param system Define the `lensFlareSystem` this flare is part of
  54424. * @returns The newly created Lens Flare
  54425. */
  54426. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54427. /**
  54428. * Instantiates a new Lens Flare.
  54429. * This represents one of the lens effect in a `lensFlareSystem`.
  54430. * It controls one of the indiviual texture used in the effect.
  54431. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54432. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54433. * @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.
  54434. * @param color Define the lens color
  54435. * @param imgUrl Define the lens texture url
  54436. * @param system Define the `lensFlareSystem` this flare is part of
  54437. */
  54438. constructor(
  54439. /**
  54440. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54441. */
  54442. size: number,
  54443. /**
  54444. * 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.
  54445. */
  54446. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54447. /**
  54448. * Dispose and release the lens flare with its associated resources.
  54449. */
  54450. dispose(): void;
  54451. }
  54452. }
  54453. declare module BABYLON {
  54454. interface AbstractScene {
  54455. /**
  54456. * The list of lens flare system added to the scene
  54457. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54458. */
  54459. lensFlareSystems: Array<LensFlareSystem>;
  54460. /**
  54461. * Removes the given lens flare system from this scene.
  54462. * @param toRemove The lens flare system to remove
  54463. * @returns The index of the removed lens flare system
  54464. */
  54465. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54466. /**
  54467. * Adds the given lens flare system to this scene
  54468. * @param newLensFlareSystem The lens flare system to add
  54469. */
  54470. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54471. /**
  54472. * Gets a lens flare system using its name
  54473. * @param name defines the name to look for
  54474. * @returns the lens flare system or null if not found
  54475. */
  54476. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54477. /**
  54478. * Gets a lens flare system using its id
  54479. * @param id defines the id to look for
  54480. * @returns the lens flare system or null if not found
  54481. */
  54482. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54483. }
  54484. /**
  54485. * Defines the lens flare scene component responsible to manage any lens flares
  54486. * in a given scene.
  54487. */
  54488. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54489. /**
  54490. * The component name helpfull to identify the component in the list of scene components.
  54491. */
  54492. readonly name: string;
  54493. /**
  54494. * The scene the component belongs to.
  54495. */
  54496. scene: Scene;
  54497. /**
  54498. * Creates a new instance of the component for the given scene
  54499. * @param scene Defines the scene to register the component in
  54500. */
  54501. constructor(scene: Scene);
  54502. /**
  54503. * Registers the component in a given scene
  54504. */
  54505. register(): void;
  54506. /**
  54507. * Rebuilds the elements related to this component in case of
  54508. * context lost for instance.
  54509. */
  54510. rebuild(): void;
  54511. /**
  54512. * Adds all the elements from the container to the scene
  54513. * @param container the container holding the elements
  54514. */
  54515. addFromContainer(container: AbstractScene): void;
  54516. /**
  54517. * Removes all the elements in the container from the scene
  54518. * @param container contains the elements to remove
  54519. * @param dispose if the removed element should be disposed (default: false)
  54520. */
  54521. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54522. /**
  54523. * Serializes the component data to the specified json object
  54524. * @param serializationObject The object to serialize to
  54525. */
  54526. serialize(serializationObject: any): void;
  54527. /**
  54528. * Disposes the component and the associated ressources.
  54529. */
  54530. dispose(): void;
  54531. private _draw;
  54532. }
  54533. }
  54534. declare module BABYLON {
  54535. /** @hidden */
  54536. export var depthPixelShader: {
  54537. name: string;
  54538. shader: string;
  54539. };
  54540. }
  54541. declare module BABYLON {
  54542. /** @hidden */
  54543. export var depthVertexShader: {
  54544. name: string;
  54545. shader: string;
  54546. };
  54547. }
  54548. declare module BABYLON {
  54549. /**
  54550. * This represents a depth renderer in Babylon.
  54551. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54552. */
  54553. export class DepthRenderer {
  54554. private _scene;
  54555. private _depthMap;
  54556. private _effect;
  54557. private readonly _storeNonLinearDepth;
  54558. private readonly _clearColor;
  54559. /** Get if the depth renderer is using packed depth or not */
  54560. readonly isPacked: boolean;
  54561. private _cachedDefines;
  54562. private _camera;
  54563. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54564. enabled: boolean;
  54565. /**
  54566. * Specifiess that the depth renderer will only be used within
  54567. * the camera it is created for.
  54568. * This can help forcing its rendering during the camera processing.
  54569. */
  54570. useOnlyInActiveCamera: boolean;
  54571. /** @hidden */
  54572. static _SceneComponentInitialization: (scene: Scene) => void;
  54573. /**
  54574. * Instantiates a depth renderer
  54575. * @param scene The scene the renderer belongs to
  54576. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54577. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54578. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54579. */
  54580. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54581. /**
  54582. * Creates the depth rendering effect and checks if the effect is ready.
  54583. * @param subMesh The submesh to be used to render the depth map of
  54584. * @param useInstances If multiple world instances should be used
  54585. * @returns if the depth renderer is ready to render the depth map
  54586. */
  54587. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54588. /**
  54589. * Gets the texture which the depth map will be written to.
  54590. * @returns The depth map texture
  54591. */
  54592. getDepthMap(): RenderTargetTexture;
  54593. /**
  54594. * Disposes of the depth renderer.
  54595. */
  54596. dispose(): void;
  54597. }
  54598. }
  54599. declare module BABYLON {
  54600. /** @hidden */
  54601. export var minmaxReduxPixelShader: {
  54602. name: string;
  54603. shader: string;
  54604. };
  54605. }
  54606. declare module BABYLON {
  54607. /**
  54608. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54609. * and maximum values from all values of the texture.
  54610. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54611. * The source values are read from the red channel of the texture.
  54612. */
  54613. export class MinMaxReducer {
  54614. /**
  54615. * Observable triggered when the computation has been performed
  54616. */
  54617. onAfterReductionPerformed: Observable<{
  54618. min: number;
  54619. max: number;
  54620. }>;
  54621. protected _camera: Camera;
  54622. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54623. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54624. protected _postProcessManager: PostProcessManager;
  54625. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54626. protected _forceFullscreenViewport: boolean;
  54627. /**
  54628. * Creates a min/max reducer
  54629. * @param camera The camera to use for the post processes
  54630. */
  54631. constructor(camera: Camera);
  54632. /**
  54633. * Gets the texture used to read the values from.
  54634. */
  54635. get sourceTexture(): Nullable<RenderTargetTexture>;
  54636. /**
  54637. * Sets the source texture to read the values from.
  54638. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54639. * because in such textures '1' value must not be taken into account to compute the maximum
  54640. * as this value is used to clear the texture.
  54641. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54642. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54643. * @param depthRedux Indicates if the texture is a depth texture or not
  54644. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54645. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54646. */
  54647. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54648. /**
  54649. * Defines the refresh rate of the computation.
  54650. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54651. */
  54652. get refreshRate(): number;
  54653. set refreshRate(value: number);
  54654. protected _activated: boolean;
  54655. /**
  54656. * Gets the activation status of the reducer
  54657. */
  54658. get activated(): boolean;
  54659. /**
  54660. * Activates the reduction computation.
  54661. * When activated, the observers registered in onAfterReductionPerformed are
  54662. * called after the compuation is performed
  54663. */
  54664. activate(): void;
  54665. /**
  54666. * Deactivates the reduction computation.
  54667. */
  54668. deactivate(): void;
  54669. /**
  54670. * Disposes the min/max reducer
  54671. * @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.
  54672. */
  54673. dispose(disposeAll?: boolean): void;
  54674. }
  54675. }
  54676. declare module BABYLON {
  54677. /**
  54678. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54679. */
  54680. export class DepthReducer extends MinMaxReducer {
  54681. private _depthRenderer;
  54682. private _depthRendererId;
  54683. /**
  54684. * Gets the depth renderer used for the computation.
  54685. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54686. */
  54687. get depthRenderer(): Nullable<DepthRenderer>;
  54688. /**
  54689. * Creates a depth reducer
  54690. * @param camera The camera used to render the depth texture
  54691. */
  54692. constructor(camera: Camera);
  54693. /**
  54694. * Sets the depth renderer to use to generate the depth map
  54695. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54696. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54697. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54698. */
  54699. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54700. /** @hidden */
  54701. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54702. /**
  54703. * Activates the reduction computation.
  54704. * When activated, the observers registered in onAfterReductionPerformed are
  54705. * called after the compuation is performed
  54706. */
  54707. activate(): void;
  54708. /**
  54709. * Deactivates the reduction computation.
  54710. */
  54711. deactivate(): void;
  54712. /**
  54713. * Disposes the depth reducer
  54714. * @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.
  54715. */
  54716. dispose(disposeAll?: boolean): void;
  54717. }
  54718. }
  54719. declare module BABYLON {
  54720. /**
  54721. * A CSM implementation allowing casting shadows on large scenes.
  54722. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54723. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54724. */
  54725. export class CascadedShadowGenerator extends ShadowGenerator {
  54726. private static readonly frustumCornersNDCSpace;
  54727. /**
  54728. * Name of the CSM class
  54729. */
  54730. static CLASSNAME: string;
  54731. /**
  54732. * Defines the default number of cascades used by the CSM.
  54733. */
  54734. static readonly DEFAULT_CASCADES_COUNT: number;
  54735. /**
  54736. * Defines the minimum number of cascades used by the CSM.
  54737. */
  54738. static readonly MIN_CASCADES_COUNT: number;
  54739. /**
  54740. * Defines the maximum number of cascades used by the CSM.
  54741. */
  54742. static readonly MAX_CASCADES_COUNT: number;
  54743. protected _validateFilter(filter: number): number;
  54744. /**
  54745. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54746. */
  54747. penumbraDarkness: number;
  54748. private _numCascades;
  54749. /**
  54750. * Gets or set the number of cascades used by the CSM.
  54751. */
  54752. get numCascades(): number;
  54753. set numCascades(value: number);
  54754. /**
  54755. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54756. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54757. */
  54758. stabilizeCascades: boolean;
  54759. private _freezeShadowCastersBoundingInfo;
  54760. private _freezeShadowCastersBoundingInfoObservable;
  54761. /**
  54762. * Enables or disables the shadow casters bounding info computation.
  54763. * If your shadow casters don't move, you can disable this feature.
  54764. * If it is enabled, the bounding box computation is done every frame.
  54765. */
  54766. get freezeShadowCastersBoundingInfo(): boolean;
  54767. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54768. private _scbiMin;
  54769. private _scbiMax;
  54770. protected _computeShadowCastersBoundingInfo(): void;
  54771. protected _shadowCastersBoundingInfo: BoundingInfo;
  54772. /**
  54773. * Gets or sets the shadow casters bounding info.
  54774. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54775. * so that the system won't overwrite the bounds you provide
  54776. */
  54777. get shadowCastersBoundingInfo(): BoundingInfo;
  54778. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54779. protected _breaksAreDirty: boolean;
  54780. protected _minDistance: number;
  54781. protected _maxDistance: number;
  54782. /**
  54783. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54784. *
  54785. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54786. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54787. * @param min minimal distance for the breaks (default to 0.)
  54788. * @param max maximal distance for the breaks (default to 1.)
  54789. */
  54790. setMinMaxDistance(min: number, max: number): void;
  54791. /** Gets the minimal distance used in the cascade break computation */
  54792. get minDistance(): number;
  54793. /** Gets the maximal distance used in the cascade break computation */
  54794. get maxDistance(): number;
  54795. /**
  54796. * Gets the class name of that object
  54797. * @returns "CascadedShadowGenerator"
  54798. */
  54799. getClassName(): string;
  54800. private _cascadeMinExtents;
  54801. private _cascadeMaxExtents;
  54802. /**
  54803. * Gets a cascade minimum extents
  54804. * @param cascadeIndex index of the cascade
  54805. * @returns the minimum cascade extents
  54806. */
  54807. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54808. /**
  54809. * Gets a cascade maximum extents
  54810. * @param cascadeIndex index of the cascade
  54811. * @returns the maximum cascade extents
  54812. */
  54813. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54814. private _cascades;
  54815. private _currentLayer;
  54816. private _viewSpaceFrustumsZ;
  54817. private _viewMatrices;
  54818. private _projectionMatrices;
  54819. private _transformMatrices;
  54820. private _transformMatricesAsArray;
  54821. private _frustumLengths;
  54822. private _lightSizeUVCorrection;
  54823. private _depthCorrection;
  54824. private _frustumCornersWorldSpace;
  54825. private _frustumCenter;
  54826. private _shadowCameraPos;
  54827. private _shadowMaxZ;
  54828. /**
  54829. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54830. * It defaults to camera.maxZ
  54831. */
  54832. get shadowMaxZ(): number;
  54833. /**
  54834. * Sets the shadow max z distance.
  54835. */
  54836. set shadowMaxZ(value: number);
  54837. protected _debug: boolean;
  54838. /**
  54839. * Gets or sets the debug flag.
  54840. * When enabled, the cascades are materialized by different colors on the screen.
  54841. */
  54842. get debug(): boolean;
  54843. set debug(dbg: boolean);
  54844. private _depthClamp;
  54845. /**
  54846. * Gets or sets the depth clamping value.
  54847. *
  54848. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54849. * to account for the shadow casters far away.
  54850. *
  54851. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54852. */
  54853. get depthClamp(): boolean;
  54854. set depthClamp(value: boolean);
  54855. private _cascadeBlendPercentage;
  54856. /**
  54857. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54858. * It defaults to 0.1 (10% blending).
  54859. */
  54860. get cascadeBlendPercentage(): number;
  54861. set cascadeBlendPercentage(value: number);
  54862. private _lambda;
  54863. /**
  54864. * Gets or set the lambda parameter.
  54865. * This parameter is used to split the camera frustum and create the cascades.
  54866. * 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.
  54867. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54868. */
  54869. get lambda(): number;
  54870. set lambda(value: number);
  54871. /**
  54872. * Gets the view matrix corresponding to a given cascade
  54873. * @param cascadeNum cascade to retrieve the view matrix from
  54874. * @returns the cascade view matrix
  54875. */
  54876. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54877. /**
  54878. * Gets the projection matrix corresponding to a given cascade
  54879. * @param cascadeNum cascade to retrieve the projection matrix from
  54880. * @returns the cascade projection matrix
  54881. */
  54882. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54883. /**
  54884. * Gets the transformation matrix corresponding to a given cascade
  54885. * @param cascadeNum cascade to retrieve the transformation matrix from
  54886. * @returns the cascade transformation matrix
  54887. */
  54888. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54889. private _depthRenderer;
  54890. /**
  54891. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54892. *
  54893. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54894. *
  54895. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54896. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54897. * @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
  54898. */
  54899. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54900. private _depthReducer;
  54901. private _autoCalcDepthBounds;
  54902. /**
  54903. * Gets or sets the autoCalcDepthBounds property.
  54904. *
  54905. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54906. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54907. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54908. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54909. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54910. */
  54911. get autoCalcDepthBounds(): boolean;
  54912. set autoCalcDepthBounds(value: boolean);
  54913. /**
  54914. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54915. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54916. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54917. * for setting the refresh rate on the renderer yourself!
  54918. */
  54919. get autoCalcDepthBoundsRefreshRate(): number;
  54920. set autoCalcDepthBoundsRefreshRate(value: number);
  54921. /**
  54922. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54923. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54924. * you change the camera near/far planes!
  54925. */
  54926. splitFrustum(): void;
  54927. private _splitFrustum;
  54928. private _computeMatrices;
  54929. private _computeFrustumInWorldSpace;
  54930. private _computeCascadeFrustum;
  54931. /**
  54932. * Support test.
  54933. */
  54934. static get IsSupported(): boolean;
  54935. /** @hidden */
  54936. static _SceneComponentInitialization: (scene: Scene) => void;
  54937. /**
  54938. * Creates a Cascaded Shadow Generator object.
  54939. * A ShadowGenerator is the required tool to use the shadows.
  54940. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54941. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54942. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54943. * @param light The directional light object generating the shadows.
  54944. * @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.
  54945. */
  54946. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54947. protected _initializeGenerator(): void;
  54948. protected _createTargetRenderTexture(): void;
  54949. protected _initializeShadowMap(): void;
  54950. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54951. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54952. /**
  54953. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54954. * @param defines Defines of the material we want to update
  54955. * @param lightIndex Index of the light in the enabled light list of the material
  54956. */
  54957. prepareDefines(defines: any, lightIndex: number): void;
  54958. /**
  54959. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54960. * defined in the generator but impacting the effect).
  54961. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54962. * @param effect The effect we are binfing the information for
  54963. */
  54964. bindShadowLight(lightIndex: string, effect: Effect): void;
  54965. /**
  54966. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54967. * (eq to view projection * shadow projection matrices)
  54968. * @returns The transform matrix used to create the shadow map
  54969. */
  54970. getTransformMatrix(): Matrix;
  54971. /**
  54972. * Disposes the ShadowGenerator.
  54973. * Returns nothing.
  54974. */
  54975. dispose(): void;
  54976. /**
  54977. * Serializes the shadow generator setup to a json object.
  54978. * @returns The serialized JSON object
  54979. */
  54980. serialize(): any;
  54981. /**
  54982. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54983. * @param parsedShadowGenerator The JSON object to parse
  54984. * @param scene The scene to create the shadow map for
  54985. * @returns The parsed shadow generator
  54986. */
  54987. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54988. }
  54989. }
  54990. declare module BABYLON {
  54991. /**
  54992. * Defines the shadow generator component responsible to manage any shadow generators
  54993. * in a given scene.
  54994. */
  54995. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54996. /**
  54997. * The component name helpfull to identify the component in the list of scene components.
  54998. */
  54999. readonly name: string;
  55000. /**
  55001. * The scene the component belongs to.
  55002. */
  55003. scene: Scene;
  55004. /**
  55005. * Creates a new instance of the component for the given scene
  55006. * @param scene Defines the scene to register the component in
  55007. */
  55008. constructor(scene: Scene);
  55009. /**
  55010. * Registers the component in a given scene
  55011. */
  55012. register(): void;
  55013. /**
  55014. * Rebuilds the elements related to this component in case of
  55015. * context lost for instance.
  55016. */
  55017. rebuild(): void;
  55018. /**
  55019. * Serializes the component data to the specified json object
  55020. * @param serializationObject The object to serialize to
  55021. */
  55022. serialize(serializationObject: any): void;
  55023. /**
  55024. * Adds all the elements from the container to the scene
  55025. * @param container the container holding the elements
  55026. */
  55027. addFromContainer(container: AbstractScene): void;
  55028. /**
  55029. * Removes all the elements in the container from the scene
  55030. * @param container contains the elements to remove
  55031. * @param dispose if the removed element should be disposed (default: false)
  55032. */
  55033. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55034. /**
  55035. * Rebuilds the elements related to this component in case of
  55036. * context lost for instance.
  55037. */
  55038. dispose(): void;
  55039. private _gatherRenderTargets;
  55040. }
  55041. }
  55042. declare module BABYLON {
  55043. /**
  55044. * A point light is a light defined by an unique point in world space.
  55045. * The light is emitted in every direction from this point.
  55046. * A good example of a point light is a standard light bulb.
  55047. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55048. */
  55049. export class PointLight extends ShadowLight {
  55050. private _shadowAngle;
  55051. /**
  55052. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55053. * This specifies what angle the shadow will use to be created.
  55054. *
  55055. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55056. */
  55057. get shadowAngle(): number;
  55058. /**
  55059. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55060. * This specifies what angle the shadow will use to be created.
  55061. *
  55062. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55063. */
  55064. set shadowAngle(value: number);
  55065. /**
  55066. * Gets the direction if it has been set.
  55067. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55068. */
  55069. get direction(): Vector3;
  55070. /**
  55071. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55072. */
  55073. set direction(value: Vector3);
  55074. /**
  55075. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55076. * A PointLight emits the light in every direction.
  55077. * It can cast shadows.
  55078. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55079. * ```javascript
  55080. * var pointLight = new PointLight("pl", camera.position, scene);
  55081. * ```
  55082. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55083. * @param name The light friendly name
  55084. * @param position The position of the point light in the scene
  55085. * @param scene The scene the lights belongs to
  55086. */
  55087. constructor(name: string, position: Vector3, scene: Scene);
  55088. /**
  55089. * Returns the string "PointLight"
  55090. * @returns the class name
  55091. */
  55092. getClassName(): string;
  55093. /**
  55094. * Returns the integer 0.
  55095. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55096. */
  55097. getTypeID(): number;
  55098. /**
  55099. * Specifies wether or not the shadowmap should be a cube texture.
  55100. * @returns true if the shadowmap needs to be a cube texture.
  55101. */
  55102. needCube(): boolean;
  55103. /**
  55104. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55105. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55106. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55107. */
  55108. getShadowDirection(faceIndex?: number): Vector3;
  55109. /**
  55110. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55111. * - fov = PI / 2
  55112. * - aspect ratio : 1.0
  55113. * - z-near and far equal to the active camera minZ and maxZ.
  55114. * Returns the PointLight.
  55115. */
  55116. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55117. protected _buildUniformLayout(): void;
  55118. /**
  55119. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55120. * @param effect The effect to update
  55121. * @param lightIndex The index of the light in the effect to update
  55122. * @returns The point light
  55123. */
  55124. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55125. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55126. /**
  55127. * Prepares the list of defines specific to the light type.
  55128. * @param defines the list of defines
  55129. * @param lightIndex defines the index of the light for the effect
  55130. */
  55131. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55132. }
  55133. }
  55134. declare module BABYLON {
  55135. /**
  55136. * Header information of HDR texture files.
  55137. */
  55138. export interface HDRInfo {
  55139. /**
  55140. * The height of the texture in pixels.
  55141. */
  55142. height: number;
  55143. /**
  55144. * The width of the texture in pixels.
  55145. */
  55146. width: number;
  55147. /**
  55148. * The index of the beginning of the data in the binary file.
  55149. */
  55150. dataPosition: number;
  55151. }
  55152. /**
  55153. * This groups tools to convert HDR texture to native colors array.
  55154. */
  55155. export class HDRTools {
  55156. private static Ldexp;
  55157. private static Rgbe2float;
  55158. private static readStringLine;
  55159. /**
  55160. * Reads header information from an RGBE texture stored in a native array.
  55161. * More information on this format are available here:
  55162. * https://en.wikipedia.org/wiki/RGBE_image_format
  55163. *
  55164. * @param uint8array The binary file stored in native array.
  55165. * @return The header information.
  55166. */
  55167. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55168. /**
  55169. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55170. * This RGBE texture needs to store the information as a panorama.
  55171. *
  55172. * More information on this format are available here:
  55173. * https://en.wikipedia.org/wiki/RGBE_image_format
  55174. *
  55175. * @param buffer The binary file stored in an array buffer.
  55176. * @param size The expected size of the extracted cubemap.
  55177. * @return The Cube Map information.
  55178. */
  55179. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55180. /**
  55181. * Returns the pixels data extracted from an RGBE texture.
  55182. * This pixels will be stored left to right up to down in the R G B order in one array.
  55183. *
  55184. * More information on this format are available here:
  55185. * https://en.wikipedia.org/wiki/RGBE_image_format
  55186. *
  55187. * @param uint8array The binary file stored in an array buffer.
  55188. * @param hdrInfo The header information of the file.
  55189. * @return The pixels data in RGB right to left up to down order.
  55190. */
  55191. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55192. private static RGBE_ReadPixels_RLE;
  55193. }
  55194. }
  55195. declare module BABYLON {
  55196. /**
  55197. * This represents a texture coming from an HDR input.
  55198. *
  55199. * The only supported format is currently panorama picture stored in RGBE format.
  55200. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55201. */
  55202. export class HDRCubeTexture extends BaseTexture {
  55203. private static _facesMapping;
  55204. private _generateHarmonics;
  55205. private _noMipmap;
  55206. private _textureMatrix;
  55207. private _size;
  55208. private _onLoad;
  55209. private _onError;
  55210. /**
  55211. * The texture URL.
  55212. */
  55213. url: string;
  55214. /**
  55215. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55216. */
  55217. coordinatesMode: number;
  55218. protected _isBlocking: boolean;
  55219. /**
  55220. * Sets wether or not the texture is blocking during loading.
  55221. */
  55222. set isBlocking(value: boolean);
  55223. /**
  55224. * Gets wether or not the texture is blocking during loading.
  55225. */
  55226. get isBlocking(): boolean;
  55227. protected _rotationY: number;
  55228. /**
  55229. * Sets texture matrix rotation angle around Y axis in radians.
  55230. */
  55231. set rotationY(value: number);
  55232. /**
  55233. * Gets texture matrix rotation angle around Y axis radians.
  55234. */
  55235. get rotationY(): number;
  55236. /**
  55237. * Gets or sets the center of the bounding box associated with the cube texture
  55238. * It must define where the camera used to render the texture was set
  55239. */
  55240. boundingBoxPosition: Vector3;
  55241. private _boundingBoxSize;
  55242. /**
  55243. * Gets or sets the size of the bounding box associated with the cube texture
  55244. * When defined, the cubemap will switch to local mode
  55245. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55246. * @example https://www.babylonjs-playground.com/#RNASML
  55247. */
  55248. set boundingBoxSize(value: Vector3);
  55249. get boundingBoxSize(): Vector3;
  55250. /**
  55251. * Instantiates an HDRTexture from the following parameters.
  55252. *
  55253. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55254. * @param scene The scene the texture will be used in
  55255. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55256. * @param noMipmap Forces to not generate the mipmap if true
  55257. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55258. * @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)
  55259. * @param reserved Reserved flag for internal use.
  55260. */
  55261. 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>);
  55262. /**
  55263. * Get the current class name of the texture useful for serialization or dynamic coding.
  55264. * @returns "HDRCubeTexture"
  55265. */
  55266. getClassName(): string;
  55267. /**
  55268. * Occurs when the file is raw .hdr file.
  55269. */
  55270. private loadTexture;
  55271. clone(): HDRCubeTexture;
  55272. delayLoad(): void;
  55273. /**
  55274. * Get the texture reflection matrix used to rotate/transform the reflection.
  55275. * @returns the reflection matrix
  55276. */
  55277. getReflectionTextureMatrix(): Matrix;
  55278. /**
  55279. * Set the texture reflection matrix used to rotate/transform the reflection.
  55280. * @param value Define the reflection matrix to set
  55281. */
  55282. setReflectionTextureMatrix(value: Matrix): void;
  55283. /**
  55284. * Parses a JSON representation of an HDR Texture in order to create the texture
  55285. * @param parsedTexture Define the JSON representation
  55286. * @param scene Define the scene the texture should be created in
  55287. * @param rootUrl Define the root url in case we need to load relative dependencies
  55288. * @returns the newly created texture after parsing
  55289. */
  55290. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55291. serialize(): any;
  55292. }
  55293. }
  55294. declare module BABYLON {
  55295. /**
  55296. * Class used to control physics engine
  55297. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55298. */
  55299. export class PhysicsEngine implements IPhysicsEngine {
  55300. private _physicsPlugin;
  55301. /**
  55302. * Global value used to control the smallest number supported by the simulation
  55303. */
  55304. static Epsilon: number;
  55305. private _impostors;
  55306. private _joints;
  55307. private _subTimeStep;
  55308. /**
  55309. * Gets the gravity vector used by the simulation
  55310. */
  55311. gravity: Vector3;
  55312. /**
  55313. * Factory used to create the default physics plugin.
  55314. * @returns The default physics plugin
  55315. */
  55316. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55317. /**
  55318. * Creates a new Physics Engine
  55319. * @param gravity defines the gravity vector used by the simulation
  55320. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55321. */
  55322. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55323. /**
  55324. * Sets the gravity vector used by the simulation
  55325. * @param gravity defines the gravity vector to use
  55326. */
  55327. setGravity(gravity: Vector3): void;
  55328. /**
  55329. * Set the time step of the physics engine.
  55330. * Default is 1/60.
  55331. * To slow it down, enter 1/600 for example.
  55332. * To speed it up, 1/30
  55333. * @param newTimeStep defines the new timestep to apply to this world.
  55334. */
  55335. setTimeStep(newTimeStep?: number): void;
  55336. /**
  55337. * Get the time step of the physics engine.
  55338. * @returns the current time step
  55339. */
  55340. getTimeStep(): number;
  55341. /**
  55342. * Set the sub time step of the physics engine.
  55343. * Default is 0 meaning there is no sub steps
  55344. * To increase physics resolution precision, set a small value (like 1 ms)
  55345. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55346. */
  55347. setSubTimeStep(subTimeStep?: number): void;
  55348. /**
  55349. * Get the sub time step of the physics engine.
  55350. * @returns the current sub time step
  55351. */
  55352. getSubTimeStep(): number;
  55353. /**
  55354. * Release all resources
  55355. */
  55356. dispose(): void;
  55357. /**
  55358. * Gets the name of the current physics plugin
  55359. * @returns the name of the plugin
  55360. */
  55361. getPhysicsPluginName(): string;
  55362. /**
  55363. * Adding a new impostor for the impostor tracking.
  55364. * This will be done by the impostor itself.
  55365. * @param impostor the impostor to add
  55366. */
  55367. addImpostor(impostor: PhysicsImpostor): void;
  55368. /**
  55369. * Remove an impostor from the engine.
  55370. * This impostor and its mesh will not longer be updated by the physics engine.
  55371. * @param impostor the impostor to remove
  55372. */
  55373. removeImpostor(impostor: PhysicsImpostor): void;
  55374. /**
  55375. * Add a joint to the physics engine
  55376. * @param mainImpostor defines the main impostor to which the joint is added.
  55377. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55378. * @param joint defines the joint that will connect both impostors.
  55379. */
  55380. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55381. /**
  55382. * Removes a joint from the simulation
  55383. * @param mainImpostor defines the impostor used with the joint
  55384. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55385. * @param joint defines the joint to remove
  55386. */
  55387. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55388. /**
  55389. * Called by the scene. No need to call it.
  55390. * @param delta defines the timespam between frames
  55391. */
  55392. _step(delta: number): void;
  55393. /**
  55394. * Gets the current plugin used to run the simulation
  55395. * @returns current plugin
  55396. */
  55397. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55398. /**
  55399. * Gets the list of physic impostors
  55400. * @returns an array of PhysicsImpostor
  55401. */
  55402. getImpostors(): Array<PhysicsImpostor>;
  55403. /**
  55404. * Gets the impostor for a physics enabled object
  55405. * @param object defines the object impersonated by the impostor
  55406. * @returns the PhysicsImpostor or null if not found
  55407. */
  55408. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55409. /**
  55410. * Gets the impostor for a physics body object
  55411. * @param body defines physics body used by the impostor
  55412. * @returns the PhysicsImpostor or null if not found
  55413. */
  55414. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55415. /**
  55416. * Does a raycast in the physics world
  55417. * @param from when should the ray start?
  55418. * @param to when should the ray end?
  55419. * @returns PhysicsRaycastResult
  55420. */
  55421. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55422. }
  55423. }
  55424. declare module BABYLON {
  55425. /** @hidden */
  55426. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55427. private _useDeltaForWorldStep;
  55428. world: any;
  55429. name: string;
  55430. private _physicsMaterials;
  55431. private _fixedTimeStep;
  55432. private _cannonRaycastResult;
  55433. private _raycastResult;
  55434. private _physicsBodysToRemoveAfterStep;
  55435. BJSCANNON: any;
  55436. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55437. setGravity(gravity: Vector3): void;
  55438. setTimeStep(timeStep: number): void;
  55439. getTimeStep(): number;
  55440. executeStep(delta: number): void;
  55441. private _removeMarkedPhysicsBodiesFromWorld;
  55442. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55443. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55444. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55445. private _processChildMeshes;
  55446. removePhysicsBody(impostor: PhysicsImpostor): void;
  55447. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55448. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55449. private _addMaterial;
  55450. private _checkWithEpsilon;
  55451. private _createShape;
  55452. private _createHeightmap;
  55453. private _minus90X;
  55454. private _plus90X;
  55455. private _tmpPosition;
  55456. private _tmpDeltaPosition;
  55457. private _tmpUnityRotation;
  55458. private _updatePhysicsBodyTransformation;
  55459. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55460. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55461. isSupported(): boolean;
  55462. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55463. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55464. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55465. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55466. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55467. getBodyMass(impostor: PhysicsImpostor): number;
  55468. getBodyFriction(impostor: PhysicsImpostor): number;
  55469. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55470. getBodyRestitution(impostor: PhysicsImpostor): number;
  55471. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55472. sleepBody(impostor: PhysicsImpostor): void;
  55473. wakeUpBody(impostor: PhysicsImpostor): void;
  55474. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55475. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55476. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55477. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55478. getRadius(impostor: PhysicsImpostor): number;
  55479. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55480. dispose(): void;
  55481. private _extendNamespace;
  55482. /**
  55483. * Does a raycast in the physics world
  55484. * @param from when should the ray start?
  55485. * @param to when should the ray end?
  55486. * @returns PhysicsRaycastResult
  55487. */
  55488. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55489. }
  55490. }
  55491. declare module BABYLON {
  55492. /** @hidden */
  55493. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55494. world: any;
  55495. name: string;
  55496. BJSOIMO: any;
  55497. private _raycastResult;
  55498. constructor(iterations?: number, oimoInjection?: any);
  55499. setGravity(gravity: Vector3): void;
  55500. setTimeStep(timeStep: number): void;
  55501. getTimeStep(): number;
  55502. private _tmpImpostorsArray;
  55503. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55504. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55505. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55506. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55507. private _tmpPositionVector;
  55508. removePhysicsBody(impostor: PhysicsImpostor): void;
  55509. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55510. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55511. isSupported(): boolean;
  55512. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55513. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55514. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55515. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55516. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55517. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55518. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55519. getBodyMass(impostor: PhysicsImpostor): number;
  55520. getBodyFriction(impostor: PhysicsImpostor): number;
  55521. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55522. getBodyRestitution(impostor: PhysicsImpostor): number;
  55523. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55524. sleepBody(impostor: PhysicsImpostor): void;
  55525. wakeUpBody(impostor: PhysicsImpostor): void;
  55526. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55527. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55528. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55529. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55530. getRadius(impostor: PhysicsImpostor): number;
  55531. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55532. dispose(): void;
  55533. /**
  55534. * Does a raycast in the physics world
  55535. * @param from when should the ray start?
  55536. * @param to when should the ray end?
  55537. * @returns PhysicsRaycastResult
  55538. */
  55539. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55540. }
  55541. }
  55542. declare module BABYLON {
  55543. /**
  55544. * Class containing static functions to help procedurally build meshes
  55545. */
  55546. export class RibbonBuilder {
  55547. /**
  55548. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55549. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55550. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55551. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55552. * * 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
  55553. * * 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
  55554. * * 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
  55555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55556. * * 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
  55557. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55558. * * 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
  55559. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55560. * * 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
  55561. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55563. * @param name defines the name of the mesh
  55564. * @param options defines the options used to create the mesh
  55565. * @param scene defines the hosting scene
  55566. * @returns the ribbon mesh
  55567. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55568. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55569. */
  55570. static CreateRibbon(name: string, options: {
  55571. pathArray: Vector3[][];
  55572. closeArray?: boolean;
  55573. closePath?: boolean;
  55574. offset?: number;
  55575. updatable?: boolean;
  55576. sideOrientation?: number;
  55577. frontUVs?: Vector4;
  55578. backUVs?: Vector4;
  55579. instance?: Mesh;
  55580. invertUV?: boolean;
  55581. uvs?: Vector2[];
  55582. colors?: Color4[];
  55583. }, scene?: Nullable<Scene>): Mesh;
  55584. }
  55585. }
  55586. declare module BABYLON {
  55587. /**
  55588. * Class containing static functions to help procedurally build meshes
  55589. */
  55590. export class ShapeBuilder {
  55591. /**
  55592. * 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.
  55593. * * 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.
  55594. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55595. * * 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.
  55596. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55597. * * 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
  55598. * * 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
  55599. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55601. * * 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
  55602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55604. * @param name defines the name of the mesh
  55605. * @param options defines the options used to create the mesh
  55606. * @param scene defines the hosting scene
  55607. * @returns the extruded shape mesh
  55608. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55610. */
  55611. static ExtrudeShape(name: string, options: {
  55612. shape: Vector3[];
  55613. path: Vector3[];
  55614. scale?: number;
  55615. rotation?: number;
  55616. cap?: number;
  55617. updatable?: boolean;
  55618. sideOrientation?: number;
  55619. frontUVs?: Vector4;
  55620. backUVs?: Vector4;
  55621. instance?: Mesh;
  55622. invertUV?: boolean;
  55623. }, scene?: Nullable<Scene>): Mesh;
  55624. /**
  55625. * Creates an custom extruded shape mesh.
  55626. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55627. * * 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.
  55628. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55629. * * 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
  55630. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55631. * * 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
  55632. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55633. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55634. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55635. * * 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
  55636. * * 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
  55637. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55639. * * 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
  55640. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55642. * @param name defines the name of the mesh
  55643. * @param options defines the options used to create the mesh
  55644. * @param scene defines the hosting scene
  55645. * @returns the custom extruded shape mesh
  55646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55647. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55649. */
  55650. static ExtrudeShapeCustom(name: string, options: {
  55651. shape: Vector3[];
  55652. path: Vector3[];
  55653. scaleFunction?: any;
  55654. rotationFunction?: any;
  55655. ribbonCloseArray?: boolean;
  55656. ribbonClosePath?: boolean;
  55657. cap?: number;
  55658. updatable?: boolean;
  55659. sideOrientation?: number;
  55660. frontUVs?: Vector4;
  55661. backUVs?: Vector4;
  55662. instance?: Mesh;
  55663. invertUV?: boolean;
  55664. }, scene?: Nullable<Scene>): Mesh;
  55665. private static _ExtrudeShapeGeneric;
  55666. }
  55667. }
  55668. declare module BABYLON {
  55669. /**
  55670. * AmmoJS Physics plugin
  55671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55672. * @see https://github.com/kripken/ammo.js/
  55673. */
  55674. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55675. private _useDeltaForWorldStep;
  55676. /**
  55677. * Reference to the Ammo library
  55678. */
  55679. bjsAMMO: any;
  55680. /**
  55681. * Created ammoJS world which physics bodies are added to
  55682. */
  55683. world: any;
  55684. /**
  55685. * Name of the plugin
  55686. */
  55687. name: string;
  55688. private _timeStep;
  55689. private _fixedTimeStep;
  55690. private _maxSteps;
  55691. private _tmpQuaternion;
  55692. private _tmpAmmoTransform;
  55693. private _tmpAmmoQuaternion;
  55694. private _tmpAmmoConcreteContactResultCallback;
  55695. private _collisionConfiguration;
  55696. private _dispatcher;
  55697. private _overlappingPairCache;
  55698. private _solver;
  55699. private _softBodySolver;
  55700. private _tmpAmmoVectorA;
  55701. private _tmpAmmoVectorB;
  55702. private _tmpAmmoVectorC;
  55703. private _tmpAmmoVectorD;
  55704. private _tmpContactCallbackResult;
  55705. private _tmpAmmoVectorRCA;
  55706. private _tmpAmmoVectorRCB;
  55707. private _raycastResult;
  55708. private static readonly DISABLE_COLLISION_FLAG;
  55709. private static readonly KINEMATIC_FLAG;
  55710. private static readonly DISABLE_DEACTIVATION_FLAG;
  55711. /**
  55712. * Initializes the ammoJS plugin
  55713. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55714. * @param ammoInjection can be used to inject your own ammo reference
  55715. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55716. */
  55717. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55718. /**
  55719. * Sets the gravity of the physics world (m/(s^2))
  55720. * @param gravity Gravity to set
  55721. */
  55722. setGravity(gravity: Vector3): void;
  55723. /**
  55724. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55725. * @param timeStep timestep to use in seconds
  55726. */
  55727. setTimeStep(timeStep: number): void;
  55728. /**
  55729. * 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)
  55730. * @param fixedTimeStep fixedTimeStep to use in seconds
  55731. */
  55732. setFixedTimeStep(fixedTimeStep: number): void;
  55733. /**
  55734. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55735. * @param maxSteps the maximum number of steps by the physics engine per frame
  55736. */
  55737. setMaxSteps(maxSteps: number): void;
  55738. /**
  55739. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55740. * @returns the current timestep in seconds
  55741. */
  55742. getTimeStep(): number;
  55743. /**
  55744. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55745. */
  55746. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55747. private _isImpostorInContact;
  55748. private _isImpostorPairInContact;
  55749. private _stepSimulation;
  55750. /**
  55751. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55752. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55753. * After the step the babylon meshes are set to the position of the physics imposters
  55754. * @param delta amount of time to step forward
  55755. * @param impostors array of imposters to update before/after the step
  55756. */
  55757. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55758. /**
  55759. * Update babylon mesh to match physics world object
  55760. * @param impostor imposter to match
  55761. */
  55762. private _afterSoftStep;
  55763. /**
  55764. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55765. * @param impostor imposter to match
  55766. */
  55767. private _ropeStep;
  55768. /**
  55769. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55770. * @param impostor imposter to match
  55771. */
  55772. private _softbodyOrClothStep;
  55773. private _tmpMatrix;
  55774. /**
  55775. * Applies an impulse on the imposter
  55776. * @param impostor imposter to apply impulse to
  55777. * @param force amount of force to be applied to the imposter
  55778. * @param contactPoint the location to apply the impulse on the imposter
  55779. */
  55780. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55781. /**
  55782. * Applies a force on the imposter
  55783. * @param impostor imposter to apply force
  55784. * @param force amount of force to be applied to the imposter
  55785. * @param contactPoint the location to apply the force on the imposter
  55786. */
  55787. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55788. /**
  55789. * Creates a physics body using the plugin
  55790. * @param impostor the imposter to create the physics body on
  55791. */
  55792. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55793. /**
  55794. * Removes the physics body from the imposter and disposes of the body's memory
  55795. * @param impostor imposter to remove the physics body from
  55796. */
  55797. removePhysicsBody(impostor: PhysicsImpostor): void;
  55798. /**
  55799. * Generates a joint
  55800. * @param impostorJoint the imposter joint to create the joint with
  55801. */
  55802. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55803. /**
  55804. * Removes a joint
  55805. * @param impostorJoint the imposter joint to remove the joint from
  55806. */
  55807. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55808. private _addMeshVerts;
  55809. /**
  55810. * Initialise the soft body vertices to match its object's (mesh) vertices
  55811. * Softbody vertices (nodes) are in world space and to match this
  55812. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55813. * @param impostor to create the softbody for
  55814. */
  55815. private _softVertexData;
  55816. /**
  55817. * Create an impostor's soft body
  55818. * @param impostor to create the softbody for
  55819. */
  55820. private _createSoftbody;
  55821. /**
  55822. * Create cloth for an impostor
  55823. * @param impostor to create the softbody for
  55824. */
  55825. private _createCloth;
  55826. /**
  55827. * Create rope for an impostor
  55828. * @param impostor to create the softbody for
  55829. */
  55830. private _createRope;
  55831. /**
  55832. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55833. * @param impostor to create the custom physics shape for
  55834. */
  55835. private _createCustom;
  55836. private _addHullVerts;
  55837. private _createShape;
  55838. /**
  55839. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55840. * @param impostor imposter containing the physics body and babylon object
  55841. */
  55842. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55843. /**
  55844. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55845. * @param impostor imposter containing the physics body and babylon object
  55846. * @param newPosition new position
  55847. * @param newRotation new rotation
  55848. */
  55849. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55850. /**
  55851. * If this plugin is supported
  55852. * @returns true if its supported
  55853. */
  55854. isSupported(): boolean;
  55855. /**
  55856. * Sets the linear velocity of the physics body
  55857. * @param impostor imposter to set the velocity on
  55858. * @param velocity velocity to set
  55859. */
  55860. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55861. /**
  55862. * Sets the angular velocity of the physics body
  55863. * @param impostor imposter to set the velocity on
  55864. * @param velocity velocity to set
  55865. */
  55866. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55867. /**
  55868. * gets the linear velocity
  55869. * @param impostor imposter to get linear velocity from
  55870. * @returns linear velocity
  55871. */
  55872. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55873. /**
  55874. * gets the angular velocity
  55875. * @param impostor imposter to get angular velocity from
  55876. * @returns angular velocity
  55877. */
  55878. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55879. /**
  55880. * Sets the mass of physics body
  55881. * @param impostor imposter to set the mass on
  55882. * @param mass mass to set
  55883. */
  55884. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55885. /**
  55886. * Gets the mass of the physics body
  55887. * @param impostor imposter to get the mass from
  55888. * @returns mass
  55889. */
  55890. getBodyMass(impostor: PhysicsImpostor): number;
  55891. /**
  55892. * Gets friction of the impostor
  55893. * @param impostor impostor to get friction from
  55894. * @returns friction value
  55895. */
  55896. getBodyFriction(impostor: PhysicsImpostor): number;
  55897. /**
  55898. * Sets friction of the impostor
  55899. * @param impostor impostor to set friction on
  55900. * @param friction friction value
  55901. */
  55902. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55903. /**
  55904. * Gets restitution of the impostor
  55905. * @param impostor impostor to get restitution from
  55906. * @returns restitution value
  55907. */
  55908. getBodyRestitution(impostor: PhysicsImpostor): number;
  55909. /**
  55910. * Sets resitution of the impostor
  55911. * @param impostor impostor to set resitution on
  55912. * @param restitution resitution value
  55913. */
  55914. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55915. /**
  55916. * Gets pressure inside the impostor
  55917. * @param impostor impostor to get pressure from
  55918. * @returns pressure value
  55919. */
  55920. getBodyPressure(impostor: PhysicsImpostor): number;
  55921. /**
  55922. * Sets pressure inside a soft body impostor
  55923. * Cloth and rope must remain 0 pressure
  55924. * @param impostor impostor to set pressure on
  55925. * @param pressure pressure value
  55926. */
  55927. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55928. /**
  55929. * Gets stiffness of the impostor
  55930. * @param impostor impostor to get stiffness from
  55931. * @returns pressure value
  55932. */
  55933. getBodyStiffness(impostor: PhysicsImpostor): number;
  55934. /**
  55935. * Sets stiffness of the impostor
  55936. * @param impostor impostor to set stiffness on
  55937. * @param stiffness stiffness value from 0 to 1
  55938. */
  55939. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55940. /**
  55941. * Gets velocityIterations of the impostor
  55942. * @param impostor impostor to get velocity iterations from
  55943. * @returns velocityIterations value
  55944. */
  55945. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55946. /**
  55947. * Sets velocityIterations of the impostor
  55948. * @param impostor impostor to set velocity iterations on
  55949. * @param velocityIterations velocityIterations value
  55950. */
  55951. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55952. /**
  55953. * Gets positionIterations of the impostor
  55954. * @param impostor impostor to get position iterations from
  55955. * @returns positionIterations value
  55956. */
  55957. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55958. /**
  55959. * Sets positionIterations of the impostor
  55960. * @param impostor impostor to set position on
  55961. * @param positionIterations positionIterations value
  55962. */
  55963. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55964. /**
  55965. * Append an anchor to a cloth object
  55966. * @param impostor is the cloth impostor to add anchor to
  55967. * @param otherImpostor is the rigid impostor to anchor to
  55968. * @param width ratio across width from 0 to 1
  55969. * @param height ratio up height from 0 to 1
  55970. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55971. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55972. */
  55973. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55974. /**
  55975. * Append an hook to a rope object
  55976. * @param impostor is the rope impostor to add hook to
  55977. * @param otherImpostor is the rigid impostor to hook to
  55978. * @param length ratio along the rope from 0 to 1
  55979. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55980. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55981. */
  55982. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55983. /**
  55984. * Sleeps the physics body and stops it from being active
  55985. * @param impostor impostor to sleep
  55986. */
  55987. sleepBody(impostor: PhysicsImpostor): void;
  55988. /**
  55989. * Activates the physics body
  55990. * @param impostor impostor to activate
  55991. */
  55992. wakeUpBody(impostor: PhysicsImpostor): void;
  55993. /**
  55994. * Updates the distance parameters of the joint
  55995. * @param joint joint to update
  55996. * @param maxDistance maximum distance of the joint
  55997. * @param minDistance minimum distance of the joint
  55998. */
  55999. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56000. /**
  56001. * Sets a motor on the joint
  56002. * @param joint joint to set motor on
  56003. * @param speed speed of the motor
  56004. * @param maxForce maximum force of the motor
  56005. * @param motorIndex index of the motor
  56006. */
  56007. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56008. /**
  56009. * Sets the motors limit
  56010. * @param joint joint to set limit on
  56011. * @param upperLimit upper limit
  56012. * @param lowerLimit lower limit
  56013. */
  56014. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56015. /**
  56016. * Syncs the position and rotation of a mesh with the impostor
  56017. * @param mesh mesh to sync
  56018. * @param impostor impostor to update the mesh with
  56019. */
  56020. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56021. /**
  56022. * Gets the radius of the impostor
  56023. * @param impostor impostor to get radius from
  56024. * @returns the radius
  56025. */
  56026. getRadius(impostor: PhysicsImpostor): number;
  56027. /**
  56028. * Gets the box size of the impostor
  56029. * @param impostor impostor to get box size from
  56030. * @param result the resulting box size
  56031. */
  56032. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56033. /**
  56034. * Disposes of the impostor
  56035. */
  56036. dispose(): void;
  56037. /**
  56038. * Does a raycast in the physics world
  56039. * @param from when should the ray start?
  56040. * @param to when should the ray end?
  56041. * @returns PhysicsRaycastResult
  56042. */
  56043. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56044. }
  56045. }
  56046. declare module BABYLON {
  56047. interface AbstractScene {
  56048. /**
  56049. * The list of reflection probes added to the scene
  56050. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56051. */
  56052. reflectionProbes: Array<ReflectionProbe>;
  56053. /**
  56054. * Removes the given reflection probe from this scene.
  56055. * @param toRemove The reflection probe to remove
  56056. * @returns The index of the removed reflection probe
  56057. */
  56058. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56059. /**
  56060. * Adds the given reflection probe to this scene.
  56061. * @param newReflectionProbe The reflection probe to add
  56062. */
  56063. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56064. }
  56065. /**
  56066. * Class used to generate realtime reflection / refraction cube textures
  56067. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56068. */
  56069. export class ReflectionProbe {
  56070. /** defines the name of the probe */
  56071. name: string;
  56072. private _scene;
  56073. private _renderTargetTexture;
  56074. private _projectionMatrix;
  56075. private _viewMatrix;
  56076. private _target;
  56077. private _add;
  56078. private _attachedMesh;
  56079. private _invertYAxis;
  56080. /** Gets or sets probe position (center of the cube map) */
  56081. position: Vector3;
  56082. /**
  56083. * Creates a new reflection probe
  56084. * @param name defines the name of the probe
  56085. * @param size defines the texture resolution (for each face)
  56086. * @param scene defines the hosting scene
  56087. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56088. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56089. */
  56090. constructor(
  56091. /** defines the name of the probe */
  56092. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56093. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56094. get samples(): number;
  56095. set samples(value: number);
  56096. /** Gets or sets the refresh rate to use (on every frame by default) */
  56097. get refreshRate(): number;
  56098. set refreshRate(value: number);
  56099. /**
  56100. * Gets the hosting scene
  56101. * @returns a Scene
  56102. */
  56103. getScene(): Scene;
  56104. /** Gets the internal CubeTexture used to render to */
  56105. get cubeTexture(): RenderTargetTexture;
  56106. /** Gets the list of meshes to render */
  56107. get renderList(): Nullable<AbstractMesh[]>;
  56108. /**
  56109. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56110. * @param mesh defines the mesh to attach to
  56111. */
  56112. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56113. /**
  56114. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56115. * @param renderingGroupId The rendering group id corresponding to its index
  56116. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56117. */
  56118. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56119. /**
  56120. * Clean all associated resources
  56121. */
  56122. dispose(): void;
  56123. /**
  56124. * Converts the reflection probe information to a readable string for debug purpose.
  56125. * @param fullDetails Supports for multiple levels of logging within scene loading
  56126. * @returns the human readable reflection probe info
  56127. */
  56128. toString(fullDetails?: boolean): string;
  56129. /**
  56130. * Get the class name of the relfection probe.
  56131. * @returns "ReflectionProbe"
  56132. */
  56133. getClassName(): string;
  56134. /**
  56135. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56136. * @returns The JSON representation of the texture
  56137. */
  56138. serialize(): any;
  56139. /**
  56140. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56141. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56142. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56143. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56144. * @returns The parsed reflection probe if successful
  56145. */
  56146. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56147. }
  56148. }
  56149. declare module BABYLON {
  56150. /** @hidden */
  56151. export var _BabylonLoaderRegistered: boolean;
  56152. /**
  56153. * Helps setting up some configuration for the babylon file loader.
  56154. */
  56155. export class BabylonFileLoaderConfiguration {
  56156. /**
  56157. * The loader does not allow injecting custom physix engine into the plugins.
  56158. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56159. * So you could set this variable to your engine import to make it work.
  56160. */
  56161. static LoaderInjectedPhysicsEngine: any;
  56162. }
  56163. }
  56164. declare module BABYLON {
  56165. /**
  56166. * The Physically based simple base material of BJS.
  56167. *
  56168. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56169. * It is used as the base class for both the specGloss and metalRough conventions.
  56170. */
  56171. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56172. /**
  56173. * Number of Simultaneous lights allowed on the material.
  56174. */
  56175. maxSimultaneousLights: number;
  56176. /**
  56177. * If sets to true, disables all the lights affecting the material.
  56178. */
  56179. disableLighting: boolean;
  56180. /**
  56181. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56182. */
  56183. environmentTexture: BaseTexture;
  56184. /**
  56185. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56186. */
  56187. invertNormalMapX: boolean;
  56188. /**
  56189. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56190. */
  56191. invertNormalMapY: boolean;
  56192. /**
  56193. * Normal map used in the model.
  56194. */
  56195. normalTexture: BaseTexture;
  56196. /**
  56197. * Emissivie color used to self-illuminate the model.
  56198. */
  56199. emissiveColor: Color3;
  56200. /**
  56201. * Emissivie texture used to self-illuminate the model.
  56202. */
  56203. emissiveTexture: BaseTexture;
  56204. /**
  56205. * Occlusion Channel Strenght.
  56206. */
  56207. occlusionStrength: number;
  56208. /**
  56209. * Occlusion Texture of the material (adding extra occlusion effects).
  56210. */
  56211. occlusionTexture: BaseTexture;
  56212. /**
  56213. * Defines the alpha limits in alpha test mode.
  56214. */
  56215. alphaCutOff: number;
  56216. /**
  56217. * Gets the current double sided mode.
  56218. */
  56219. get doubleSided(): boolean;
  56220. /**
  56221. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56222. */
  56223. set doubleSided(value: boolean);
  56224. /**
  56225. * Stores the pre-calculated light information of a mesh in a texture.
  56226. */
  56227. lightmapTexture: BaseTexture;
  56228. /**
  56229. * If true, the light map contains occlusion information instead of lighting info.
  56230. */
  56231. useLightmapAsShadowmap: boolean;
  56232. /**
  56233. * Instantiates a new PBRMaterial instance.
  56234. *
  56235. * @param name The material name
  56236. * @param scene The scene the material will be use in.
  56237. */
  56238. constructor(name: string, scene: Scene);
  56239. getClassName(): string;
  56240. }
  56241. }
  56242. declare module BABYLON {
  56243. /**
  56244. * The PBR material of BJS following the metal roughness convention.
  56245. *
  56246. * This fits to the PBR convention in the GLTF definition:
  56247. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56248. */
  56249. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56250. /**
  56251. * The base color has two different interpretations depending on the value of metalness.
  56252. * When the material is a metal, the base color is the specific measured reflectance value
  56253. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56254. * of the material.
  56255. */
  56256. baseColor: Color3;
  56257. /**
  56258. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56259. * well as opacity information in the alpha channel.
  56260. */
  56261. baseTexture: BaseTexture;
  56262. /**
  56263. * Specifies the metallic scalar value of the material.
  56264. * Can also be used to scale the metalness values of the metallic texture.
  56265. */
  56266. metallic: number;
  56267. /**
  56268. * Specifies the roughness scalar value of the material.
  56269. * Can also be used to scale the roughness values of the metallic texture.
  56270. */
  56271. roughness: number;
  56272. /**
  56273. * Texture containing both the metallic value in the B channel and the
  56274. * roughness value in the G channel to keep better precision.
  56275. */
  56276. metallicRoughnessTexture: BaseTexture;
  56277. /**
  56278. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56279. *
  56280. * @param name The material name
  56281. * @param scene The scene the material will be use in.
  56282. */
  56283. constructor(name: string, scene: Scene);
  56284. /**
  56285. * Return the currrent class name of the material.
  56286. */
  56287. getClassName(): string;
  56288. /**
  56289. * Makes a duplicate of the current material.
  56290. * @param name - name to use for the new material.
  56291. */
  56292. clone(name: string): PBRMetallicRoughnessMaterial;
  56293. /**
  56294. * Serialize the material to a parsable JSON object.
  56295. */
  56296. serialize(): any;
  56297. /**
  56298. * Parses a JSON object correponding to the serialize function.
  56299. */
  56300. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56301. }
  56302. }
  56303. declare module BABYLON {
  56304. /**
  56305. * The PBR material of BJS following the specular glossiness convention.
  56306. *
  56307. * This fits to the PBR convention in the GLTF definition:
  56308. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56309. */
  56310. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56311. /**
  56312. * Specifies the diffuse color of the material.
  56313. */
  56314. diffuseColor: Color3;
  56315. /**
  56316. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56317. * channel.
  56318. */
  56319. diffuseTexture: BaseTexture;
  56320. /**
  56321. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56322. */
  56323. specularColor: Color3;
  56324. /**
  56325. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56326. */
  56327. glossiness: number;
  56328. /**
  56329. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56330. */
  56331. specularGlossinessTexture: BaseTexture;
  56332. /**
  56333. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56334. *
  56335. * @param name The material name
  56336. * @param scene The scene the material will be use in.
  56337. */
  56338. constructor(name: string, scene: Scene);
  56339. /**
  56340. * Return the currrent class name of the material.
  56341. */
  56342. getClassName(): string;
  56343. /**
  56344. * Makes a duplicate of the current material.
  56345. * @param name - name to use for the new material.
  56346. */
  56347. clone(name: string): PBRSpecularGlossinessMaterial;
  56348. /**
  56349. * Serialize the material to a parsable JSON object.
  56350. */
  56351. serialize(): any;
  56352. /**
  56353. * Parses a JSON object correponding to the serialize function.
  56354. */
  56355. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56356. }
  56357. }
  56358. declare module BABYLON {
  56359. /**
  56360. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56361. * It can help converting any input color in a desired output one. This can then be used to create effects
  56362. * from sepia, black and white to sixties or futuristic rendering...
  56363. *
  56364. * The only supported format is currently 3dl.
  56365. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56366. */
  56367. export class ColorGradingTexture extends BaseTexture {
  56368. /**
  56369. * The current texture matrix. (will always be identity in color grading texture)
  56370. */
  56371. private _textureMatrix;
  56372. /**
  56373. * The texture URL.
  56374. */
  56375. url: string;
  56376. /**
  56377. * Empty line regex stored for GC.
  56378. */
  56379. private static _noneEmptyLineRegex;
  56380. private _engine;
  56381. /**
  56382. * Instantiates a ColorGradingTexture from the following parameters.
  56383. *
  56384. * @param url The location of the color gradind data (currently only supporting 3dl)
  56385. * @param scene The scene the texture will be used in
  56386. */
  56387. constructor(url: string, scene: Scene);
  56388. /**
  56389. * Returns the texture matrix used in most of the material.
  56390. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56391. */
  56392. getTextureMatrix(): Matrix;
  56393. /**
  56394. * Occurs when the file being loaded is a .3dl LUT file.
  56395. */
  56396. private load3dlTexture;
  56397. /**
  56398. * Starts the loading process of the texture.
  56399. */
  56400. private loadTexture;
  56401. /**
  56402. * Clones the color gradind texture.
  56403. */
  56404. clone(): ColorGradingTexture;
  56405. /**
  56406. * Called during delayed load for textures.
  56407. */
  56408. delayLoad(): void;
  56409. /**
  56410. * Parses a color grading texture serialized by Babylon.
  56411. * @param parsedTexture The texture information being parsedTexture
  56412. * @param scene The scene to load the texture in
  56413. * @param rootUrl The root url of the data assets to load
  56414. * @return A color gradind texture
  56415. */
  56416. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56417. /**
  56418. * Serializes the LUT texture to json format.
  56419. */
  56420. serialize(): any;
  56421. }
  56422. }
  56423. declare module BABYLON {
  56424. /**
  56425. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56426. */
  56427. export class EquiRectangularCubeTexture extends BaseTexture {
  56428. /** The six faces of the cube. */
  56429. private static _FacesMapping;
  56430. private _noMipmap;
  56431. private _onLoad;
  56432. private _onError;
  56433. /** The size of the cubemap. */
  56434. private _size;
  56435. /** The buffer of the image. */
  56436. private _buffer;
  56437. /** The width of the input image. */
  56438. private _width;
  56439. /** The height of the input image. */
  56440. private _height;
  56441. /** The URL to the image. */
  56442. url: string;
  56443. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56444. coordinatesMode: number;
  56445. /**
  56446. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56447. * @param url The location of the image
  56448. * @param scene The scene the texture will be used in
  56449. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56450. * @param noMipmap Forces to not generate the mipmap if true
  56451. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56452. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56453. * @param onLoad — defines a callback called when texture is loaded
  56454. * @param onError — defines a callback called if there is an error
  56455. */
  56456. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56457. /**
  56458. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56459. */
  56460. private loadImage;
  56461. /**
  56462. * Convert the image buffer into a cubemap and create a CubeTexture.
  56463. */
  56464. private loadTexture;
  56465. /**
  56466. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56467. * @param buffer The ArrayBuffer that should be converted.
  56468. * @returns The buffer as Float32Array.
  56469. */
  56470. private getFloat32ArrayFromArrayBuffer;
  56471. /**
  56472. * Get the current class name of the texture useful for serialization or dynamic coding.
  56473. * @returns "EquiRectangularCubeTexture"
  56474. */
  56475. getClassName(): string;
  56476. /**
  56477. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56478. * @returns A clone of the current EquiRectangularCubeTexture.
  56479. */
  56480. clone(): EquiRectangularCubeTexture;
  56481. }
  56482. }
  56483. declare module BABYLON {
  56484. /**
  56485. * Based on jsTGALoader - Javascript loader for TGA file
  56486. * By Vincent Thibault
  56487. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56488. */
  56489. export class TGATools {
  56490. private static _TYPE_INDEXED;
  56491. private static _TYPE_RGB;
  56492. private static _TYPE_GREY;
  56493. private static _TYPE_RLE_INDEXED;
  56494. private static _TYPE_RLE_RGB;
  56495. private static _TYPE_RLE_GREY;
  56496. private static _ORIGIN_MASK;
  56497. private static _ORIGIN_SHIFT;
  56498. private static _ORIGIN_BL;
  56499. private static _ORIGIN_BR;
  56500. private static _ORIGIN_UL;
  56501. private static _ORIGIN_UR;
  56502. /**
  56503. * Gets the header of a TGA file
  56504. * @param data defines the TGA data
  56505. * @returns the header
  56506. */
  56507. static GetTGAHeader(data: Uint8Array): any;
  56508. /**
  56509. * Uploads TGA content to a Babylon Texture
  56510. * @hidden
  56511. */
  56512. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56513. /** @hidden */
  56514. 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;
  56515. /** @hidden */
  56516. 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;
  56517. /** @hidden */
  56518. 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;
  56519. /** @hidden */
  56520. 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;
  56521. /** @hidden */
  56522. 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;
  56523. /** @hidden */
  56524. 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;
  56525. }
  56526. }
  56527. declare module BABYLON {
  56528. /**
  56529. * Implementation of the TGA Texture Loader.
  56530. * @hidden
  56531. */
  56532. export class _TGATextureLoader implements IInternalTextureLoader {
  56533. /**
  56534. * Defines wether the loader supports cascade loading the different faces.
  56535. */
  56536. readonly supportCascades: boolean;
  56537. /**
  56538. * This returns if the loader support the current file information.
  56539. * @param extension defines the file extension of the file being loaded
  56540. * @returns true if the loader can load the specified file
  56541. */
  56542. canLoad(extension: string): boolean;
  56543. /**
  56544. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56545. * @param data contains the texture data
  56546. * @param texture defines the BabylonJS internal texture
  56547. * @param createPolynomials will be true if polynomials have been requested
  56548. * @param onLoad defines the callback to trigger once the texture is ready
  56549. * @param onError defines the callback to trigger in case of error
  56550. */
  56551. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56552. /**
  56553. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56554. * @param data contains the texture data
  56555. * @param texture defines the BabylonJS internal texture
  56556. * @param callback defines the method to call once ready to upload
  56557. */
  56558. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56559. }
  56560. }
  56561. declare module BABYLON {
  56562. /**
  56563. * Info about the .basis files
  56564. */
  56565. class BasisFileInfo {
  56566. /**
  56567. * If the file has alpha
  56568. */
  56569. hasAlpha: boolean;
  56570. /**
  56571. * Info about each image of the basis file
  56572. */
  56573. images: Array<{
  56574. levels: Array<{
  56575. width: number;
  56576. height: number;
  56577. transcodedPixels: ArrayBufferView;
  56578. }>;
  56579. }>;
  56580. }
  56581. /**
  56582. * Result of transcoding a basis file
  56583. */
  56584. class TranscodeResult {
  56585. /**
  56586. * Info about the .basis file
  56587. */
  56588. fileInfo: BasisFileInfo;
  56589. /**
  56590. * Format to use when loading the file
  56591. */
  56592. format: number;
  56593. }
  56594. /**
  56595. * Configuration options for the Basis transcoder
  56596. */
  56597. export class BasisTranscodeConfiguration {
  56598. /**
  56599. * Supported compression formats used to determine the supported output format of the transcoder
  56600. */
  56601. supportedCompressionFormats?: {
  56602. /**
  56603. * etc1 compression format
  56604. */
  56605. etc1?: boolean;
  56606. /**
  56607. * s3tc compression format
  56608. */
  56609. s3tc?: boolean;
  56610. /**
  56611. * pvrtc compression format
  56612. */
  56613. pvrtc?: boolean;
  56614. /**
  56615. * etc2 compression format
  56616. */
  56617. etc2?: boolean;
  56618. };
  56619. /**
  56620. * If mipmap levels should be loaded for transcoded images (Default: true)
  56621. */
  56622. loadMipmapLevels?: boolean;
  56623. /**
  56624. * Index of a single image to load (Default: all images)
  56625. */
  56626. loadSingleImage?: number;
  56627. }
  56628. /**
  56629. * Used to load .Basis files
  56630. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56631. */
  56632. export class BasisTools {
  56633. private static _IgnoreSupportedFormats;
  56634. /**
  56635. * URL to use when loading the basis transcoder
  56636. */
  56637. static JSModuleURL: string;
  56638. /**
  56639. * URL to use when loading the wasm module for the transcoder
  56640. */
  56641. static WasmModuleURL: string;
  56642. /**
  56643. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56644. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56645. * @returns internal format corresponding to the Basis format
  56646. */
  56647. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56648. private static _WorkerPromise;
  56649. private static _Worker;
  56650. private static _actionId;
  56651. private static _CreateWorkerAsync;
  56652. /**
  56653. * Transcodes a loaded image file to compressed pixel data
  56654. * @param data image data to transcode
  56655. * @param config configuration options for the transcoding
  56656. * @returns a promise resulting in the transcoded image
  56657. */
  56658. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56659. /**
  56660. * Loads a texture from the transcode result
  56661. * @param texture texture load to
  56662. * @param transcodeResult the result of transcoding the basis file to load from
  56663. */
  56664. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56665. }
  56666. }
  56667. declare module BABYLON {
  56668. /**
  56669. * Loader for .basis file format
  56670. */
  56671. export class _BasisTextureLoader implements IInternalTextureLoader {
  56672. /**
  56673. * Defines whether the loader supports cascade loading the different faces.
  56674. */
  56675. readonly supportCascades: boolean;
  56676. /**
  56677. * This returns if the loader support the current file information.
  56678. * @param extension defines the file extension of the file being loaded
  56679. * @returns true if the loader can load the specified file
  56680. */
  56681. canLoad(extension: string): boolean;
  56682. /**
  56683. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56684. * @param data contains the texture data
  56685. * @param texture defines the BabylonJS internal texture
  56686. * @param createPolynomials will be true if polynomials have been requested
  56687. * @param onLoad defines the callback to trigger once the texture is ready
  56688. * @param onError defines the callback to trigger in case of error
  56689. */
  56690. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56691. /**
  56692. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56693. * @param data contains the texture data
  56694. * @param texture defines the BabylonJS internal texture
  56695. * @param callback defines the method to call once ready to upload
  56696. */
  56697. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56698. }
  56699. }
  56700. declare module BABYLON {
  56701. /**
  56702. * 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.
  56703. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56704. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56705. */
  56706. export class CustomProceduralTexture extends ProceduralTexture {
  56707. private _animate;
  56708. private _time;
  56709. private _config;
  56710. private _texturePath;
  56711. /**
  56712. * Instantiates a new Custom Procedural Texture.
  56713. * 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.
  56714. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56715. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56716. * @param name Define the name of the texture
  56717. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56718. * @param size Define the size of the texture to create
  56719. * @param scene Define the scene the texture belongs to
  56720. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56721. * @param generateMipMaps Define if the texture should creates mip maps or not
  56722. */
  56723. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56724. private _loadJson;
  56725. /**
  56726. * Is the texture ready to be used ? (rendered at least once)
  56727. * @returns true if ready, otherwise, false.
  56728. */
  56729. isReady(): boolean;
  56730. /**
  56731. * Render the texture to its associated render target.
  56732. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56733. */
  56734. render(useCameraPostProcess?: boolean): void;
  56735. /**
  56736. * Update the list of dependant textures samplers in the shader.
  56737. */
  56738. updateTextures(): void;
  56739. /**
  56740. * Update the uniform values of the procedural texture in the shader.
  56741. */
  56742. updateShaderUniforms(): void;
  56743. /**
  56744. * Define if the texture animates or not.
  56745. */
  56746. get animate(): boolean;
  56747. set animate(value: boolean);
  56748. }
  56749. }
  56750. declare module BABYLON {
  56751. /** @hidden */
  56752. export var noisePixelShader: {
  56753. name: string;
  56754. shader: string;
  56755. };
  56756. }
  56757. declare module BABYLON {
  56758. /**
  56759. * Class used to generate noise procedural textures
  56760. */
  56761. export class NoiseProceduralTexture extends ProceduralTexture {
  56762. private _time;
  56763. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56764. brightness: number;
  56765. /** Defines the number of octaves to process */
  56766. octaves: number;
  56767. /** Defines the level of persistence (0.8 by default) */
  56768. persistence: number;
  56769. /** Gets or sets animation speed factor (default is 1) */
  56770. animationSpeedFactor: number;
  56771. /**
  56772. * Creates a new NoiseProceduralTexture
  56773. * @param name defines the name fo the texture
  56774. * @param size defines the size of the texture (default is 256)
  56775. * @param scene defines the hosting scene
  56776. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56777. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56778. */
  56779. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56780. private _updateShaderUniforms;
  56781. protected _getDefines(): string;
  56782. /** Generate the current state of the procedural texture */
  56783. render(useCameraPostProcess?: boolean): void;
  56784. /**
  56785. * Serializes this noise procedural texture
  56786. * @returns a serialized noise procedural texture object
  56787. */
  56788. serialize(): any;
  56789. /**
  56790. * Clone the texture.
  56791. * @returns the cloned texture
  56792. */
  56793. clone(): NoiseProceduralTexture;
  56794. /**
  56795. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56796. * @param parsedTexture defines parsed texture data
  56797. * @param scene defines the current scene
  56798. * @param rootUrl defines the root URL containing noise procedural texture information
  56799. * @returns a parsed NoiseProceduralTexture
  56800. */
  56801. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56802. }
  56803. }
  56804. declare module BABYLON {
  56805. /**
  56806. * Raw cube texture where the raw buffers are passed in
  56807. */
  56808. export class RawCubeTexture extends CubeTexture {
  56809. /**
  56810. * Creates a cube texture where the raw buffers are passed in.
  56811. * @param scene defines the scene the texture is attached to
  56812. * @param data defines the array of data to use to create each face
  56813. * @param size defines the size of the textures
  56814. * @param format defines the format of the data
  56815. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56816. * @param generateMipMaps defines if the engine should generate the mip levels
  56817. * @param invertY defines if data must be stored with Y axis inverted
  56818. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56819. * @param compression defines the compression used (null by default)
  56820. */
  56821. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56822. /**
  56823. * Updates the raw cube texture.
  56824. * @param data defines the data to store
  56825. * @param format defines the data format
  56826. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56827. * @param invertY defines if data must be stored with Y axis inverted
  56828. * @param compression defines the compression used (null by default)
  56829. * @param level defines which level of the texture to update
  56830. */
  56831. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56832. /**
  56833. * Updates a raw cube texture with RGBD encoded data.
  56834. * @param data defines the array of data [mipmap][face] to use to create each face
  56835. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56836. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56837. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56838. * @returns a promsie that resolves when the operation is complete
  56839. */
  56840. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56841. /**
  56842. * Clones the raw cube texture.
  56843. * @return a new cube texture
  56844. */
  56845. clone(): CubeTexture;
  56846. /** @hidden */
  56847. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56848. }
  56849. }
  56850. declare module BABYLON {
  56851. /**
  56852. * Class used to store 3D textures containing user data
  56853. */
  56854. export class RawTexture3D extends Texture {
  56855. /** Gets or sets the texture format to use */
  56856. format: number;
  56857. private _engine;
  56858. /**
  56859. * Create a new RawTexture3D
  56860. * @param data defines the data of the texture
  56861. * @param width defines the width of the texture
  56862. * @param height defines the height of the texture
  56863. * @param depth defines the depth of the texture
  56864. * @param format defines the texture format to use
  56865. * @param scene defines the hosting scene
  56866. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56867. * @param invertY defines if texture must be stored with Y axis inverted
  56868. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56869. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56870. */
  56871. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56872. /** Gets or sets the texture format to use */
  56873. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56874. /**
  56875. * Update the texture with new data
  56876. * @param data defines the data to store in the texture
  56877. */
  56878. update(data: ArrayBufferView): void;
  56879. }
  56880. }
  56881. declare module BABYLON {
  56882. /**
  56883. * Class used to store 2D array textures containing user data
  56884. */
  56885. export class RawTexture2DArray extends Texture {
  56886. /** Gets or sets the texture format to use */
  56887. format: number;
  56888. private _engine;
  56889. /**
  56890. * Create a new RawTexture2DArray
  56891. * @param data defines the data of the texture
  56892. * @param width defines the width of the texture
  56893. * @param height defines the height of the texture
  56894. * @param depth defines the number of layers of the texture
  56895. * @param format defines the texture format to use
  56896. * @param scene defines the hosting scene
  56897. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56898. * @param invertY defines if texture must be stored with Y axis inverted
  56899. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56900. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56901. */
  56902. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56903. /** Gets or sets the texture format to use */
  56904. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56905. /**
  56906. * Update the texture with new data
  56907. * @param data defines the data to store in the texture
  56908. */
  56909. update(data: ArrayBufferView): void;
  56910. }
  56911. }
  56912. declare module BABYLON {
  56913. /**
  56914. * Creates a refraction texture used by refraction channel of the standard material.
  56915. * It is like a mirror but to see through a material.
  56916. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56917. */
  56918. export class RefractionTexture extends RenderTargetTexture {
  56919. /**
  56920. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56921. * 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.
  56922. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56923. */
  56924. refractionPlane: Plane;
  56925. /**
  56926. * Define how deep under the surface we should see.
  56927. */
  56928. depth: number;
  56929. /**
  56930. * Creates a refraction texture used by refraction channel of the standard material.
  56931. * It is like a mirror but to see through a material.
  56932. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56933. * @param name Define the texture name
  56934. * @param size Define the size of the underlying texture
  56935. * @param scene Define the scene the refraction belongs to
  56936. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56937. */
  56938. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56939. /**
  56940. * Clone the refraction texture.
  56941. * @returns the cloned texture
  56942. */
  56943. clone(): RefractionTexture;
  56944. /**
  56945. * Serialize the texture to a JSON representation you could use in Parse later on
  56946. * @returns the serialized JSON representation
  56947. */
  56948. serialize(): any;
  56949. }
  56950. }
  56951. declare module BABYLON {
  56952. /**
  56953. * Defines the options related to the creation of an HtmlElementTexture
  56954. */
  56955. export interface IHtmlElementTextureOptions {
  56956. /**
  56957. * Defines wether mip maps should be created or not.
  56958. */
  56959. generateMipMaps?: boolean;
  56960. /**
  56961. * Defines the sampling mode of the texture.
  56962. */
  56963. samplingMode?: number;
  56964. /**
  56965. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56966. */
  56967. engine: Nullable<ThinEngine>;
  56968. /**
  56969. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56970. */
  56971. scene: Nullable<Scene>;
  56972. }
  56973. /**
  56974. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56975. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56976. * is automatically managed.
  56977. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56978. * in your application.
  56979. *
  56980. * As the update is not automatic, you need to call them manually.
  56981. */
  56982. export class HtmlElementTexture extends BaseTexture {
  56983. /**
  56984. * The texture URL.
  56985. */
  56986. element: HTMLVideoElement | HTMLCanvasElement;
  56987. private static readonly DefaultOptions;
  56988. private _textureMatrix;
  56989. private _engine;
  56990. private _isVideo;
  56991. private _generateMipMaps;
  56992. private _samplingMode;
  56993. /**
  56994. * Instantiates a HtmlElementTexture from the following parameters.
  56995. *
  56996. * @param name Defines the name of the texture
  56997. * @param element Defines the video or canvas the texture is filled with
  56998. * @param options Defines the other none mandatory texture creation options
  56999. */
  57000. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57001. private _createInternalTexture;
  57002. /**
  57003. * Returns the texture matrix used in most of the material.
  57004. */
  57005. getTextureMatrix(): Matrix;
  57006. /**
  57007. * Updates the content of the texture.
  57008. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57009. */
  57010. update(invertY?: Nullable<boolean>): void;
  57011. }
  57012. }
  57013. declare module BABYLON {
  57014. /**
  57015. * Defines the basic options interface of a TexturePacker Frame
  57016. */
  57017. export interface ITexturePackerFrame {
  57018. /**
  57019. * The frame ID
  57020. */
  57021. id: number;
  57022. /**
  57023. * The frames Scale
  57024. */
  57025. scale: Vector2;
  57026. /**
  57027. * The Frames offset
  57028. */
  57029. offset: Vector2;
  57030. }
  57031. /**
  57032. * This is a support class for frame Data on texture packer sets.
  57033. */
  57034. export class TexturePackerFrame implements ITexturePackerFrame {
  57035. /**
  57036. * The frame ID
  57037. */
  57038. id: number;
  57039. /**
  57040. * The frames Scale
  57041. */
  57042. scale: Vector2;
  57043. /**
  57044. * The Frames offset
  57045. */
  57046. offset: Vector2;
  57047. /**
  57048. * Initializes a texture package frame.
  57049. * @param id The numerical frame identifier
  57050. * @param scale Scalar Vector2 for UV frame
  57051. * @param offset Vector2 for the frame position in UV units.
  57052. * @returns TexturePackerFrame
  57053. */
  57054. constructor(id: number, scale: Vector2, offset: Vector2);
  57055. }
  57056. }
  57057. declare module BABYLON {
  57058. /**
  57059. * Defines the basic options interface of a TexturePacker
  57060. */
  57061. export interface ITexturePackerOptions {
  57062. /**
  57063. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57064. */
  57065. map?: string[];
  57066. /**
  57067. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57068. */
  57069. uvsIn?: string;
  57070. /**
  57071. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57072. */
  57073. uvsOut?: string;
  57074. /**
  57075. * number representing the layout style. Defaults to LAYOUT_STRIP
  57076. */
  57077. layout?: number;
  57078. /**
  57079. * number of columns if using custom column count layout(2). This defaults to 4.
  57080. */
  57081. colnum?: number;
  57082. /**
  57083. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57084. */
  57085. updateInputMeshes?: boolean;
  57086. /**
  57087. * boolean flag to dispose all the source textures. Defaults to true.
  57088. */
  57089. disposeSources?: boolean;
  57090. /**
  57091. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57092. */
  57093. fillBlanks?: boolean;
  57094. /**
  57095. * string value representing the context fill style color. Defaults to 'black'.
  57096. */
  57097. customFillColor?: string;
  57098. /**
  57099. * Width and Height Value of each Frame in the TexturePacker Sets
  57100. */
  57101. frameSize?: number;
  57102. /**
  57103. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57104. */
  57105. paddingRatio?: number;
  57106. /**
  57107. * Number that declares the fill method for the padding gutter.
  57108. */
  57109. paddingMode?: number;
  57110. /**
  57111. * If in SUBUV_COLOR padding mode what color to use.
  57112. */
  57113. paddingColor?: Color3 | Color4;
  57114. }
  57115. /**
  57116. * Defines the basic interface of a TexturePacker JSON File
  57117. */
  57118. export interface ITexturePackerJSON {
  57119. /**
  57120. * The frame ID
  57121. */
  57122. name: string;
  57123. /**
  57124. * The base64 channel data
  57125. */
  57126. sets: any;
  57127. /**
  57128. * The options of the Packer
  57129. */
  57130. options: ITexturePackerOptions;
  57131. /**
  57132. * The frame data of the Packer
  57133. */
  57134. frames: Array<number>;
  57135. }
  57136. /**
  57137. * This is a support class that generates a series of packed texture sets.
  57138. * @see https://doc.babylonjs.com/babylon101/materials
  57139. */
  57140. export class TexturePacker {
  57141. /** Packer Layout Constant 0 */
  57142. static readonly LAYOUT_STRIP: number;
  57143. /** Packer Layout Constant 1 */
  57144. static readonly LAYOUT_POWER2: number;
  57145. /** Packer Layout Constant 2 */
  57146. static readonly LAYOUT_COLNUM: number;
  57147. /** Packer Layout Constant 0 */
  57148. static readonly SUBUV_WRAP: number;
  57149. /** Packer Layout Constant 1 */
  57150. static readonly SUBUV_EXTEND: number;
  57151. /** Packer Layout Constant 2 */
  57152. static readonly SUBUV_COLOR: number;
  57153. /** The Name of the Texture Package */
  57154. name: string;
  57155. /** The scene scope of the TexturePacker */
  57156. scene: Scene;
  57157. /** The Meshes to target */
  57158. meshes: AbstractMesh[];
  57159. /** Arguments passed with the Constructor */
  57160. options: ITexturePackerOptions;
  57161. /** The promise that is started upon initialization */
  57162. promise: Nullable<Promise<TexturePacker | string>>;
  57163. /** The Container object for the channel sets that are generated */
  57164. sets: object;
  57165. /** The Container array for the frames that are generated */
  57166. frames: TexturePackerFrame[];
  57167. /** The expected number of textures the system is parsing. */
  57168. private _expecting;
  57169. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57170. private _paddingValue;
  57171. /**
  57172. * Initializes a texture package series from an array of meshes or a single mesh.
  57173. * @param name The name of the package
  57174. * @param meshes The target meshes to compose the package from
  57175. * @param options The arguments that texture packer should follow while building.
  57176. * @param scene The scene which the textures are scoped to.
  57177. * @returns TexturePacker
  57178. */
  57179. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57180. /**
  57181. * Starts the package process
  57182. * @param resolve The promises resolution function
  57183. * @returns TexturePacker
  57184. */
  57185. private _createFrames;
  57186. /**
  57187. * Calculates the Size of the Channel Sets
  57188. * @returns Vector2
  57189. */
  57190. private _calculateSize;
  57191. /**
  57192. * Calculates the UV data for the frames.
  57193. * @param baseSize the base frameSize
  57194. * @param padding the base frame padding
  57195. * @param dtSize size of the Dynamic Texture for that channel
  57196. * @param dtUnits is 1/dtSize
  57197. * @param update flag to update the input meshes
  57198. */
  57199. private _calculateMeshUVFrames;
  57200. /**
  57201. * Calculates the frames Offset.
  57202. * @param index of the frame
  57203. * @returns Vector2
  57204. */
  57205. private _getFrameOffset;
  57206. /**
  57207. * Updates a Mesh to the frame data
  57208. * @param mesh that is the target
  57209. * @param frameID or the frame index
  57210. */
  57211. private _updateMeshUV;
  57212. /**
  57213. * Updates a Meshes materials to use the texture packer channels
  57214. * @param m is the mesh to target
  57215. * @param force all channels on the packer to be set.
  57216. */
  57217. private _updateTextureReferences;
  57218. /**
  57219. * Public method to set a Mesh to a frame
  57220. * @param m that is the target
  57221. * @param frameID or the frame index
  57222. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57223. */
  57224. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57225. /**
  57226. * Starts the async promise to compile the texture packer.
  57227. * @returns Promise<void>
  57228. */
  57229. processAsync(): Promise<void>;
  57230. /**
  57231. * Disposes all textures associated with this packer
  57232. */
  57233. dispose(): void;
  57234. /**
  57235. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57236. * @param imageType is the image type to use.
  57237. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57238. */
  57239. download(imageType?: string, quality?: number): void;
  57240. /**
  57241. * Public method to load a texturePacker JSON file.
  57242. * @param data of the JSON file in string format.
  57243. */
  57244. updateFromJSON(data: string): void;
  57245. }
  57246. }
  57247. declare module BABYLON {
  57248. /**
  57249. * Enum used to define the target of a block
  57250. */
  57251. export enum NodeMaterialBlockTargets {
  57252. /** Vertex shader */
  57253. Vertex = 1,
  57254. /** Fragment shader */
  57255. Fragment = 2,
  57256. /** Neutral */
  57257. Neutral = 4,
  57258. /** Vertex and Fragment */
  57259. VertexAndFragment = 3
  57260. }
  57261. }
  57262. declare module BABYLON {
  57263. /**
  57264. * Defines the kind of connection point for node based material
  57265. */
  57266. export enum NodeMaterialBlockConnectionPointTypes {
  57267. /** Float */
  57268. Float = 1,
  57269. /** Int */
  57270. Int = 2,
  57271. /** Vector2 */
  57272. Vector2 = 4,
  57273. /** Vector3 */
  57274. Vector3 = 8,
  57275. /** Vector4 */
  57276. Vector4 = 16,
  57277. /** Color3 */
  57278. Color3 = 32,
  57279. /** Color4 */
  57280. Color4 = 64,
  57281. /** Matrix */
  57282. Matrix = 128,
  57283. /** Detect type based on connection */
  57284. AutoDetect = 1024,
  57285. /** Output type that will be defined by input type */
  57286. BasedOnInput = 2048
  57287. }
  57288. }
  57289. declare module BABYLON {
  57290. /**
  57291. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57292. */
  57293. export enum NodeMaterialBlockConnectionPointMode {
  57294. /** Value is an uniform */
  57295. Uniform = 0,
  57296. /** Value is a mesh attribute */
  57297. Attribute = 1,
  57298. /** Value is a varying between vertex and fragment shaders */
  57299. Varying = 2,
  57300. /** Mode is undefined */
  57301. Undefined = 3
  57302. }
  57303. }
  57304. declare module BABYLON {
  57305. /**
  57306. * Enum used to define system values e.g. values automatically provided by the system
  57307. */
  57308. export enum NodeMaterialSystemValues {
  57309. /** World */
  57310. World = 1,
  57311. /** View */
  57312. View = 2,
  57313. /** Projection */
  57314. Projection = 3,
  57315. /** ViewProjection */
  57316. ViewProjection = 4,
  57317. /** WorldView */
  57318. WorldView = 5,
  57319. /** WorldViewProjection */
  57320. WorldViewProjection = 6,
  57321. /** CameraPosition */
  57322. CameraPosition = 7,
  57323. /** Fog Color */
  57324. FogColor = 8,
  57325. /** Delta time */
  57326. DeltaTime = 9
  57327. }
  57328. }
  57329. declare module BABYLON {
  57330. /**
  57331. * Root class for all node material optimizers
  57332. */
  57333. export class NodeMaterialOptimizer {
  57334. /**
  57335. * Function used to optimize a NodeMaterial graph
  57336. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57337. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57338. */
  57339. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57340. }
  57341. }
  57342. declare module BABYLON {
  57343. /**
  57344. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57345. */
  57346. export class TransformBlock extends NodeMaterialBlock {
  57347. /**
  57348. * Defines the value to use to complement W value to transform it to a Vector4
  57349. */
  57350. complementW: number;
  57351. /**
  57352. * Defines the value to use to complement z value to transform it to a Vector4
  57353. */
  57354. complementZ: number;
  57355. /**
  57356. * Creates a new TransformBlock
  57357. * @param name defines the block name
  57358. */
  57359. constructor(name: string);
  57360. /**
  57361. * Gets the current class name
  57362. * @returns the class name
  57363. */
  57364. getClassName(): string;
  57365. /**
  57366. * Gets the vector input
  57367. */
  57368. get vector(): NodeMaterialConnectionPoint;
  57369. /**
  57370. * Gets the output component
  57371. */
  57372. get output(): NodeMaterialConnectionPoint;
  57373. /**
  57374. * Gets the xyz output component
  57375. */
  57376. get xyz(): NodeMaterialConnectionPoint;
  57377. /**
  57378. * Gets the matrix transform input
  57379. */
  57380. get transform(): NodeMaterialConnectionPoint;
  57381. protected _buildBlock(state: NodeMaterialBuildState): this;
  57382. serialize(): any;
  57383. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57384. protected _dumpPropertiesCode(): string;
  57385. }
  57386. }
  57387. declare module BABYLON {
  57388. /**
  57389. * Block used to output the vertex position
  57390. */
  57391. export class VertexOutputBlock extends NodeMaterialBlock {
  57392. /**
  57393. * Creates a new VertexOutputBlock
  57394. * @param name defines the block name
  57395. */
  57396. constructor(name: string);
  57397. /**
  57398. * Gets the current class name
  57399. * @returns the class name
  57400. */
  57401. getClassName(): string;
  57402. /**
  57403. * Gets the vector input component
  57404. */
  57405. get vector(): NodeMaterialConnectionPoint;
  57406. protected _buildBlock(state: NodeMaterialBuildState): this;
  57407. }
  57408. }
  57409. declare module BABYLON {
  57410. /**
  57411. * Block used to output the final color
  57412. */
  57413. export class FragmentOutputBlock extends NodeMaterialBlock {
  57414. /**
  57415. * Create a new FragmentOutputBlock
  57416. * @param name defines the block name
  57417. */
  57418. constructor(name: string);
  57419. /**
  57420. * Gets the current class name
  57421. * @returns the class name
  57422. */
  57423. getClassName(): string;
  57424. /**
  57425. * Gets the rgba input component
  57426. */
  57427. get rgba(): NodeMaterialConnectionPoint;
  57428. /**
  57429. * Gets the rgb input component
  57430. */
  57431. get rgb(): NodeMaterialConnectionPoint;
  57432. /**
  57433. * Gets the a input component
  57434. */
  57435. get a(): NodeMaterialConnectionPoint;
  57436. protected _buildBlock(state: NodeMaterialBuildState): this;
  57437. }
  57438. }
  57439. declare module BABYLON {
  57440. /**
  57441. * Block used to read a reflection texture from a sampler
  57442. */
  57443. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57444. private _define3DName;
  57445. private _defineCubicName;
  57446. private _defineExplicitName;
  57447. private _defineProjectionName;
  57448. private _defineLocalCubicName;
  57449. private _defineSphericalName;
  57450. private _definePlanarName;
  57451. private _defineEquirectangularName;
  57452. private _defineMirroredEquirectangularFixedName;
  57453. private _defineEquirectangularFixedName;
  57454. private _defineSkyboxName;
  57455. private _cubeSamplerName;
  57456. private _2DSamplerName;
  57457. private _positionUVWName;
  57458. private _directionWName;
  57459. private _reflectionCoordsName;
  57460. private _reflection2DCoordsName;
  57461. private _reflectionColorName;
  57462. private _reflectionMatrixName;
  57463. /**
  57464. * Gets or sets the texture associated with the node
  57465. */
  57466. texture: Nullable<BaseTexture>;
  57467. /**
  57468. * Create a new TextureBlock
  57469. * @param name defines the block name
  57470. */
  57471. constructor(name: string);
  57472. /**
  57473. * Gets the current class name
  57474. * @returns the class name
  57475. */
  57476. getClassName(): string;
  57477. /**
  57478. * Gets the world position input component
  57479. */
  57480. get position(): NodeMaterialConnectionPoint;
  57481. /**
  57482. * Gets the world position input component
  57483. */
  57484. get worldPosition(): NodeMaterialConnectionPoint;
  57485. /**
  57486. * Gets the world normal input component
  57487. */
  57488. get worldNormal(): NodeMaterialConnectionPoint;
  57489. /**
  57490. * Gets the world input component
  57491. */
  57492. get world(): NodeMaterialConnectionPoint;
  57493. /**
  57494. * Gets the camera (or eye) position component
  57495. */
  57496. get cameraPosition(): NodeMaterialConnectionPoint;
  57497. /**
  57498. * Gets the view input component
  57499. */
  57500. get view(): NodeMaterialConnectionPoint;
  57501. /**
  57502. * Gets the rgb output component
  57503. */
  57504. get rgb(): NodeMaterialConnectionPoint;
  57505. /**
  57506. * Gets the r output component
  57507. */
  57508. get r(): NodeMaterialConnectionPoint;
  57509. /**
  57510. * Gets the g output component
  57511. */
  57512. get g(): NodeMaterialConnectionPoint;
  57513. /**
  57514. * Gets the b output component
  57515. */
  57516. get b(): NodeMaterialConnectionPoint;
  57517. autoConfigure(material: NodeMaterial): void;
  57518. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57519. isReady(): boolean;
  57520. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57521. private _injectVertexCode;
  57522. private _writeOutput;
  57523. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57524. protected _dumpPropertiesCode(): string;
  57525. serialize(): any;
  57526. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57527. }
  57528. }
  57529. declare module BABYLON {
  57530. /**
  57531. * Interface used to configure the node material editor
  57532. */
  57533. export interface INodeMaterialEditorOptions {
  57534. /** Define the URl to load node editor script */
  57535. editorURL?: string;
  57536. }
  57537. /** @hidden */
  57538. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57539. NORMAL: boolean;
  57540. TANGENT: boolean;
  57541. UV1: boolean;
  57542. /** BONES */
  57543. NUM_BONE_INFLUENCERS: number;
  57544. BonesPerMesh: number;
  57545. BONETEXTURE: boolean;
  57546. /** MORPH TARGETS */
  57547. MORPHTARGETS: boolean;
  57548. MORPHTARGETS_NORMAL: boolean;
  57549. MORPHTARGETS_TANGENT: boolean;
  57550. MORPHTARGETS_UV: boolean;
  57551. NUM_MORPH_INFLUENCERS: number;
  57552. /** IMAGE PROCESSING */
  57553. IMAGEPROCESSING: boolean;
  57554. VIGNETTE: boolean;
  57555. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57556. VIGNETTEBLENDMODEOPAQUE: boolean;
  57557. TONEMAPPING: boolean;
  57558. TONEMAPPING_ACES: boolean;
  57559. CONTRAST: boolean;
  57560. EXPOSURE: boolean;
  57561. COLORCURVES: boolean;
  57562. COLORGRADING: boolean;
  57563. COLORGRADING3D: boolean;
  57564. SAMPLER3DGREENDEPTH: boolean;
  57565. SAMPLER3DBGRMAP: boolean;
  57566. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57567. /** MISC. */
  57568. BUMPDIRECTUV: number;
  57569. constructor();
  57570. setValue(name: string, value: boolean): void;
  57571. }
  57572. /**
  57573. * Class used to configure NodeMaterial
  57574. */
  57575. export interface INodeMaterialOptions {
  57576. /**
  57577. * Defines if blocks should emit comments
  57578. */
  57579. emitComments: boolean;
  57580. }
  57581. /**
  57582. * Class used to create a node based material built by assembling shader blocks
  57583. */
  57584. export class NodeMaterial extends PushMaterial {
  57585. private static _BuildIdGenerator;
  57586. private _options;
  57587. private _vertexCompilationState;
  57588. private _fragmentCompilationState;
  57589. private _sharedData;
  57590. private _buildId;
  57591. private _buildWasSuccessful;
  57592. private _cachedWorldViewMatrix;
  57593. private _cachedWorldViewProjectionMatrix;
  57594. private _optimizers;
  57595. private _animationFrame;
  57596. /** Define the Url to load node editor script */
  57597. static EditorURL: string;
  57598. /** Define the Url to load snippets */
  57599. static SnippetUrl: string;
  57600. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  57601. static IgnoreTexturesAtLoadTime: boolean;
  57602. private BJSNODEMATERIALEDITOR;
  57603. /** Get the inspector from bundle or global */
  57604. private _getGlobalNodeMaterialEditor;
  57605. /**
  57606. * Snippet ID if the material was created from the snippet server
  57607. */
  57608. snippetId: string;
  57609. /**
  57610. * Gets or sets data used by visual editor
  57611. * @see https://nme.babylonjs.com
  57612. */
  57613. editorData: any;
  57614. /**
  57615. * 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)
  57616. */
  57617. ignoreAlpha: boolean;
  57618. /**
  57619. * Defines the maximum number of lights that can be used in the material
  57620. */
  57621. maxSimultaneousLights: number;
  57622. /**
  57623. * Observable raised when the material is built
  57624. */
  57625. onBuildObservable: Observable<NodeMaterial>;
  57626. /**
  57627. * Gets or sets the root nodes of the material vertex shader
  57628. */
  57629. _vertexOutputNodes: NodeMaterialBlock[];
  57630. /**
  57631. * Gets or sets the root nodes of the material fragment (pixel) shader
  57632. */
  57633. _fragmentOutputNodes: NodeMaterialBlock[];
  57634. /** Gets or sets options to control the node material overall behavior */
  57635. get options(): INodeMaterialOptions;
  57636. set options(options: INodeMaterialOptions);
  57637. /**
  57638. * Default configuration related to image processing available in the standard Material.
  57639. */
  57640. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57641. /**
  57642. * Gets the image processing configuration used either in this material.
  57643. */
  57644. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57645. /**
  57646. * Sets the Default image processing configuration used either in the this material.
  57647. *
  57648. * If sets to null, the scene one is in use.
  57649. */
  57650. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57651. /**
  57652. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57653. */
  57654. attachedBlocks: NodeMaterialBlock[];
  57655. /**
  57656. * Create a new node based material
  57657. * @param name defines the material name
  57658. * @param scene defines the hosting scene
  57659. * @param options defines creation option
  57660. */
  57661. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57662. /**
  57663. * Gets the current class name of the material e.g. "NodeMaterial"
  57664. * @returns the class name
  57665. */
  57666. getClassName(): string;
  57667. /**
  57668. * Keep track of the image processing observer to allow dispose and replace.
  57669. */
  57670. private _imageProcessingObserver;
  57671. /**
  57672. * Attaches a new image processing configuration to the Standard Material.
  57673. * @param configuration
  57674. */
  57675. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57676. /**
  57677. * Get a block by its name
  57678. * @param name defines the name of the block to retrieve
  57679. * @returns the required block or null if not found
  57680. */
  57681. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57682. /**
  57683. * Get a block by its name
  57684. * @param predicate defines the predicate used to find the good candidate
  57685. * @returns the required block or null if not found
  57686. */
  57687. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57688. /**
  57689. * Get an input block by its name
  57690. * @param predicate defines the predicate used to find the good candidate
  57691. * @returns the required input block or null if not found
  57692. */
  57693. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57694. /**
  57695. * Gets the list of input blocks attached to this material
  57696. * @returns an array of InputBlocks
  57697. */
  57698. getInputBlocks(): InputBlock[];
  57699. /**
  57700. * Adds a new optimizer to the list of optimizers
  57701. * @param optimizer defines the optimizers to add
  57702. * @returns the current material
  57703. */
  57704. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57705. /**
  57706. * Remove an optimizer from the list of optimizers
  57707. * @param optimizer defines the optimizers to remove
  57708. * @returns the current material
  57709. */
  57710. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57711. /**
  57712. * Add a new block to the list of output nodes
  57713. * @param node defines the node to add
  57714. * @returns the current material
  57715. */
  57716. addOutputNode(node: NodeMaterialBlock): this;
  57717. /**
  57718. * Remove a block from the list of root nodes
  57719. * @param node defines the node to remove
  57720. * @returns the current material
  57721. */
  57722. removeOutputNode(node: NodeMaterialBlock): this;
  57723. private _addVertexOutputNode;
  57724. private _removeVertexOutputNode;
  57725. private _addFragmentOutputNode;
  57726. private _removeFragmentOutputNode;
  57727. /**
  57728. * Specifies if the material will require alpha blending
  57729. * @returns a boolean specifying if alpha blending is needed
  57730. */
  57731. needAlphaBlending(): boolean;
  57732. /**
  57733. * Specifies if this material should be rendered in alpha test mode
  57734. * @returns a boolean specifying if an alpha test is needed.
  57735. */
  57736. needAlphaTesting(): boolean;
  57737. private _initializeBlock;
  57738. private _resetDualBlocks;
  57739. /**
  57740. * Remove a block from the current node material
  57741. * @param block defines the block to remove
  57742. */
  57743. removeBlock(block: NodeMaterialBlock): void;
  57744. /**
  57745. * Build the material and generates the inner effect
  57746. * @param verbose defines if the build should log activity
  57747. */
  57748. build(verbose?: boolean): void;
  57749. /**
  57750. * Runs an otpimization phase to try to improve the shader code
  57751. */
  57752. optimize(): void;
  57753. private _prepareDefinesForAttributes;
  57754. /**
  57755. * Get if the submesh is ready to be used and all its information available.
  57756. * Child classes can use it to update shaders
  57757. * @param mesh defines the mesh to check
  57758. * @param subMesh defines which submesh to check
  57759. * @param useInstances specifies that instances should be used
  57760. * @returns a boolean indicating that the submesh is ready or not
  57761. */
  57762. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57763. /**
  57764. * Get a string representing the shaders built by the current node graph
  57765. */
  57766. get compiledShaders(): string;
  57767. /**
  57768. * Binds the world matrix to the material
  57769. * @param world defines the world transformation matrix
  57770. */
  57771. bindOnlyWorldMatrix(world: Matrix): void;
  57772. /**
  57773. * Binds the submesh to this material by preparing the effect and shader to draw
  57774. * @param world defines the world transformation matrix
  57775. * @param mesh defines the mesh containing the submesh
  57776. * @param subMesh defines the submesh to bind the material to
  57777. */
  57778. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57779. /**
  57780. * Gets the active textures from the material
  57781. * @returns an array of textures
  57782. */
  57783. getActiveTextures(): BaseTexture[];
  57784. /**
  57785. * Gets the list of texture blocks
  57786. * @returns an array of texture blocks
  57787. */
  57788. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57789. /**
  57790. * Specifies if the material uses a texture
  57791. * @param texture defines the texture to check against the material
  57792. * @returns a boolean specifying if the material uses the texture
  57793. */
  57794. hasTexture(texture: BaseTexture): boolean;
  57795. /**
  57796. * Disposes the material
  57797. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57798. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57799. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57800. */
  57801. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57802. /** Creates the node editor window. */
  57803. private _createNodeEditor;
  57804. /**
  57805. * Launch the node material editor
  57806. * @param config Define the configuration of the editor
  57807. * @return a promise fulfilled when the node editor is visible
  57808. */
  57809. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57810. /**
  57811. * Clear the current material
  57812. */
  57813. clear(): void;
  57814. /**
  57815. * Clear the current material and set it to a default state
  57816. */
  57817. setToDefault(): void;
  57818. /**
  57819. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57820. * @param url defines the url to load from
  57821. * @returns a promise that will fullfil when the material is fully loaded
  57822. */
  57823. loadAsync(url: string): Promise<void>;
  57824. private _gatherBlocks;
  57825. /**
  57826. * Generate a string containing the code declaration required to create an equivalent of this material
  57827. * @returns a string
  57828. */
  57829. generateCode(): string;
  57830. /**
  57831. * Serializes this material in a JSON representation
  57832. * @returns the serialized material object
  57833. */
  57834. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57835. private _restoreConnections;
  57836. /**
  57837. * Clear the current graph and load a new one from a serialization object
  57838. * @param source defines the JSON representation of the material
  57839. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57840. */
  57841. loadFromSerialization(source: any, rootUrl?: string): void;
  57842. /**
  57843. * Makes a duplicate of the current material.
  57844. * @param name - name to use for the new material.
  57845. */
  57846. clone(name: string): NodeMaterial;
  57847. /**
  57848. * Creates a node material from parsed material data
  57849. * @param source defines the JSON representation of the material
  57850. * @param scene defines the hosting scene
  57851. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57852. * @returns a new node material
  57853. */
  57854. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57855. /**
  57856. * Creates a node material from a snippet saved in a remote file
  57857. * @param name defines the name of the material to create
  57858. * @param url defines the url to load from
  57859. * @param scene defines the hosting scene
  57860. * @returns a promise that will resolve to the new node material
  57861. */
  57862. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57863. /**
  57864. * Creates a node material from a snippet saved by the node material editor
  57865. * @param snippetId defines the snippet to load
  57866. * @param scene defines the hosting scene
  57867. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57868. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  57869. * @returns a promise that will resolve to the new node material
  57870. */
  57871. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  57872. /**
  57873. * Creates a new node material set to default basic configuration
  57874. * @param name defines the name of the material
  57875. * @param scene defines the hosting scene
  57876. * @returns a new NodeMaterial
  57877. */
  57878. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57879. }
  57880. }
  57881. declare module BABYLON {
  57882. /**
  57883. * Block used to read a texture from a sampler
  57884. */
  57885. export class TextureBlock extends NodeMaterialBlock {
  57886. private _defineName;
  57887. private _linearDefineName;
  57888. private _tempTextureRead;
  57889. private _samplerName;
  57890. private _transformedUVName;
  57891. private _textureTransformName;
  57892. private _textureInfoName;
  57893. private _mainUVName;
  57894. private _mainUVDefineName;
  57895. /**
  57896. * Gets or sets the texture associated with the node
  57897. */
  57898. texture: Nullable<Texture>;
  57899. /**
  57900. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57901. */
  57902. convertToGammaSpace: boolean;
  57903. /**
  57904. * Create a new TextureBlock
  57905. * @param name defines the block name
  57906. */
  57907. constructor(name: string);
  57908. /**
  57909. * Gets the current class name
  57910. * @returns the class name
  57911. */
  57912. getClassName(): string;
  57913. /**
  57914. * Gets the uv input component
  57915. */
  57916. get uv(): NodeMaterialConnectionPoint;
  57917. /**
  57918. * Gets the rgba output component
  57919. */
  57920. get rgba(): NodeMaterialConnectionPoint;
  57921. /**
  57922. * Gets the rgb output component
  57923. */
  57924. get rgb(): NodeMaterialConnectionPoint;
  57925. /**
  57926. * Gets the r output component
  57927. */
  57928. get r(): NodeMaterialConnectionPoint;
  57929. /**
  57930. * Gets the g output component
  57931. */
  57932. get g(): NodeMaterialConnectionPoint;
  57933. /**
  57934. * Gets the b output component
  57935. */
  57936. get b(): NodeMaterialConnectionPoint;
  57937. /**
  57938. * Gets the a output component
  57939. */
  57940. get a(): NodeMaterialConnectionPoint;
  57941. get target(): NodeMaterialBlockTargets;
  57942. autoConfigure(material: NodeMaterial): void;
  57943. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57944. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57945. isReady(): boolean;
  57946. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57947. private get _isMixed();
  57948. private _injectVertexCode;
  57949. private _writeTextureRead;
  57950. private _writeOutput;
  57951. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57952. protected _dumpPropertiesCode(): string;
  57953. serialize(): any;
  57954. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57955. }
  57956. }
  57957. declare module BABYLON {
  57958. /**
  57959. * Class used to store shared data between 2 NodeMaterialBuildState
  57960. */
  57961. export class NodeMaterialBuildStateSharedData {
  57962. /**
  57963. * Gets the list of emitted varyings
  57964. */
  57965. temps: string[];
  57966. /**
  57967. * Gets the list of emitted varyings
  57968. */
  57969. varyings: string[];
  57970. /**
  57971. * Gets the varying declaration string
  57972. */
  57973. varyingDeclaration: string;
  57974. /**
  57975. * Input blocks
  57976. */
  57977. inputBlocks: InputBlock[];
  57978. /**
  57979. * Input blocks
  57980. */
  57981. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57982. /**
  57983. * Bindable blocks (Blocks that need to set data to the effect)
  57984. */
  57985. bindableBlocks: NodeMaterialBlock[];
  57986. /**
  57987. * List of blocks that can provide a compilation fallback
  57988. */
  57989. blocksWithFallbacks: NodeMaterialBlock[];
  57990. /**
  57991. * List of blocks that can provide a define update
  57992. */
  57993. blocksWithDefines: NodeMaterialBlock[];
  57994. /**
  57995. * List of blocks that can provide a repeatable content
  57996. */
  57997. repeatableContentBlocks: NodeMaterialBlock[];
  57998. /**
  57999. * List of blocks that can provide a dynamic list of uniforms
  58000. */
  58001. dynamicUniformBlocks: NodeMaterialBlock[];
  58002. /**
  58003. * List of blocks that can block the isReady function for the material
  58004. */
  58005. blockingBlocks: NodeMaterialBlock[];
  58006. /**
  58007. * Gets the list of animated inputs
  58008. */
  58009. animatedInputs: InputBlock[];
  58010. /**
  58011. * Build Id used to avoid multiple recompilations
  58012. */
  58013. buildId: number;
  58014. /** List of emitted variables */
  58015. variableNames: {
  58016. [key: string]: number;
  58017. };
  58018. /** List of emitted defines */
  58019. defineNames: {
  58020. [key: string]: number;
  58021. };
  58022. /** Should emit comments? */
  58023. emitComments: boolean;
  58024. /** Emit build activity */
  58025. verbose: boolean;
  58026. /** Gets or sets the hosting scene */
  58027. scene: Scene;
  58028. /**
  58029. * Gets the compilation hints emitted at compilation time
  58030. */
  58031. hints: {
  58032. needWorldViewMatrix: boolean;
  58033. needWorldViewProjectionMatrix: boolean;
  58034. needAlphaBlending: boolean;
  58035. needAlphaTesting: boolean;
  58036. };
  58037. /**
  58038. * List of compilation checks
  58039. */
  58040. checks: {
  58041. emitVertex: boolean;
  58042. emitFragment: boolean;
  58043. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58044. };
  58045. /** Creates a new shared data */
  58046. constructor();
  58047. /**
  58048. * Emits console errors and exceptions if there is a failing check
  58049. */
  58050. emitErrors(): void;
  58051. }
  58052. }
  58053. declare module BABYLON {
  58054. /**
  58055. * Class used to store node based material build state
  58056. */
  58057. export class NodeMaterialBuildState {
  58058. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58059. supportUniformBuffers: boolean;
  58060. /**
  58061. * Gets the list of emitted attributes
  58062. */
  58063. attributes: string[];
  58064. /**
  58065. * Gets the list of emitted uniforms
  58066. */
  58067. uniforms: string[];
  58068. /**
  58069. * Gets the list of emitted constants
  58070. */
  58071. constants: string[];
  58072. /**
  58073. * Gets the list of emitted samplers
  58074. */
  58075. samplers: string[];
  58076. /**
  58077. * Gets the list of emitted functions
  58078. */
  58079. functions: {
  58080. [key: string]: string;
  58081. };
  58082. /**
  58083. * Gets the list of emitted extensions
  58084. */
  58085. extensions: {
  58086. [key: string]: string;
  58087. };
  58088. /**
  58089. * Gets the target of the compilation state
  58090. */
  58091. target: NodeMaterialBlockTargets;
  58092. /**
  58093. * Gets the list of emitted counters
  58094. */
  58095. counters: {
  58096. [key: string]: number;
  58097. };
  58098. /**
  58099. * Shared data between multiple NodeMaterialBuildState instances
  58100. */
  58101. sharedData: NodeMaterialBuildStateSharedData;
  58102. /** @hidden */
  58103. _vertexState: NodeMaterialBuildState;
  58104. /** @hidden */
  58105. _attributeDeclaration: string;
  58106. /** @hidden */
  58107. _uniformDeclaration: string;
  58108. /** @hidden */
  58109. _constantDeclaration: string;
  58110. /** @hidden */
  58111. _samplerDeclaration: string;
  58112. /** @hidden */
  58113. _varyingTransfer: string;
  58114. private _repeatableContentAnchorIndex;
  58115. /** @hidden */
  58116. _builtCompilationString: string;
  58117. /**
  58118. * Gets the emitted compilation strings
  58119. */
  58120. compilationString: string;
  58121. /**
  58122. * Finalize the compilation strings
  58123. * @param state defines the current compilation state
  58124. */
  58125. finalize(state: NodeMaterialBuildState): void;
  58126. /** @hidden */
  58127. get _repeatableContentAnchor(): string;
  58128. /** @hidden */
  58129. _getFreeVariableName(prefix: string): string;
  58130. /** @hidden */
  58131. _getFreeDefineName(prefix: string): string;
  58132. /** @hidden */
  58133. _excludeVariableName(name: string): void;
  58134. /** @hidden */
  58135. _emit2DSampler(name: string): void;
  58136. /** @hidden */
  58137. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58138. /** @hidden */
  58139. _emitExtension(name: string, extension: string): void;
  58140. /** @hidden */
  58141. _emitFunction(name: string, code: string, comments: string): void;
  58142. /** @hidden */
  58143. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58144. replaceStrings?: {
  58145. search: RegExp;
  58146. replace: string;
  58147. }[];
  58148. repeatKey?: string;
  58149. }): string;
  58150. /** @hidden */
  58151. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58152. repeatKey?: string;
  58153. removeAttributes?: boolean;
  58154. removeUniforms?: boolean;
  58155. removeVaryings?: boolean;
  58156. removeIfDef?: boolean;
  58157. replaceStrings?: {
  58158. search: RegExp;
  58159. replace: string;
  58160. }[];
  58161. }, storeKey?: string): void;
  58162. /** @hidden */
  58163. _registerTempVariable(name: string): boolean;
  58164. /** @hidden */
  58165. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58166. /** @hidden */
  58167. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58168. /** @hidden */
  58169. _emitFloat(value: number): string;
  58170. }
  58171. }
  58172. declare module BABYLON {
  58173. /**
  58174. * Defines a block that can be used inside a node based material
  58175. */
  58176. export class NodeMaterialBlock {
  58177. private _buildId;
  58178. private _buildTarget;
  58179. private _target;
  58180. private _isFinalMerger;
  58181. private _isInput;
  58182. protected _isUnique: boolean;
  58183. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58184. inputsAreExclusive: boolean;
  58185. /** @hidden */
  58186. _codeVariableName: string;
  58187. /** @hidden */
  58188. _inputs: NodeMaterialConnectionPoint[];
  58189. /** @hidden */
  58190. _outputs: NodeMaterialConnectionPoint[];
  58191. /** @hidden */
  58192. _preparationId: number;
  58193. /**
  58194. * Gets or sets the name of the block
  58195. */
  58196. name: string;
  58197. /**
  58198. * Gets or sets the unique id of the node
  58199. */
  58200. uniqueId: number;
  58201. /**
  58202. * Gets or sets the comments associated with this block
  58203. */
  58204. comments: string;
  58205. /**
  58206. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58207. */
  58208. get isUnique(): boolean;
  58209. /**
  58210. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58211. */
  58212. get isFinalMerger(): boolean;
  58213. /**
  58214. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58215. */
  58216. get isInput(): boolean;
  58217. /**
  58218. * Gets or sets the build Id
  58219. */
  58220. get buildId(): number;
  58221. set buildId(value: number);
  58222. /**
  58223. * Gets or sets the target of the block
  58224. */
  58225. get target(): NodeMaterialBlockTargets;
  58226. set target(value: NodeMaterialBlockTargets);
  58227. /**
  58228. * Gets the list of input points
  58229. */
  58230. get inputs(): NodeMaterialConnectionPoint[];
  58231. /** Gets the list of output points */
  58232. get outputs(): NodeMaterialConnectionPoint[];
  58233. /**
  58234. * Find an input by its name
  58235. * @param name defines the name of the input to look for
  58236. * @returns the input or null if not found
  58237. */
  58238. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58239. /**
  58240. * Find an output by its name
  58241. * @param name defines the name of the outputto look for
  58242. * @returns the output or null if not found
  58243. */
  58244. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58245. /**
  58246. * Creates a new NodeMaterialBlock
  58247. * @param name defines the block name
  58248. * @param target defines the target of that block (Vertex by default)
  58249. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58250. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58251. */
  58252. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58253. /**
  58254. * Initialize the block and prepare the context for build
  58255. * @param state defines the state that will be used for the build
  58256. */
  58257. initialize(state: NodeMaterialBuildState): void;
  58258. /**
  58259. * Bind data to effect. Will only be called for blocks with isBindable === true
  58260. * @param effect defines the effect to bind data to
  58261. * @param nodeMaterial defines the hosting NodeMaterial
  58262. * @param mesh defines the mesh that will be rendered
  58263. */
  58264. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58265. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58266. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58267. protected _writeFloat(value: number): string;
  58268. /**
  58269. * Gets the current class name e.g. "NodeMaterialBlock"
  58270. * @returns the class name
  58271. */
  58272. getClassName(): string;
  58273. /**
  58274. * Register a new input. Must be called inside a block constructor
  58275. * @param name defines the connection point name
  58276. * @param type defines the connection point type
  58277. * @param isOptional defines a boolean indicating that this input can be omitted
  58278. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58279. * @returns the current block
  58280. */
  58281. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58282. /**
  58283. * Register a new output. Must be called inside a block constructor
  58284. * @param name defines the connection point name
  58285. * @param type defines the connection point type
  58286. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58287. * @returns the current block
  58288. */
  58289. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58290. /**
  58291. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58292. * @param forOutput defines an optional connection point to check compatibility with
  58293. * @returns the first available input or null
  58294. */
  58295. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58296. /**
  58297. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58298. * @param forBlock defines an optional block to check compatibility with
  58299. * @returns the first available input or null
  58300. */
  58301. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58302. /**
  58303. * Gets the sibling of the given output
  58304. * @param current defines the current output
  58305. * @returns the next output in the list or null
  58306. */
  58307. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58308. /**
  58309. * Connect current block with another block
  58310. * @param other defines the block to connect with
  58311. * @param options define the various options to help pick the right connections
  58312. * @returns the current block
  58313. */
  58314. connectTo(other: NodeMaterialBlock, options?: {
  58315. input?: string;
  58316. output?: string;
  58317. outputSwizzle?: string;
  58318. }): this | undefined;
  58319. protected _buildBlock(state: NodeMaterialBuildState): void;
  58320. /**
  58321. * Add uniforms, samplers and uniform buffers at compilation time
  58322. * @param state defines the state to update
  58323. * @param nodeMaterial defines the node material requesting the update
  58324. * @param defines defines the material defines to update
  58325. * @param uniformBuffers defines the list of uniform buffer names
  58326. */
  58327. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58328. /**
  58329. * Add potential fallbacks if shader compilation fails
  58330. * @param mesh defines the mesh to be rendered
  58331. * @param fallbacks defines the current prioritized list of fallbacks
  58332. */
  58333. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58334. /**
  58335. * Initialize defines for shader compilation
  58336. * @param mesh defines the mesh to be rendered
  58337. * @param nodeMaterial defines the node material requesting the update
  58338. * @param defines defines the material defines to update
  58339. * @param useInstances specifies that instances should be used
  58340. */
  58341. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58342. /**
  58343. * Update defines for shader compilation
  58344. * @param mesh defines the mesh to be rendered
  58345. * @param nodeMaterial defines the node material requesting the update
  58346. * @param defines defines the material defines to update
  58347. * @param useInstances specifies that instances should be used
  58348. */
  58349. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58350. /**
  58351. * Lets the block try to connect some inputs automatically
  58352. * @param material defines the hosting NodeMaterial
  58353. */
  58354. autoConfigure(material: NodeMaterial): void;
  58355. /**
  58356. * Function called when a block is declared as repeatable content generator
  58357. * @param vertexShaderState defines the current compilation state for the vertex shader
  58358. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58359. * @param mesh defines the mesh to be rendered
  58360. * @param defines defines the material defines to update
  58361. */
  58362. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58363. /**
  58364. * Checks if the block is ready
  58365. * @param mesh defines the mesh to be rendered
  58366. * @param nodeMaterial defines the node material requesting the update
  58367. * @param defines defines the material defines to update
  58368. * @param useInstances specifies that instances should be used
  58369. * @returns true if the block is ready
  58370. */
  58371. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58372. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58373. private _processBuild;
  58374. /**
  58375. * Compile the current node and generate the shader code
  58376. * @param state defines the current compilation state (uniforms, samplers, current string)
  58377. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58378. * @returns true if already built
  58379. */
  58380. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58381. protected _inputRename(name: string): string;
  58382. protected _outputRename(name: string): string;
  58383. protected _dumpPropertiesCode(): string;
  58384. /** @hidden */
  58385. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58386. /** @hidden */
  58387. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58388. /**
  58389. * Clone the current block to a new identical block
  58390. * @param scene defines the hosting scene
  58391. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58392. * @returns a copy of the current block
  58393. */
  58394. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58395. /**
  58396. * Serializes this block in a JSON representation
  58397. * @returns the serialized block object
  58398. */
  58399. serialize(): any;
  58400. /** @hidden */
  58401. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58402. /**
  58403. * Release resources
  58404. */
  58405. dispose(): void;
  58406. }
  58407. }
  58408. declare module BABYLON {
  58409. /**
  58410. * Enum defining the type of animations supported by InputBlock
  58411. */
  58412. export enum AnimatedInputBlockTypes {
  58413. /** No animation */
  58414. None = 0,
  58415. /** Time based animation. Will only work for floats */
  58416. Time = 1
  58417. }
  58418. }
  58419. declare module BABYLON {
  58420. /**
  58421. * Block used to expose an input value
  58422. */
  58423. export class InputBlock extends NodeMaterialBlock {
  58424. private _mode;
  58425. private _associatedVariableName;
  58426. private _storedValue;
  58427. private _valueCallback;
  58428. private _type;
  58429. private _animationType;
  58430. /** Gets or set a value used to limit the range of float values */
  58431. min: number;
  58432. /** Gets or set a value used to limit the range of float values */
  58433. max: number;
  58434. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58435. isBoolean: boolean;
  58436. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58437. matrixMode: number;
  58438. /** @hidden */
  58439. _systemValue: Nullable<NodeMaterialSystemValues>;
  58440. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58441. visibleInInspector: boolean;
  58442. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58443. isConstant: boolean;
  58444. /** Gets or sets the group to use to display this block in the Inspector */
  58445. groupInInspector: string;
  58446. /** Gets an observable raised when the value is changed */
  58447. onValueChangedObservable: Observable<InputBlock>;
  58448. /**
  58449. * Gets or sets the connection point type (default is float)
  58450. */
  58451. get type(): NodeMaterialBlockConnectionPointTypes;
  58452. /**
  58453. * Creates a new InputBlock
  58454. * @param name defines the block name
  58455. * @param target defines the target of that block (Vertex by default)
  58456. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58457. */
  58458. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58459. /**
  58460. * Gets the output component
  58461. */
  58462. get output(): NodeMaterialConnectionPoint;
  58463. /**
  58464. * Set the source of this connection point to a vertex attribute
  58465. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58466. * @returns the current connection point
  58467. */
  58468. setAsAttribute(attributeName?: string): InputBlock;
  58469. /**
  58470. * Set the source of this connection point to a system value
  58471. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58472. * @returns the current connection point
  58473. */
  58474. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58475. /**
  58476. * Gets or sets the value of that point.
  58477. * Please note that this value will be ignored if valueCallback is defined
  58478. */
  58479. get value(): any;
  58480. set value(value: any);
  58481. /**
  58482. * Gets or sets a callback used to get the value of that point.
  58483. * Please note that setting this value will force the connection point to ignore the value property
  58484. */
  58485. get valueCallback(): () => any;
  58486. set valueCallback(value: () => any);
  58487. /**
  58488. * Gets or sets the associated variable name in the shader
  58489. */
  58490. get associatedVariableName(): string;
  58491. set associatedVariableName(value: string);
  58492. /** Gets or sets the type of animation applied to the input */
  58493. get animationType(): AnimatedInputBlockTypes;
  58494. set animationType(value: AnimatedInputBlockTypes);
  58495. /**
  58496. * Gets a boolean indicating that this connection point not defined yet
  58497. */
  58498. get isUndefined(): boolean;
  58499. /**
  58500. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58501. * In this case the connection point name must be the name of the uniform to use.
  58502. * Can only be set on inputs
  58503. */
  58504. get isUniform(): boolean;
  58505. set isUniform(value: boolean);
  58506. /**
  58507. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58508. * In this case the connection point name must be the name of the attribute to use
  58509. * Can only be set on inputs
  58510. */
  58511. get isAttribute(): boolean;
  58512. set isAttribute(value: boolean);
  58513. /**
  58514. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58515. * Can only be set on exit points
  58516. */
  58517. get isVarying(): boolean;
  58518. set isVarying(value: boolean);
  58519. /**
  58520. * Gets a boolean indicating that the current connection point is a system value
  58521. */
  58522. get isSystemValue(): boolean;
  58523. /**
  58524. * Gets or sets the current well known value or null if not defined as a system value
  58525. */
  58526. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58527. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58528. /**
  58529. * Gets the current class name
  58530. * @returns the class name
  58531. */
  58532. getClassName(): string;
  58533. /**
  58534. * Animate the input if animationType !== None
  58535. * @param scene defines the rendering scene
  58536. */
  58537. animate(scene: Scene): void;
  58538. private _emitDefine;
  58539. initialize(state: NodeMaterialBuildState): void;
  58540. /**
  58541. * Set the input block to its default value (based on its type)
  58542. */
  58543. setDefaultValue(): void;
  58544. private _emitConstant;
  58545. private _emit;
  58546. /** @hidden */
  58547. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58548. /** @hidden */
  58549. _transmit(effect: Effect, scene: Scene): void;
  58550. protected _buildBlock(state: NodeMaterialBuildState): void;
  58551. protected _dumpPropertiesCode(): string;
  58552. dispose(): void;
  58553. serialize(): any;
  58554. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58555. }
  58556. }
  58557. declare module BABYLON {
  58558. /**
  58559. * Enum used to define the compatibility state between two connection points
  58560. */
  58561. export enum NodeMaterialConnectionPointCompatibilityStates {
  58562. /** Points are compatibles */
  58563. Compatible = 0,
  58564. /** Points are incompatible because of their types */
  58565. TypeIncompatible = 1,
  58566. /** Points are incompatible because of their targets (vertex vs fragment) */
  58567. TargetIncompatible = 2
  58568. }
  58569. /**
  58570. * Defines the direction of a connection point
  58571. */
  58572. export enum NodeMaterialConnectionPointDirection {
  58573. /** Input */
  58574. Input = 0,
  58575. /** Output */
  58576. Output = 1
  58577. }
  58578. /**
  58579. * Defines a connection point for a block
  58580. */
  58581. export class NodeMaterialConnectionPoint {
  58582. /** @hidden */
  58583. _ownerBlock: NodeMaterialBlock;
  58584. /** @hidden */
  58585. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58586. private _endpoints;
  58587. private _associatedVariableName;
  58588. private _direction;
  58589. /** @hidden */
  58590. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58591. /** @hidden */
  58592. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58593. private _type;
  58594. /** @hidden */
  58595. _enforceAssociatedVariableName: boolean;
  58596. /** Gets the direction of the point */
  58597. get direction(): NodeMaterialConnectionPointDirection;
  58598. /**
  58599. * Gets or sets the additional types supported by this connection point
  58600. */
  58601. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58602. /**
  58603. * Gets or sets the additional types excluded by this connection point
  58604. */
  58605. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58606. /**
  58607. * Observable triggered when this point is connected
  58608. */
  58609. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58610. /**
  58611. * Gets or sets the associated variable name in the shader
  58612. */
  58613. get associatedVariableName(): string;
  58614. set associatedVariableName(value: string);
  58615. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58616. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58617. /**
  58618. * Gets or sets the connection point type (default is float)
  58619. */
  58620. get type(): NodeMaterialBlockConnectionPointTypes;
  58621. set type(value: NodeMaterialBlockConnectionPointTypes);
  58622. /**
  58623. * Gets or sets the connection point name
  58624. */
  58625. name: string;
  58626. /**
  58627. * Gets or sets a boolean indicating that this connection point can be omitted
  58628. */
  58629. isOptional: boolean;
  58630. /**
  58631. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58632. */
  58633. define: string;
  58634. /** @hidden */
  58635. _prioritizeVertex: boolean;
  58636. private _target;
  58637. /** Gets or sets the target of that connection point */
  58638. get target(): NodeMaterialBlockTargets;
  58639. set target(value: NodeMaterialBlockTargets);
  58640. /**
  58641. * Gets a boolean indicating that the current point is connected
  58642. */
  58643. get isConnected(): boolean;
  58644. /**
  58645. * Gets a boolean indicating that the current point is connected to an input block
  58646. */
  58647. get isConnectedToInputBlock(): boolean;
  58648. /**
  58649. * Gets a the connected input block (if any)
  58650. */
  58651. get connectInputBlock(): Nullable<InputBlock>;
  58652. /** Get the other side of the connection (if any) */
  58653. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58654. /** Get the block that owns this connection point */
  58655. get ownerBlock(): NodeMaterialBlock;
  58656. /** Get the block connected on the other side of this connection (if any) */
  58657. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58658. /** Get the block connected on the endpoints of this connection (if any) */
  58659. get connectedBlocks(): Array<NodeMaterialBlock>;
  58660. /** Gets the list of connected endpoints */
  58661. get endpoints(): NodeMaterialConnectionPoint[];
  58662. /** Gets a boolean indicating if that output point is connected to at least one input */
  58663. get hasEndpoints(): boolean;
  58664. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58665. get isConnectedInVertexShader(): boolean;
  58666. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58667. get isConnectedInFragmentShader(): boolean;
  58668. /**
  58669. * Creates a new connection point
  58670. * @param name defines the connection point name
  58671. * @param ownerBlock defines the block hosting this connection point
  58672. * @param direction defines the direction of the connection point
  58673. */
  58674. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58675. /**
  58676. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58677. * @returns the class name
  58678. */
  58679. getClassName(): string;
  58680. /**
  58681. * Gets a boolean indicating if the current point can be connected to another point
  58682. * @param connectionPoint defines the other connection point
  58683. * @returns a boolean
  58684. */
  58685. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58686. /**
  58687. * Gets a number indicating if the current point can be connected to another point
  58688. * @param connectionPoint defines the other connection point
  58689. * @returns a number defining the compatibility state
  58690. */
  58691. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58692. /**
  58693. * Connect this point to another connection point
  58694. * @param connectionPoint defines the other connection point
  58695. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58696. * @returns the current connection point
  58697. */
  58698. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58699. /**
  58700. * Disconnect this point from one of his endpoint
  58701. * @param endpoint defines the other connection point
  58702. * @returns the current connection point
  58703. */
  58704. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58705. /**
  58706. * Serializes this point in a JSON representation
  58707. * @returns the serialized point object
  58708. */
  58709. serialize(): any;
  58710. /**
  58711. * Release resources
  58712. */
  58713. dispose(): void;
  58714. }
  58715. }
  58716. declare module BABYLON {
  58717. /**
  58718. * Block used to add support for vertex skinning (bones)
  58719. */
  58720. export class BonesBlock extends NodeMaterialBlock {
  58721. /**
  58722. * Creates a new BonesBlock
  58723. * @param name defines the block name
  58724. */
  58725. constructor(name: string);
  58726. /**
  58727. * Initialize the block and prepare the context for build
  58728. * @param state defines the state that will be used for the build
  58729. */
  58730. initialize(state: NodeMaterialBuildState): void;
  58731. /**
  58732. * Gets the current class name
  58733. * @returns the class name
  58734. */
  58735. getClassName(): string;
  58736. /**
  58737. * Gets the matrix indices input component
  58738. */
  58739. get matricesIndices(): NodeMaterialConnectionPoint;
  58740. /**
  58741. * Gets the matrix weights input component
  58742. */
  58743. get matricesWeights(): NodeMaterialConnectionPoint;
  58744. /**
  58745. * Gets the extra matrix indices input component
  58746. */
  58747. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58748. /**
  58749. * Gets the extra matrix weights input component
  58750. */
  58751. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58752. /**
  58753. * Gets the world input component
  58754. */
  58755. get world(): NodeMaterialConnectionPoint;
  58756. /**
  58757. * Gets the output component
  58758. */
  58759. get output(): NodeMaterialConnectionPoint;
  58760. autoConfigure(material: NodeMaterial): void;
  58761. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58762. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58764. protected _buildBlock(state: NodeMaterialBuildState): this;
  58765. }
  58766. }
  58767. declare module BABYLON {
  58768. /**
  58769. * Block used to add support for instances
  58770. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58771. */
  58772. export class InstancesBlock extends NodeMaterialBlock {
  58773. /**
  58774. * Creates a new InstancesBlock
  58775. * @param name defines the block name
  58776. */
  58777. constructor(name: string);
  58778. /**
  58779. * Gets the current class name
  58780. * @returns the class name
  58781. */
  58782. getClassName(): string;
  58783. /**
  58784. * Gets the first world row input component
  58785. */
  58786. get world0(): NodeMaterialConnectionPoint;
  58787. /**
  58788. * Gets the second world row input component
  58789. */
  58790. get world1(): NodeMaterialConnectionPoint;
  58791. /**
  58792. * Gets the third world row input component
  58793. */
  58794. get world2(): NodeMaterialConnectionPoint;
  58795. /**
  58796. * Gets the forth world row input component
  58797. */
  58798. get world3(): NodeMaterialConnectionPoint;
  58799. /**
  58800. * Gets the world input component
  58801. */
  58802. get world(): NodeMaterialConnectionPoint;
  58803. /**
  58804. * Gets the output component
  58805. */
  58806. get output(): NodeMaterialConnectionPoint;
  58807. /**
  58808. * Gets the isntanceID component
  58809. */
  58810. get instanceID(): NodeMaterialConnectionPoint;
  58811. autoConfigure(material: NodeMaterial): void;
  58812. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58813. protected _buildBlock(state: NodeMaterialBuildState): this;
  58814. }
  58815. }
  58816. declare module BABYLON {
  58817. /**
  58818. * Block used to add morph targets support to vertex shader
  58819. */
  58820. export class MorphTargetsBlock extends NodeMaterialBlock {
  58821. private _repeatableContentAnchor;
  58822. /**
  58823. * Create a new MorphTargetsBlock
  58824. * @param name defines the block name
  58825. */
  58826. constructor(name: string);
  58827. /**
  58828. * Gets the current class name
  58829. * @returns the class name
  58830. */
  58831. getClassName(): string;
  58832. /**
  58833. * Gets the position input component
  58834. */
  58835. get position(): NodeMaterialConnectionPoint;
  58836. /**
  58837. * Gets the normal input component
  58838. */
  58839. get normal(): NodeMaterialConnectionPoint;
  58840. /**
  58841. * Gets the tangent input component
  58842. */
  58843. get tangent(): NodeMaterialConnectionPoint;
  58844. /**
  58845. * Gets the tangent input component
  58846. */
  58847. get uv(): NodeMaterialConnectionPoint;
  58848. /**
  58849. * Gets the position output component
  58850. */
  58851. get positionOutput(): NodeMaterialConnectionPoint;
  58852. /**
  58853. * Gets the normal output component
  58854. */
  58855. get normalOutput(): NodeMaterialConnectionPoint;
  58856. /**
  58857. * Gets the tangent output component
  58858. */
  58859. get tangentOutput(): NodeMaterialConnectionPoint;
  58860. /**
  58861. * Gets the tangent output component
  58862. */
  58863. get uvOutput(): NodeMaterialConnectionPoint;
  58864. initialize(state: NodeMaterialBuildState): void;
  58865. autoConfigure(material: NodeMaterial): void;
  58866. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58867. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58868. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58869. protected _buildBlock(state: NodeMaterialBuildState): this;
  58870. }
  58871. }
  58872. declare module BABYLON {
  58873. /**
  58874. * Block used to get data information from a light
  58875. */
  58876. export class LightInformationBlock extends NodeMaterialBlock {
  58877. private _lightDataUniformName;
  58878. private _lightColorUniformName;
  58879. private _lightTypeDefineName;
  58880. /**
  58881. * Gets or sets the light associated with this block
  58882. */
  58883. light: Nullable<Light>;
  58884. /**
  58885. * Creates a new LightInformationBlock
  58886. * @param name defines the block name
  58887. */
  58888. constructor(name: string);
  58889. /**
  58890. * Gets the current class name
  58891. * @returns the class name
  58892. */
  58893. getClassName(): string;
  58894. /**
  58895. * Gets the world position input component
  58896. */
  58897. get worldPosition(): NodeMaterialConnectionPoint;
  58898. /**
  58899. * Gets the direction output component
  58900. */
  58901. get direction(): NodeMaterialConnectionPoint;
  58902. /**
  58903. * Gets the direction output component
  58904. */
  58905. get color(): NodeMaterialConnectionPoint;
  58906. /**
  58907. * Gets the direction output component
  58908. */
  58909. get intensity(): NodeMaterialConnectionPoint;
  58910. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58912. protected _buildBlock(state: NodeMaterialBuildState): this;
  58913. serialize(): any;
  58914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58915. }
  58916. }
  58917. declare module BABYLON {
  58918. /**
  58919. * Block used to add image processing support to fragment shader
  58920. */
  58921. export class ImageProcessingBlock extends NodeMaterialBlock {
  58922. /**
  58923. * Create a new ImageProcessingBlock
  58924. * @param name defines the block name
  58925. */
  58926. constructor(name: string);
  58927. /**
  58928. * Gets the current class name
  58929. * @returns the class name
  58930. */
  58931. getClassName(): string;
  58932. /**
  58933. * Gets the color input component
  58934. */
  58935. get color(): NodeMaterialConnectionPoint;
  58936. /**
  58937. * Gets the output component
  58938. */
  58939. get output(): NodeMaterialConnectionPoint;
  58940. /**
  58941. * Initialize the block and prepare the context for build
  58942. * @param state defines the state that will be used for the build
  58943. */
  58944. initialize(state: NodeMaterialBuildState): void;
  58945. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58946. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58947. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58948. protected _buildBlock(state: NodeMaterialBuildState): this;
  58949. }
  58950. }
  58951. declare module BABYLON {
  58952. /**
  58953. * Block used to pertub normals based on a normal map
  58954. */
  58955. export class PerturbNormalBlock extends NodeMaterialBlock {
  58956. private _tangentSpaceParameterName;
  58957. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58958. invertX: boolean;
  58959. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58960. invertY: boolean;
  58961. /**
  58962. * Create a new PerturbNormalBlock
  58963. * @param name defines the block name
  58964. */
  58965. constructor(name: string);
  58966. /**
  58967. * Gets the current class name
  58968. * @returns the class name
  58969. */
  58970. getClassName(): string;
  58971. /**
  58972. * Gets the world position input component
  58973. */
  58974. get worldPosition(): NodeMaterialConnectionPoint;
  58975. /**
  58976. * Gets the world normal input component
  58977. */
  58978. get worldNormal(): NodeMaterialConnectionPoint;
  58979. /**
  58980. * Gets the world tangent input component
  58981. */
  58982. get worldTangent(): NodeMaterialConnectionPoint;
  58983. /**
  58984. * Gets the uv input component
  58985. */
  58986. get uv(): NodeMaterialConnectionPoint;
  58987. /**
  58988. * Gets the normal map color input component
  58989. */
  58990. get normalMapColor(): NodeMaterialConnectionPoint;
  58991. /**
  58992. * Gets the strength input component
  58993. */
  58994. get strength(): NodeMaterialConnectionPoint;
  58995. /**
  58996. * Gets the output component
  58997. */
  58998. get output(): NodeMaterialConnectionPoint;
  58999. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59000. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59001. autoConfigure(material: NodeMaterial): void;
  59002. protected _buildBlock(state: NodeMaterialBuildState): this;
  59003. protected _dumpPropertiesCode(): string;
  59004. serialize(): any;
  59005. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59006. }
  59007. }
  59008. declare module BABYLON {
  59009. /**
  59010. * Block used to discard a pixel if a value is smaller than a cutoff
  59011. */
  59012. export class DiscardBlock extends NodeMaterialBlock {
  59013. /**
  59014. * Create a new DiscardBlock
  59015. * @param name defines the block name
  59016. */
  59017. constructor(name: string);
  59018. /**
  59019. * Gets the current class name
  59020. * @returns the class name
  59021. */
  59022. getClassName(): string;
  59023. /**
  59024. * Gets the color input component
  59025. */
  59026. get value(): NodeMaterialConnectionPoint;
  59027. /**
  59028. * Gets the cutoff input component
  59029. */
  59030. get cutoff(): NodeMaterialConnectionPoint;
  59031. protected _buildBlock(state: NodeMaterialBuildState): this;
  59032. }
  59033. }
  59034. declare module BABYLON {
  59035. /**
  59036. * Block used to test if the fragment shader is front facing
  59037. */
  59038. export class FrontFacingBlock extends NodeMaterialBlock {
  59039. /**
  59040. * Creates a new FrontFacingBlock
  59041. * @param name defines the block name
  59042. */
  59043. constructor(name: string);
  59044. /**
  59045. * Gets the current class name
  59046. * @returns the class name
  59047. */
  59048. getClassName(): string;
  59049. /**
  59050. * Gets the output component
  59051. */
  59052. get output(): NodeMaterialConnectionPoint;
  59053. protected _buildBlock(state: NodeMaterialBuildState): this;
  59054. }
  59055. }
  59056. declare module BABYLON {
  59057. /**
  59058. * Block used to get the derivative value on x and y of a given input
  59059. */
  59060. export class DerivativeBlock extends NodeMaterialBlock {
  59061. /**
  59062. * Create a new DerivativeBlock
  59063. * @param name defines the block name
  59064. */
  59065. constructor(name: string);
  59066. /**
  59067. * Gets the current class name
  59068. * @returns the class name
  59069. */
  59070. getClassName(): string;
  59071. /**
  59072. * Gets the input component
  59073. */
  59074. get input(): NodeMaterialConnectionPoint;
  59075. /**
  59076. * Gets the derivative output on x
  59077. */
  59078. get dx(): NodeMaterialConnectionPoint;
  59079. /**
  59080. * Gets the derivative output on y
  59081. */
  59082. get dy(): NodeMaterialConnectionPoint;
  59083. protected _buildBlock(state: NodeMaterialBuildState): this;
  59084. }
  59085. }
  59086. declare module BABYLON {
  59087. /**
  59088. * Block used to add support for scene fog
  59089. */
  59090. export class FogBlock extends NodeMaterialBlock {
  59091. private _fogDistanceName;
  59092. private _fogParameters;
  59093. /**
  59094. * Create a new FogBlock
  59095. * @param name defines the block name
  59096. */
  59097. constructor(name: string);
  59098. /**
  59099. * Gets the current class name
  59100. * @returns the class name
  59101. */
  59102. getClassName(): string;
  59103. /**
  59104. * Gets the world position input component
  59105. */
  59106. get worldPosition(): NodeMaterialConnectionPoint;
  59107. /**
  59108. * Gets the view input component
  59109. */
  59110. get view(): NodeMaterialConnectionPoint;
  59111. /**
  59112. * Gets the color input component
  59113. */
  59114. get input(): NodeMaterialConnectionPoint;
  59115. /**
  59116. * Gets the fog color input component
  59117. */
  59118. get fogColor(): NodeMaterialConnectionPoint;
  59119. /**
  59120. * Gets the output component
  59121. */
  59122. get output(): NodeMaterialConnectionPoint;
  59123. autoConfigure(material: NodeMaterial): void;
  59124. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59125. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59126. protected _buildBlock(state: NodeMaterialBuildState): this;
  59127. }
  59128. }
  59129. declare module BABYLON {
  59130. /**
  59131. * Block used to add light in the fragment shader
  59132. */
  59133. export class LightBlock extends NodeMaterialBlock {
  59134. private _lightId;
  59135. /**
  59136. * Gets or sets the light associated with this block
  59137. */
  59138. light: Nullable<Light>;
  59139. /**
  59140. * Create a new LightBlock
  59141. * @param name defines the block name
  59142. */
  59143. constructor(name: string);
  59144. /**
  59145. * Gets the current class name
  59146. * @returns the class name
  59147. */
  59148. getClassName(): string;
  59149. /**
  59150. * Gets the world position input component
  59151. */
  59152. get worldPosition(): NodeMaterialConnectionPoint;
  59153. /**
  59154. * Gets the world normal input component
  59155. */
  59156. get worldNormal(): NodeMaterialConnectionPoint;
  59157. /**
  59158. * Gets the camera (or eye) position component
  59159. */
  59160. get cameraPosition(): NodeMaterialConnectionPoint;
  59161. /**
  59162. * Gets the glossiness component
  59163. */
  59164. get glossiness(): NodeMaterialConnectionPoint;
  59165. /**
  59166. * Gets the glossinness power component
  59167. */
  59168. get glossPower(): NodeMaterialConnectionPoint;
  59169. /**
  59170. * Gets the diffuse color component
  59171. */
  59172. get diffuseColor(): NodeMaterialConnectionPoint;
  59173. /**
  59174. * Gets the specular color component
  59175. */
  59176. get specularColor(): NodeMaterialConnectionPoint;
  59177. /**
  59178. * Gets the diffuse output component
  59179. */
  59180. get diffuseOutput(): NodeMaterialConnectionPoint;
  59181. /**
  59182. * Gets the specular output component
  59183. */
  59184. get specularOutput(): NodeMaterialConnectionPoint;
  59185. /**
  59186. * Gets the shadow output component
  59187. */
  59188. get shadow(): NodeMaterialConnectionPoint;
  59189. autoConfigure(material: NodeMaterial): void;
  59190. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59191. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59192. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59193. private _injectVertexCode;
  59194. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59195. serialize(): any;
  59196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59197. }
  59198. }
  59199. declare module BABYLON {
  59200. /**
  59201. * Block used to multiply 2 values
  59202. */
  59203. export class MultiplyBlock extends NodeMaterialBlock {
  59204. /**
  59205. * Creates a new MultiplyBlock
  59206. * @param name defines the block name
  59207. */
  59208. constructor(name: string);
  59209. /**
  59210. * Gets the current class name
  59211. * @returns the class name
  59212. */
  59213. getClassName(): string;
  59214. /**
  59215. * Gets the left operand input component
  59216. */
  59217. get left(): NodeMaterialConnectionPoint;
  59218. /**
  59219. * Gets the right operand input component
  59220. */
  59221. get right(): NodeMaterialConnectionPoint;
  59222. /**
  59223. * Gets the output component
  59224. */
  59225. get output(): NodeMaterialConnectionPoint;
  59226. protected _buildBlock(state: NodeMaterialBuildState): this;
  59227. }
  59228. }
  59229. declare module BABYLON {
  59230. /**
  59231. * Block used to add 2 vectors
  59232. */
  59233. export class AddBlock extends NodeMaterialBlock {
  59234. /**
  59235. * Creates a new AddBlock
  59236. * @param name defines the block name
  59237. */
  59238. constructor(name: string);
  59239. /**
  59240. * Gets the current class name
  59241. * @returns the class name
  59242. */
  59243. getClassName(): string;
  59244. /**
  59245. * Gets the left operand input component
  59246. */
  59247. get left(): NodeMaterialConnectionPoint;
  59248. /**
  59249. * Gets the right operand input component
  59250. */
  59251. get right(): NodeMaterialConnectionPoint;
  59252. /**
  59253. * Gets the output component
  59254. */
  59255. get output(): NodeMaterialConnectionPoint;
  59256. protected _buildBlock(state: NodeMaterialBuildState): this;
  59257. }
  59258. }
  59259. declare module BABYLON {
  59260. /**
  59261. * Block used to scale a vector by a float
  59262. */
  59263. export class ScaleBlock extends NodeMaterialBlock {
  59264. /**
  59265. * Creates a new ScaleBlock
  59266. * @param name defines the block name
  59267. */
  59268. constructor(name: string);
  59269. /**
  59270. * Gets the current class name
  59271. * @returns the class name
  59272. */
  59273. getClassName(): string;
  59274. /**
  59275. * Gets the input component
  59276. */
  59277. get input(): NodeMaterialConnectionPoint;
  59278. /**
  59279. * Gets the factor input component
  59280. */
  59281. get factor(): NodeMaterialConnectionPoint;
  59282. /**
  59283. * Gets the output component
  59284. */
  59285. get output(): NodeMaterialConnectionPoint;
  59286. protected _buildBlock(state: NodeMaterialBuildState): this;
  59287. }
  59288. }
  59289. declare module BABYLON {
  59290. /**
  59291. * Block used to clamp a float
  59292. */
  59293. export class ClampBlock extends NodeMaterialBlock {
  59294. /** Gets or sets the minimum range */
  59295. minimum: number;
  59296. /** Gets or sets the maximum range */
  59297. maximum: number;
  59298. /**
  59299. * Creates a new ClampBlock
  59300. * @param name defines the block name
  59301. */
  59302. constructor(name: string);
  59303. /**
  59304. * Gets the current class name
  59305. * @returns the class name
  59306. */
  59307. getClassName(): string;
  59308. /**
  59309. * Gets the value input component
  59310. */
  59311. get value(): NodeMaterialConnectionPoint;
  59312. /**
  59313. * Gets the output component
  59314. */
  59315. get output(): NodeMaterialConnectionPoint;
  59316. protected _buildBlock(state: NodeMaterialBuildState): this;
  59317. protected _dumpPropertiesCode(): string;
  59318. serialize(): any;
  59319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59320. }
  59321. }
  59322. declare module BABYLON {
  59323. /**
  59324. * Block used to apply a cross product between 2 vectors
  59325. */
  59326. export class CrossBlock extends NodeMaterialBlock {
  59327. /**
  59328. * Creates a new CrossBlock
  59329. * @param name defines the block name
  59330. */
  59331. constructor(name: string);
  59332. /**
  59333. * Gets the current class name
  59334. * @returns the class name
  59335. */
  59336. getClassName(): string;
  59337. /**
  59338. * Gets the left operand input component
  59339. */
  59340. get left(): NodeMaterialConnectionPoint;
  59341. /**
  59342. * Gets the right operand input component
  59343. */
  59344. get right(): NodeMaterialConnectionPoint;
  59345. /**
  59346. * Gets the output component
  59347. */
  59348. get output(): NodeMaterialConnectionPoint;
  59349. protected _buildBlock(state: NodeMaterialBuildState): this;
  59350. }
  59351. }
  59352. declare module BABYLON {
  59353. /**
  59354. * Block used to apply a dot product between 2 vectors
  59355. */
  59356. export class DotBlock extends NodeMaterialBlock {
  59357. /**
  59358. * Creates a new DotBlock
  59359. * @param name defines the block name
  59360. */
  59361. constructor(name: string);
  59362. /**
  59363. * Gets the current class name
  59364. * @returns the class name
  59365. */
  59366. getClassName(): string;
  59367. /**
  59368. * Gets the left operand input component
  59369. */
  59370. get left(): NodeMaterialConnectionPoint;
  59371. /**
  59372. * Gets the right operand input component
  59373. */
  59374. get right(): NodeMaterialConnectionPoint;
  59375. /**
  59376. * Gets the output component
  59377. */
  59378. get output(): NodeMaterialConnectionPoint;
  59379. protected _buildBlock(state: NodeMaterialBuildState): this;
  59380. }
  59381. }
  59382. declare module BABYLON {
  59383. /**
  59384. * Block used to remap a float from a range to a new one
  59385. */
  59386. export class RemapBlock extends NodeMaterialBlock {
  59387. /**
  59388. * Gets or sets the source range
  59389. */
  59390. sourceRange: Vector2;
  59391. /**
  59392. * Gets or sets the target range
  59393. */
  59394. targetRange: Vector2;
  59395. /**
  59396. * Creates a new RemapBlock
  59397. * @param name defines the block name
  59398. */
  59399. constructor(name: string);
  59400. /**
  59401. * Gets the current class name
  59402. * @returns the class name
  59403. */
  59404. getClassName(): string;
  59405. /**
  59406. * Gets the input component
  59407. */
  59408. get input(): NodeMaterialConnectionPoint;
  59409. /**
  59410. * Gets the source min input component
  59411. */
  59412. get sourceMin(): NodeMaterialConnectionPoint;
  59413. /**
  59414. * Gets the source max input component
  59415. */
  59416. get sourceMax(): NodeMaterialConnectionPoint;
  59417. /**
  59418. * Gets the target min input component
  59419. */
  59420. get targetMin(): NodeMaterialConnectionPoint;
  59421. /**
  59422. * Gets the target max input component
  59423. */
  59424. get targetMax(): NodeMaterialConnectionPoint;
  59425. /**
  59426. * Gets the output component
  59427. */
  59428. get output(): NodeMaterialConnectionPoint;
  59429. protected _buildBlock(state: NodeMaterialBuildState): this;
  59430. protected _dumpPropertiesCode(): string;
  59431. serialize(): any;
  59432. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59433. }
  59434. }
  59435. declare module BABYLON {
  59436. /**
  59437. * Block used to normalize a vector
  59438. */
  59439. export class NormalizeBlock extends NodeMaterialBlock {
  59440. /**
  59441. * Creates a new NormalizeBlock
  59442. * @param name defines the block name
  59443. */
  59444. constructor(name: string);
  59445. /**
  59446. * Gets the current class name
  59447. * @returns the class name
  59448. */
  59449. getClassName(): string;
  59450. /**
  59451. * Gets the input component
  59452. */
  59453. get input(): NodeMaterialConnectionPoint;
  59454. /**
  59455. * Gets the output component
  59456. */
  59457. get output(): NodeMaterialConnectionPoint;
  59458. protected _buildBlock(state: NodeMaterialBuildState): this;
  59459. }
  59460. }
  59461. declare module BABYLON {
  59462. /**
  59463. * Operations supported by the Trigonometry block
  59464. */
  59465. export enum TrigonometryBlockOperations {
  59466. /** Cos */
  59467. Cos = 0,
  59468. /** Sin */
  59469. Sin = 1,
  59470. /** Abs */
  59471. Abs = 2,
  59472. /** Exp */
  59473. Exp = 3,
  59474. /** Exp2 */
  59475. Exp2 = 4,
  59476. /** Round */
  59477. Round = 5,
  59478. /** Floor */
  59479. Floor = 6,
  59480. /** Ceiling */
  59481. Ceiling = 7,
  59482. /** Square root */
  59483. Sqrt = 8,
  59484. /** Log */
  59485. Log = 9,
  59486. /** Tangent */
  59487. Tan = 10,
  59488. /** Arc tangent */
  59489. ArcTan = 11,
  59490. /** Arc cosinus */
  59491. ArcCos = 12,
  59492. /** Arc sinus */
  59493. ArcSin = 13,
  59494. /** Fraction */
  59495. Fract = 14,
  59496. /** Sign */
  59497. Sign = 15,
  59498. /** To radians (from degrees) */
  59499. Radians = 16,
  59500. /** To degrees (from radians) */
  59501. Degrees = 17
  59502. }
  59503. /**
  59504. * Block used to apply trigonometry operation to floats
  59505. */
  59506. export class TrigonometryBlock extends NodeMaterialBlock {
  59507. /**
  59508. * Gets or sets the operation applied by the block
  59509. */
  59510. operation: TrigonometryBlockOperations;
  59511. /**
  59512. * Creates a new TrigonometryBlock
  59513. * @param name defines the block name
  59514. */
  59515. constructor(name: string);
  59516. /**
  59517. * Gets the current class name
  59518. * @returns the class name
  59519. */
  59520. getClassName(): string;
  59521. /**
  59522. * Gets the input component
  59523. */
  59524. get input(): NodeMaterialConnectionPoint;
  59525. /**
  59526. * Gets the output component
  59527. */
  59528. get output(): NodeMaterialConnectionPoint;
  59529. protected _buildBlock(state: NodeMaterialBuildState): this;
  59530. serialize(): any;
  59531. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59532. protected _dumpPropertiesCode(): string;
  59533. }
  59534. }
  59535. declare module BABYLON {
  59536. /**
  59537. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59538. */
  59539. export class ColorMergerBlock extends NodeMaterialBlock {
  59540. /**
  59541. * Create a new ColorMergerBlock
  59542. * @param name defines the block name
  59543. */
  59544. constructor(name: string);
  59545. /**
  59546. * Gets the current class name
  59547. * @returns the class name
  59548. */
  59549. getClassName(): string;
  59550. /**
  59551. * Gets the rgb component (input)
  59552. */
  59553. get rgbIn(): NodeMaterialConnectionPoint;
  59554. /**
  59555. * Gets the r component (input)
  59556. */
  59557. get r(): NodeMaterialConnectionPoint;
  59558. /**
  59559. * Gets the g component (input)
  59560. */
  59561. get g(): NodeMaterialConnectionPoint;
  59562. /**
  59563. * Gets the b component (input)
  59564. */
  59565. get b(): NodeMaterialConnectionPoint;
  59566. /**
  59567. * Gets the a component (input)
  59568. */
  59569. get a(): NodeMaterialConnectionPoint;
  59570. /**
  59571. * Gets the rgba component (output)
  59572. */
  59573. get rgba(): NodeMaterialConnectionPoint;
  59574. /**
  59575. * Gets the rgb component (output)
  59576. */
  59577. get rgbOut(): NodeMaterialConnectionPoint;
  59578. /**
  59579. * Gets the rgb component (output)
  59580. * @deprecated Please use rgbOut instead.
  59581. */
  59582. get rgb(): NodeMaterialConnectionPoint;
  59583. protected _buildBlock(state: NodeMaterialBuildState): this;
  59584. }
  59585. }
  59586. declare module BABYLON {
  59587. /**
  59588. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59589. */
  59590. export class VectorMergerBlock extends NodeMaterialBlock {
  59591. /**
  59592. * Create a new VectorMergerBlock
  59593. * @param name defines the block name
  59594. */
  59595. constructor(name: string);
  59596. /**
  59597. * Gets the current class name
  59598. * @returns the class name
  59599. */
  59600. getClassName(): string;
  59601. /**
  59602. * Gets the xyz component (input)
  59603. */
  59604. get xyzIn(): NodeMaterialConnectionPoint;
  59605. /**
  59606. * Gets the xy component (input)
  59607. */
  59608. get xyIn(): NodeMaterialConnectionPoint;
  59609. /**
  59610. * Gets the x component (input)
  59611. */
  59612. get x(): NodeMaterialConnectionPoint;
  59613. /**
  59614. * Gets the y component (input)
  59615. */
  59616. get y(): NodeMaterialConnectionPoint;
  59617. /**
  59618. * Gets the z component (input)
  59619. */
  59620. get z(): NodeMaterialConnectionPoint;
  59621. /**
  59622. * Gets the w component (input)
  59623. */
  59624. get w(): NodeMaterialConnectionPoint;
  59625. /**
  59626. * Gets the xyzw component (output)
  59627. */
  59628. get xyzw(): NodeMaterialConnectionPoint;
  59629. /**
  59630. * Gets the xyz component (output)
  59631. */
  59632. get xyzOut(): NodeMaterialConnectionPoint;
  59633. /**
  59634. * Gets the xy component (output)
  59635. */
  59636. get xyOut(): NodeMaterialConnectionPoint;
  59637. /**
  59638. * Gets the xy component (output)
  59639. * @deprecated Please use xyOut instead.
  59640. */
  59641. get xy(): NodeMaterialConnectionPoint;
  59642. /**
  59643. * Gets the xyz component (output)
  59644. * @deprecated Please use xyzOut instead.
  59645. */
  59646. get xyz(): NodeMaterialConnectionPoint;
  59647. protected _buildBlock(state: NodeMaterialBuildState): this;
  59648. }
  59649. }
  59650. declare module BABYLON {
  59651. /**
  59652. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59653. */
  59654. export class ColorSplitterBlock extends NodeMaterialBlock {
  59655. /**
  59656. * Create a new ColorSplitterBlock
  59657. * @param name defines the block name
  59658. */
  59659. constructor(name: string);
  59660. /**
  59661. * Gets the current class name
  59662. * @returns the class name
  59663. */
  59664. getClassName(): string;
  59665. /**
  59666. * Gets the rgba component (input)
  59667. */
  59668. get rgba(): NodeMaterialConnectionPoint;
  59669. /**
  59670. * Gets the rgb component (input)
  59671. */
  59672. get rgbIn(): NodeMaterialConnectionPoint;
  59673. /**
  59674. * Gets the rgb component (output)
  59675. */
  59676. get rgbOut(): NodeMaterialConnectionPoint;
  59677. /**
  59678. * Gets the r component (output)
  59679. */
  59680. get r(): NodeMaterialConnectionPoint;
  59681. /**
  59682. * Gets the g component (output)
  59683. */
  59684. get g(): NodeMaterialConnectionPoint;
  59685. /**
  59686. * Gets the b component (output)
  59687. */
  59688. get b(): NodeMaterialConnectionPoint;
  59689. /**
  59690. * Gets the a component (output)
  59691. */
  59692. get a(): NodeMaterialConnectionPoint;
  59693. protected _inputRename(name: string): string;
  59694. protected _outputRename(name: string): string;
  59695. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59696. }
  59697. }
  59698. declare module BABYLON {
  59699. /**
  59700. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59701. */
  59702. export class VectorSplitterBlock extends NodeMaterialBlock {
  59703. /**
  59704. * Create a new VectorSplitterBlock
  59705. * @param name defines the block name
  59706. */
  59707. constructor(name: string);
  59708. /**
  59709. * Gets the current class name
  59710. * @returns the class name
  59711. */
  59712. getClassName(): string;
  59713. /**
  59714. * Gets the xyzw component (input)
  59715. */
  59716. get xyzw(): NodeMaterialConnectionPoint;
  59717. /**
  59718. * Gets the xyz component (input)
  59719. */
  59720. get xyzIn(): NodeMaterialConnectionPoint;
  59721. /**
  59722. * Gets the xy component (input)
  59723. */
  59724. get xyIn(): NodeMaterialConnectionPoint;
  59725. /**
  59726. * Gets the xyz component (output)
  59727. */
  59728. get xyzOut(): NodeMaterialConnectionPoint;
  59729. /**
  59730. * Gets the xy component (output)
  59731. */
  59732. get xyOut(): NodeMaterialConnectionPoint;
  59733. /**
  59734. * Gets the x component (output)
  59735. */
  59736. get x(): NodeMaterialConnectionPoint;
  59737. /**
  59738. * Gets the y component (output)
  59739. */
  59740. get y(): NodeMaterialConnectionPoint;
  59741. /**
  59742. * Gets the z component (output)
  59743. */
  59744. get z(): NodeMaterialConnectionPoint;
  59745. /**
  59746. * Gets the w component (output)
  59747. */
  59748. get w(): NodeMaterialConnectionPoint;
  59749. protected _inputRename(name: string): string;
  59750. protected _outputRename(name: string): string;
  59751. protected _buildBlock(state: NodeMaterialBuildState): this;
  59752. }
  59753. }
  59754. declare module BABYLON {
  59755. /**
  59756. * Block used to lerp between 2 values
  59757. */
  59758. export class LerpBlock extends NodeMaterialBlock {
  59759. /**
  59760. * Creates a new LerpBlock
  59761. * @param name defines the block name
  59762. */
  59763. constructor(name: string);
  59764. /**
  59765. * Gets the current class name
  59766. * @returns the class name
  59767. */
  59768. getClassName(): string;
  59769. /**
  59770. * Gets the left operand input component
  59771. */
  59772. get left(): NodeMaterialConnectionPoint;
  59773. /**
  59774. * Gets the right operand input component
  59775. */
  59776. get right(): NodeMaterialConnectionPoint;
  59777. /**
  59778. * Gets the gradient operand input component
  59779. */
  59780. get gradient(): NodeMaterialConnectionPoint;
  59781. /**
  59782. * Gets the output component
  59783. */
  59784. get output(): NodeMaterialConnectionPoint;
  59785. protected _buildBlock(state: NodeMaterialBuildState): this;
  59786. }
  59787. }
  59788. declare module BABYLON {
  59789. /**
  59790. * Block used to divide 2 vectors
  59791. */
  59792. export class DivideBlock extends NodeMaterialBlock {
  59793. /**
  59794. * Creates a new DivideBlock
  59795. * @param name defines the block name
  59796. */
  59797. constructor(name: string);
  59798. /**
  59799. * Gets the current class name
  59800. * @returns the class name
  59801. */
  59802. getClassName(): string;
  59803. /**
  59804. * Gets the left operand input component
  59805. */
  59806. get left(): NodeMaterialConnectionPoint;
  59807. /**
  59808. * Gets the right operand input component
  59809. */
  59810. get right(): NodeMaterialConnectionPoint;
  59811. /**
  59812. * Gets the output component
  59813. */
  59814. get output(): NodeMaterialConnectionPoint;
  59815. protected _buildBlock(state: NodeMaterialBuildState): this;
  59816. }
  59817. }
  59818. declare module BABYLON {
  59819. /**
  59820. * Block used to subtract 2 vectors
  59821. */
  59822. export class SubtractBlock extends NodeMaterialBlock {
  59823. /**
  59824. * Creates a new SubtractBlock
  59825. * @param name defines the block name
  59826. */
  59827. constructor(name: string);
  59828. /**
  59829. * Gets the current class name
  59830. * @returns the class name
  59831. */
  59832. getClassName(): string;
  59833. /**
  59834. * Gets the left operand input component
  59835. */
  59836. get left(): NodeMaterialConnectionPoint;
  59837. /**
  59838. * Gets the right operand input component
  59839. */
  59840. get right(): NodeMaterialConnectionPoint;
  59841. /**
  59842. * Gets the output component
  59843. */
  59844. get output(): NodeMaterialConnectionPoint;
  59845. protected _buildBlock(state: NodeMaterialBuildState): this;
  59846. }
  59847. }
  59848. declare module BABYLON {
  59849. /**
  59850. * Block used to step a value
  59851. */
  59852. export class StepBlock extends NodeMaterialBlock {
  59853. /**
  59854. * Creates a new StepBlock
  59855. * @param name defines the block name
  59856. */
  59857. constructor(name: string);
  59858. /**
  59859. * Gets the current class name
  59860. * @returns the class name
  59861. */
  59862. getClassName(): string;
  59863. /**
  59864. * Gets the value operand input component
  59865. */
  59866. get value(): NodeMaterialConnectionPoint;
  59867. /**
  59868. * Gets the edge operand input component
  59869. */
  59870. get edge(): NodeMaterialConnectionPoint;
  59871. /**
  59872. * Gets the output component
  59873. */
  59874. get output(): NodeMaterialConnectionPoint;
  59875. protected _buildBlock(state: NodeMaterialBuildState): this;
  59876. }
  59877. }
  59878. declare module BABYLON {
  59879. /**
  59880. * Block used to get the opposite (1 - x) of a value
  59881. */
  59882. export class OneMinusBlock extends NodeMaterialBlock {
  59883. /**
  59884. * Creates a new OneMinusBlock
  59885. * @param name defines the block name
  59886. */
  59887. constructor(name: string);
  59888. /**
  59889. * Gets the current class name
  59890. * @returns the class name
  59891. */
  59892. getClassName(): string;
  59893. /**
  59894. * Gets the input component
  59895. */
  59896. get input(): NodeMaterialConnectionPoint;
  59897. /**
  59898. * Gets the output component
  59899. */
  59900. get output(): NodeMaterialConnectionPoint;
  59901. protected _buildBlock(state: NodeMaterialBuildState): this;
  59902. }
  59903. }
  59904. declare module BABYLON {
  59905. /**
  59906. * Block used to get the view direction
  59907. */
  59908. export class ViewDirectionBlock extends NodeMaterialBlock {
  59909. /**
  59910. * Creates a new ViewDirectionBlock
  59911. * @param name defines the block name
  59912. */
  59913. constructor(name: string);
  59914. /**
  59915. * Gets the current class name
  59916. * @returns the class name
  59917. */
  59918. getClassName(): string;
  59919. /**
  59920. * Gets the world position component
  59921. */
  59922. get worldPosition(): NodeMaterialConnectionPoint;
  59923. /**
  59924. * Gets the camera position component
  59925. */
  59926. get cameraPosition(): NodeMaterialConnectionPoint;
  59927. /**
  59928. * Gets the output component
  59929. */
  59930. get output(): NodeMaterialConnectionPoint;
  59931. autoConfigure(material: NodeMaterial): void;
  59932. protected _buildBlock(state: NodeMaterialBuildState): this;
  59933. }
  59934. }
  59935. declare module BABYLON {
  59936. /**
  59937. * Block used to compute fresnel value
  59938. */
  59939. export class FresnelBlock extends NodeMaterialBlock {
  59940. /**
  59941. * Create a new FresnelBlock
  59942. * @param name defines the block name
  59943. */
  59944. constructor(name: string);
  59945. /**
  59946. * Gets the current class name
  59947. * @returns the class name
  59948. */
  59949. getClassName(): string;
  59950. /**
  59951. * Gets the world normal input component
  59952. */
  59953. get worldNormal(): NodeMaterialConnectionPoint;
  59954. /**
  59955. * Gets the view direction input component
  59956. */
  59957. get viewDirection(): NodeMaterialConnectionPoint;
  59958. /**
  59959. * Gets the bias input component
  59960. */
  59961. get bias(): NodeMaterialConnectionPoint;
  59962. /**
  59963. * Gets the camera (or eye) position component
  59964. */
  59965. get power(): NodeMaterialConnectionPoint;
  59966. /**
  59967. * Gets the fresnel output component
  59968. */
  59969. get fresnel(): NodeMaterialConnectionPoint;
  59970. autoConfigure(material: NodeMaterial): void;
  59971. protected _buildBlock(state: NodeMaterialBuildState): this;
  59972. }
  59973. }
  59974. declare module BABYLON {
  59975. /**
  59976. * Block used to get the max of 2 values
  59977. */
  59978. export class MaxBlock extends NodeMaterialBlock {
  59979. /**
  59980. * Creates a new MaxBlock
  59981. * @param name defines the block name
  59982. */
  59983. constructor(name: string);
  59984. /**
  59985. * Gets the current class name
  59986. * @returns the class name
  59987. */
  59988. getClassName(): string;
  59989. /**
  59990. * Gets the left operand input component
  59991. */
  59992. get left(): NodeMaterialConnectionPoint;
  59993. /**
  59994. * Gets the right operand input component
  59995. */
  59996. get right(): NodeMaterialConnectionPoint;
  59997. /**
  59998. * Gets the output component
  59999. */
  60000. get output(): NodeMaterialConnectionPoint;
  60001. protected _buildBlock(state: NodeMaterialBuildState): this;
  60002. }
  60003. }
  60004. declare module BABYLON {
  60005. /**
  60006. * Block used to get the min of 2 values
  60007. */
  60008. export class MinBlock extends NodeMaterialBlock {
  60009. /**
  60010. * Creates a new MinBlock
  60011. * @param name defines the block name
  60012. */
  60013. constructor(name: string);
  60014. /**
  60015. * Gets the current class name
  60016. * @returns the class name
  60017. */
  60018. getClassName(): string;
  60019. /**
  60020. * Gets the left operand input component
  60021. */
  60022. get left(): NodeMaterialConnectionPoint;
  60023. /**
  60024. * Gets the right operand input component
  60025. */
  60026. get right(): NodeMaterialConnectionPoint;
  60027. /**
  60028. * Gets the output component
  60029. */
  60030. get output(): NodeMaterialConnectionPoint;
  60031. protected _buildBlock(state: NodeMaterialBuildState): this;
  60032. }
  60033. }
  60034. declare module BABYLON {
  60035. /**
  60036. * Block used to get the distance between 2 values
  60037. */
  60038. export class DistanceBlock extends NodeMaterialBlock {
  60039. /**
  60040. * Creates a new DistanceBlock
  60041. * @param name defines the block name
  60042. */
  60043. constructor(name: string);
  60044. /**
  60045. * Gets the current class name
  60046. * @returns the class name
  60047. */
  60048. getClassName(): string;
  60049. /**
  60050. * Gets the left operand input component
  60051. */
  60052. get left(): NodeMaterialConnectionPoint;
  60053. /**
  60054. * Gets the right operand input component
  60055. */
  60056. get right(): NodeMaterialConnectionPoint;
  60057. /**
  60058. * Gets the output component
  60059. */
  60060. get output(): NodeMaterialConnectionPoint;
  60061. protected _buildBlock(state: NodeMaterialBuildState): this;
  60062. }
  60063. }
  60064. declare module BABYLON {
  60065. /**
  60066. * Block used to get the length of a vector
  60067. */
  60068. export class LengthBlock extends NodeMaterialBlock {
  60069. /**
  60070. * Creates a new LengthBlock
  60071. * @param name defines the block name
  60072. */
  60073. constructor(name: string);
  60074. /**
  60075. * Gets the current class name
  60076. * @returns the class name
  60077. */
  60078. getClassName(): string;
  60079. /**
  60080. * Gets the value input component
  60081. */
  60082. get value(): NodeMaterialConnectionPoint;
  60083. /**
  60084. * Gets the output component
  60085. */
  60086. get output(): NodeMaterialConnectionPoint;
  60087. protected _buildBlock(state: NodeMaterialBuildState): this;
  60088. }
  60089. }
  60090. declare module BABYLON {
  60091. /**
  60092. * Block used to get negative version of a value (i.e. x * -1)
  60093. */
  60094. export class NegateBlock extends NodeMaterialBlock {
  60095. /**
  60096. * Creates a new NegateBlock
  60097. * @param name defines the block name
  60098. */
  60099. constructor(name: string);
  60100. /**
  60101. * Gets the current class name
  60102. * @returns the class name
  60103. */
  60104. getClassName(): string;
  60105. /**
  60106. * Gets the value input component
  60107. */
  60108. get value(): NodeMaterialConnectionPoint;
  60109. /**
  60110. * Gets the output component
  60111. */
  60112. get output(): NodeMaterialConnectionPoint;
  60113. protected _buildBlock(state: NodeMaterialBuildState): this;
  60114. }
  60115. }
  60116. declare module BABYLON {
  60117. /**
  60118. * Block used to get the value of the first parameter raised to the power of the second
  60119. */
  60120. export class PowBlock extends NodeMaterialBlock {
  60121. /**
  60122. * Creates a new PowBlock
  60123. * @param name defines the block name
  60124. */
  60125. constructor(name: string);
  60126. /**
  60127. * Gets the current class name
  60128. * @returns the class name
  60129. */
  60130. getClassName(): string;
  60131. /**
  60132. * Gets the value operand input component
  60133. */
  60134. get value(): NodeMaterialConnectionPoint;
  60135. /**
  60136. * Gets the power operand input component
  60137. */
  60138. get power(): NodeMaterialConnectionPoint;
  60139. /**
  60140. * Gets the output component
  60141. */
  60142. get output(): NodeMaterialConnectionPoint;
  60143. protected _buildBlock(state: NodeMaterialBuildState): this;
  60144. }
  60145. }
  60146. declare module BABYLON {
  60147. /**
  60148. * Block used to get a random number
  60149. */
  60150. export class RandomNumberBlock extends NodeMaterialBlock {
  60151. /**
  60152. * Creates a new RandomNumberBlock
  60153. * @param name defines the block name
  60154. */
  60155. constructor(name: string);
  60156. /**
  60157. * Gets the current class name
  60158. * @returns the class name
  60159. */
  60160. getClassName(): string;
  60161. /**
  60162. * Gets the seed input component
  60163. */
  60164. get seed(): NodeMaterialConnectionPoint;
  60165. /**
  60166. * Gets the output component
  60167. */
  60168. get output(): NodeMaterialConnectionPoint;
  60169. protected _buildBlock(state: NodeMaterialBuildState): this;
  60170. }
  60171. }
  60172. declare module BABYLON {
  60173. /**
  60174. * Block used to compute arc tangent of 2 values
  60175. */
  60176. export class ArcTan2Block extends NodeMaterialBlock {
  60177. /**
  60178. * Creates a new ArcTan2Block
  60179. * @param name defines the block name
  60180. */
  60181. constructor(name: string);
  60182. /**
  60183. * Gets the current class name
  60184. * @returns the class name
  60185. */
  60186. getClassName(): string;
  60187. /**
  60188. * Gets the x operand input component
  60189. */
  60190. get x(): NodeMaterialConnectionPoint;
  60191. /**
  60192. * Gets the y operand input component
  60193. */
  60194. get y(): NodeMaterialConnectionPoint;
  60195. /**
  60196. * Gets the output component
  60197. */
  60198. get output(): NodeMaterialConnectionPoint;
  60199. protected _buildBlock(state: NodeMaterialBuildState): this;
  60200. }
  60201. }
  60202. declare module BABYLON {
  60203. /**
  60204. * Block used to smooth step a value
  60205. */
  60206. export class SmoothStepBlock extends NodeMaterialBlock {
  60207. /**
  60208. * Creates a new SmoothStepBlock
  60209. * @param name defines the block name
  60210. */
  60211. constructor(name: string);
  60212. /**
  60213. * Gets the current class name
  60214. * @returns the class name
  60215. */
  60216. getClassName(): string;
  60217. /**
  60218. * Gets the value operand input component
  60219. */
  60220. get value(): NodeMaterialConnectionPoint;
  60221. /**
  60222. * Gets the first edge operand input component
  60223. */
  60224. get edge0(): NodeMaterialConnectionPoint;
  60225. /**
  60226. * Gets the second edge operand input component
  60227. */
  60228. get edge1(): NodeMaterialConnectionPoint;
  60229. /**
  60230. * Gets the output component
  60231. */
  60232. get output(): NodeMaterialConnectionPoint;
  60233. protected _buildBlock(state: NodeMaterialBuildState): this;
  60234. }
  60235. }
  60236. declare module BABYLON {
  60237. /**
  60238. * Block used to get the reciprocal (1 / x) of a value
  60239. */
  60240. export class ReciprocalBlock extends NodeMaterialBlock {
  60241. /**
  60242. * Creates a new ReciprocalBlock
  60243. * @param name defines the block name
  60244. */
  60245. constructor(name: string);
  60246. /**
  60247. * Gets the current class name
  60248. * @returns the class name
  60249. */
  60250. getClassName(): string;
  60251. /**
  60252. * Gets the input component
  60253. */
  60254. get input(): NodeMaterialConnectionPoint;
  60255. /**
  60256. * Gets the output component
  60257. */
  60258. get output(): NodeMaterialConnectionPoint;
  60259. protected _buildBlock(state: NodeMaterialBuildState): this;
  60260. }
  60261. }
  60262. declare module BABYLON {
  60263. /**
  60264. * Block used to replace a color by another one
  60265. */
  60266. export class ReplaceColorBlock extends NodeMaterialBlock {
  60267. /**
  60268. * Creates a new ReplaceColorBlock
  60269. * @param name defines the block name
  60270. */
  60271. constructor(name: string);
  60272. /**
  60273. * Gets the current class name
  60274. * @returns the class name
  60275. */
  60276. getClassName(): string;
  60277. /**
  60278. * Gets the value input component
  60279. */
  60280. get value(): NodeMaterialConnectionPoint;
  60281. /**
  60282. * Gets the reference input component
  60283. */
  60284. get reference(): NodeMaterialConnectionPoint;
  60285. /**
  60286. * Gets the distance input component
  60287. */
  60288. get distance(): NodeMaterialConnectionPoint;
  60289. /**
  60290. * Gets the replacement input component
  60291. */
  60292. get replacement(): NodeMaterialConnectionPoint;
  60293. /**
  60294. * Gets the output component
  60295. */
  60296. get output(): NodeMaterialConnectionPoint;
  60297. protected _buildBlock(state: NodeMaterialBuildState): this;
  60298. }
  60299. }
  60300. declare module BABYLON {
  60301. /**
  60302. * Block used to posterize a value
  60303. * @see https://en.wikipedia.org/wiki/Posterization
  60304. */
  60305. export class PosterizeBlock extends NodeMaterialBlock {
  60306. /**
  60307. * Creates a new PosterizeBlock
  60308. * @param name defines the block name
  60309. */
  60310. constructor(name: string);
  60311. /**
  60312. * Gets the current class name
  60313. * @returns the class name
  60314. */
  60315. getClassName(): string;
  60316. /**
  60317. * Gets the value input component
  60318. */
  60319. get value(): NodeMaterialConnectionPoint;
  60320. /**
  60321. * Gets the steps input component
  60322. */
  60323. get steps(): NodeMaterialConnectionPoint;
  60324. /**
  60325. * Gets the output component
  60326. */
  60327. get output(): NodeMaterialConnectionPoint;
  60328. protected _buildBlock(state: NodeMaterialBuildState): this;
  60329. }
  60330. }
  60331. declare module BABYLON {
  60332. /**
  60333. * Operations supported by the Wave block
  60334. */
  60335. export enum WaveBlockKind {
  60336. /** SawTooth */
  60337. SawTooth = 0,
  60338. /** Square */
  60339. Square = 1,
  60340. /** Triangle */
  60341. Triangle = 2
  60342. }
  60343. /**
  60344. * Block used to apply wave operation to floats
  60345. */
  60346. export class WaveBlock extends NodeMaterialBlock {
  60347. /**
  60348. * Gets or sets the kibnd of wave to be applied by the block
  60349. */
  60350. kind: WaveBlockKind;
  60351. /**
  60352. * Creates a new WaveBlock
  60353. * @param name defines the block name
  60354. */
  60355. constructor(name: string);
  60356. /**
  60357. * Gets the current class name
  60358. * @returns the class name
  60359. */
  60360. getClassName(): string;
  60361. /**
  60362. * Gets the input component
  60363. */
  60364. get input(): NodeMaterialConnectionPoint;
  60365. /**
  60366. * Gets the output component
  60367. */
  60368. get output(): NodeMaterialConnectionPoint;
  60369. protected _buildBlock(state: NodeMaterialBuildState): this;
  60370. serialize(): any;
  60371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60372. }
  60373. }
  60374. declare module BABYLON {
  60375. /**
  60376. * Class used to store a color step for the GradientBlock
  60377. */
  60378. export class GradientBlockColorStep {
  60379. /**
  60380. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60381. */
  60382. step: number;
  60383. /**
  60384. * Gets or sets the color associated with this step
  60385. */
  60386. color: Color3;
  60387. /**
  60388. * Creates a new GradientBlockColorStep
  60389. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60390. * @param color defines the color associated with this step
  60391. */
  60392. constructor(
  60393. /**
  60394. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60395. */
  60396. step: number,
  60397. /**
  60398. * Gets or sets the color associated with this step
  60399. */
  60400. color: Color3);
  60401. }
  60402. /**
  60403. * Block used to return a color from a gradient based on an input value between 0 and 1
  60404. */
  60405. export class GradientBlock extends NodeMaterialBlock {
  60406. /**
  60407. * Gets or sets the list of color steps
  60408. */
  60409. colorSteps: GradientBlockColorStep[];
  60410. /**
  60411. * Creates a new GradientBlock
  60412. * @param name defines the block name
  60413. */
  60414. constructor(name: string);
  60415. /**
  60416. * Gets the current class name
  60417. * @returns the class name
  60418. */
  60419. getClassName(): string;
  60420. /**
  60421. * Gets the gradient input component
  60422. */
  60423. get gradient(): NodeMaterialConnectionPoint;
  60424. /**
  60425. * Gets the output component
  60426. */
  60427. get output(): NodeMaterialConnectionPoint;
  60428. private _writeColorConstant;
  60429. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60430. serialize(): any;
  60431. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60432. protected _dumpPropertiesCode(): string;
  60433. }
  60434. }
  60435. declare module BABYLON {
  60436. /**
  60437. * Block used to normalize lerp between 2 values
  60438. */
  60439. export class NLerpBlock extends NodeMaterialBlock {
  60440. /**
  60441. * Creates a new NLerpBlock
  60442. * @param name defines the block name
  60443. */
  60444. constructor(name: string);
  60445. /**
  60446. * Gets the current class name
  60447. * @returns the class name
  60448. */
  60449. getClassName(): string;
  60450. /**
  60451. * Gets the left operand input component
  60452. */
  60453. get left(): NodeMaterialConnectionPoint;
  60454. /**
  60455. * Gets the right operand input component
  60456. */
  60457. get right(): NodeMaterialConnectionPoint;
  60458. /**
  60459. * Gets the gradient operand input component
  60460. */
  60461. get gradient(): NodeMaterialConnectionPoint;
  60462. /**
  60463. * Gets the output component
  60464. */
  60465. get output(): NodeMaterialConnectionPoint;
  60466. protected _buildBlock(state: NodeMaterialBuildState): this;
  60467. }
  60468. }
  60469. declare module BABYLON {
  60470. /**
  60471. * block used to Generate a Worley Noise 3D Noise Pattern
  60472. */
  60473. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60474. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60475. manhattanDistance: boolean;
  60476. /**
  60477. * Creates a new WorleyNoise3DBlock
  60478. * @param name defines the block name
  60479. */
  60480. constructor(name: string);
  60481. /**
  60482. * Gets the current class name
  60483. * @returns the class name
  60484. */
  60485. getClassName(): string;
  60486. /**
  60487. * Gets the seed input component
  60488. */
  60489. get seed(): NodeMaterialConnectionPoint;
  60490. /**
  60491. * Gets the jitter input component
  60492. */
  60493. get jitter(): NodeMaterialConnectionPoint;
  60494. /**
  60495. * Gets the output component
  60496. */
  60497. get output(): NodeMaterialConnectionPoint;
  60498. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60499. /**
  60500. * Exposes the properties to the UI?
  60501. */
  60502. protected _dumpPropertiesCode(): string;
  60503. /**
  60504. * Exposes the properties to the Seralize?
  60505. */
  60506. serialize(): any;
  60507. /**
  60508. * Exposes the properties to the deseralize?
  60509. */
  60510. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60511. }
  60512. }
  60513. declare module BABYLON {
  60514. /**
  60515. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60516. */
  60517. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60518. /**
  60519. * Creates a new SimplexPerlin3DBlock
  60520. * @param name defines the block name
  60521. */
  60522. constructor(name: string);
  60523. /**
  60524. * Gets the current class name
  60525. * @returns the class name
  60526. */
  60527. getClassName(): string;
  60528. /**
  60529. * Gets the seed operand input component
  60530. */
  60531. get seed(): NodeMaterialConnectionPoint;
  60532. /**
  60533. * Gets the output component
  60534. */
  60535. get output(): NodeMaterialConnectionPoint;
  60536. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60537. }
  60538. }
  60539. declare module BABYLON {
  60540. /**
  60541. * Block used to blend normals
  60542. */
  60543. export class NormalBlendBlock extends NodeMaterialBlock {
  60544. /**
  60545. * Creates a new NormalBlendBlock
  60546. * @param name defines the block name
  60547. */
  60548. constructor(name: string);
  60549. /**
  60550. * Gets the current class name
  60551. * @returns the class name
  60552. */
  60553. getClassName(): string;
  60554. /**
  60555. * Gets the first input component
  60556. */
  60557. get normalMap0(): NodeMaterialConnectionPoint;
  60558. /**
  60559. * Gets the second input component
  60560. */
  60561. get normalMap1(): NodeMaterialConnectionPoint;
  60562. /**
  60563. * Gets the output component
  60564. */
  60565. get output(): NodeMaterialConnectionPoint;
  60566. protected _buildBlock(state: NodeMaterialBuildState): this;
  60567. }
  60568. }
  60569. declare module BABYLON {
  60570. /**
  60571. * Block used to rotate a 2d vector by a given angle
  60572. */
  60573. export class Rotate2dBlock extends NodeMaterialBlock {
  60574. /**
  60575. * Creates a new Rotate2dBlock
  60576. * @param name defines the block name
  60577. */
  60578. constructor(name: string);
  60579. /**
  60580. * Gets the current class name
  60581. * @returns the class name
  60582. */
  60583. getClassName(): string;
  60584. /**
  60585. * Gets the input vector
  60586. */
  60587. get input(): NodeMaterialConnectionPoint;
  60588. /**
  60589. * Gets the input angle
  60590. */
  60591. get angle(): NodeMaterialConnectionPoint;
  60592. /**
  60593. * Gets the output component
  60594. */
  60595. get output(): NodeMaterialConnectionPoint;
  60596. autoConfigure(material: NodeMaterial): void;
  60597. protected _buildBlock(state: NodeMaterialBuildState): this;
  60598. }
  60599. }
  60600. declare module BABYLON {
  60601. /**
  60602. * Block used to get the reflected vector from a direction and a normal
  60603. */
  60604. export class ReflectBlock extends NodeMaterialBlock {
  60605. /**
  60606. * Creates a new ReflectBlock
  60607. * @param name defines the block name
  60608. */
  60609. constructor(name: string);
  60610. /**
  60611. * Gets the current class name
  60612. * @returns the class name
  60613. */
  60614. getClassName(): string;
  60615. /**
  60616. * Gets the incident component
  60617. */
  60618. get incident(): NodeMaterialConnectionPoint;
  60619. /**
  60620. * Gets the normal component
  60621. */
  60622. get normal(): NodeMaterialConnectionPoint;
  60623. /**
  60624. * Gets the output component
  60625. */
  60626. get output(): NodeMaterialConnectionPoint;
  60627. protected _buildBlock(state: NodeMaterialBuildState): this;
  60628. }
  60629. }
  60630. declare module BABYLON {
  60631. /**
  60632. * Block used to get the refracted vector from a direction and a normal
  60633. */
  60634. export class RefractBlock extends NodeMaterialBlock {
  60635. /**
  60636. * Creates a new RefractBlock
  60637. * @param name defines the block name
  60638. */
  60639. constructor(name: string);
  60640. /**
  60641. * Gets the current class name
  60642. * @returns the class name
  60643. */
  60644. getClassName(): string;
  60645. /**
  60646. * Gets the incident component
  60647. */
  60648. get incident(): NodeMaterialConnectionPoint;
  60649. /**
  60650. * Gets the normal component
  60651. */
  60652. get normal(): NodeMaterialConnectionPoint;
  60653. /**
  60654. * Gets the index of refraction component
  60655. */
  60656. get ior(): NodeMaterialConnectionPoint;
  60657. /**
  60658. * Gets the output component
  60659. */
  60660. get output(): NodeMaterialConnectionPoint;
  60661. protected _buildBlock(state: NodeMaterialBuildState): this;
  60662. }
  60663. }
  60664. declare module BABYLON {
  60665. /**
  60666. * Block used to desaturate a color
  60667. */
  60668. export class DesaturateBlock extends NodeMaterialBlock {
  60669. /**
  60670. * Creates a new DesaturateBlock
  60671. * @param name defines the block name
  60672. */
  60673. constructor(name: string);
  60674. /**
  60675. * Gets the current class name
  60676. * @returns the class name
  60677. */
  60678. getClassName(): string;
  60679. /**
  60680. * Gets the color operand input component
  60681. */
  60682. get color(): NodeMaterialConnectionPoint;
  60683. /**
  60684. * Gets the level operand input component
  60685. */
  60686. get level(): NodeMaterialConnectionPoint;
  60687. /**
  60688. * Gets the output component
  60689. */
  60690. get output(): NodeMaterialConnectionPoint;
  60691. protected _buildBlock(state: NodeMaterialBuildState): this;
  60692. }
  60693. }
  60694. declare module BABYLON {
  60695. /**
  60696. * Effect Render Options
  60697. */
  60698. export interface IEffectRendererOptions {
  60699. /**
  60700. * Defines the vertices positions.
  60701. */
  60702. positions?: number[];
  60703. /**
  60704. * Defines the indices.
  60705. */
  60706. indices?: number[];
  60707. }
  60708. /**
  60709. * Helper class to render one or more effects.
  60710. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60711. */
  60712. export class EffectRenderer {
  60713. private engine;
  60714. private static _DefaultOptions;
  60715. private _vertexBuffers;
  60716. private _indexBuffer;
  60717. private _fullscreenViewport;
  60718. /**
  60719. * Creates an effect renderer
  60720. * @param engine the engine to use for rendering
  60721. * @param options defines the options of the effect renderer
  60722. */
  60723. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60724. /**
  60725. * Sets the current viewport in normalized coordinates 0-1
  60726. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60727. */
  60728. setViewport(viewport?: Viewport): void;
  60729. /**
  60730. * Binds the embedded attributes buffer to the effect.
  60731. * @param effect Defines the effect to bind the attributes for
  60732. */
  60733. bindBuffers(effect: Effect): void;
  60734. /**
  60735. * Sets the current effect wrapper to use during draw.
  60736. * The effect needs to be ready before calling this api.
  60737. * This also sets the default full screen position attribute.
  60738. * @param effectWrapper Defines the effect to draw with
  60739. */
  60740. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60741. /**
  60742. * Draws a full screen quad.
  60743. */
  60744. draw(): void;
  60745. private isRenderTargetTexture;
  60746. /**
  60747. * renders one or more effects to a specified texture
  60748. * @param effectWrapper the effect to renderer
  60749. * @param outputTexture texture to draw to, if null it will render to the screen.
  60750. */
  60751. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60752. /**
  60753. * Disposes of the effect renderer
  60754. */
  60755. dispose(): void;
  60756. }
  60757. /**
  60758. * Options to create an EffectWrapper
  60759. */
  60760. interface EffectWrapperCreationOptions {
  60761. /**
  60762. * Engine to use to create the effect
  60763. */
  60764. engine: ThinEngine;
  60765. /**
  60766. * Fragment shader for the effect
  60767. */
  60768. fragmentShader: string;
  60769. /**
  60770. * Vertex shader for the effect
  60771. */
  60772. vertexShader?: string;
  60773. /**
  60774. * Attributes to use in the shader
  60775. */
  60776. attributeNames?: Array<string>;
  60777. /**
  60778. * Uniforms to use in the shader
  60779. */
  60780. uniformNames?: Array<string>;
  60781. /**
  60782. * Texture sampler names to use in the shader
  60783. */
  60784. samplerNames?: Array<string>;
  60785. /**
  60786. * The friendly name of the effect displayed in Spector.
  60787. */
  60788. name?: string;
  60789. }
  60790. /**
  60791. * Wraps an effect to be used for rendering
  60792. */
  60793. export class EffectWrapper {
  60794. /**
  60795. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60796. */
  60797. onApplyObservable: Observable<{}>;
  60798. /**
  60799. * The underlying effect
  60800. */
  60801. effect: Effect;
  60802. /**
  60803. * Creates an effect to be renderer
  60804. * @param creationOptions options to create the effect
  60805. */
  60806. constructor(creationOptions: EffectWrapperCreationOptions);
  60807. /**
  60808. * Disposes of the effect wrapper
  60809. */
  60810. dispose(): void;
  60811. }
  60812. }
  60813. declare module BABYLON {
  60814. /**
  60815. * Helper class to push actions to a pool of workers.
  60816. */
  60817. export class WorkerPool implements IDisposable {
  60818. private _workerInfos;
  60819. private _pendingActions;
  60820. /**
  60821. * Constructor
  60822. * @param workers Array of workers to use for actions
  60823. */
  60824. constructor(workers: Array<Worker>);
  60825. /**
  60826. * Terminates all workers and clears any pending actions.
  60827. */
  60828. dispose(): void;
  60829. /**
  60830. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60831. * pended until a worker has completed its action.
  60832. * @param action The action to perform. Call onComplete when the action is complete.
  60833. */
  60834. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60835. private _execute;
  60836. }
  60837. }
  60838. declare module BABYLON {
  60839. /**
  60840. * Configuration for Draco compression
  60841. */
  60842. export interface IDracoCompressionConfiguration {
  60843. /**
  60844. * Configuration for the decoder.
  60845. */
  60846. decoder: {
  60847. /**
  60848. * The url to the WebAssembly module.
  60849. */
  60850. wasmUrl?: string;
  60851. /**
  60852. * The url to the WebAssembly binary.
  60853. */
  60854. wasmBinaryUrl?: string;
  60855. /**
  60856. * The url to the fallback JavaScript module.
  60857. */
  60858. fallbackUrl?: string;
  60859. };
  60860. }
  60861. /**
  60862. * Draco compression (https://google.github.io/draco/)
  60863. *
  60864. * This class wraps the Draco module.
  60865. *
  60866. * **Encoder**
  60867. *
  60868. * The encoder is not currently implemented.
  60869. *
  60870. * **Decoder**
  60871. *
  60872. * 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.
  60873. *
  60874. * To update the configuration, use the following code:
  60875. * ```javascript
  60876. * DracoCompression.Configuration = {
  60877. * decoder: {
  60878. * wasmUrl: "<url to the WebAssembly library>",
  60879. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60880. * fallbackUrl: "<url to the fallback JavaScript library>",
  60881. * }
  60882. * };
  60883. * ```
  60884. *
  60885. * 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.
  60886. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60887. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60888. *
  60889. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60890. * ```javascript
  60891. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60892. * ```
  60893. *
  60894. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60895. */
  60896. export class DracoCompression implements IDisposable {
  60897. private _workerPoolPromise?;
  60898. private _decoderModulePromise?;
  60899. /**
  60900. * The configuration. Defaults to the following urls:
  60901. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60902. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60903. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60904. */
  60905. static Configuration: IDracoCompressionConfiguration;
  60906. /**
  60907. * Returns true if the decoder configuration is available.
  60908. */
  60909. static get DecoderAvailable(): boolean;
  60910. /**
  60911. * Default number of workers to create when creating the draco compression object.
  60912. */
  60913. static DefaultNumWorkers: number;
  60914. private static GetDefaultNumWorkers;
  60915. private static _Default;
  60916. /**
  60917. * Default instance for the draco compression object.
  60918. */
  60919. static get Default(): DracoCompression;
  60920. /**
  60921. * Constructor
  60922. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60923. */
  60924. constructor(numWorkers?: number);
  60925. /**
  60926. * Stop all async operations and release resources.
  60927. */
  60928. dispose(): void;
  60929. /**
  60930. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60931. * @returns a promise that resolves when ready
  60932. */
  60933. whenReadyAsync(): Promise<void>;
  60934. /**
  60935. * Decode Draco compressed mesh data to vertex data.
  60936. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60937. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60938. * @returns A promise that resolves with the decoded vertex data
  60939. */
  60940. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60941. [kind: string]: number;
  60942. }): Promise<VertexData>;
  60943. }
  60944. }
  60945. declare module BABYLON {
  60946. /**
  60947. * Class for building Constructive Solid Geometry
  60948. */
  60949. export class CSG {
  60950. private polygons;
  60951. /**
  60952. * The world matrix
  60953. */
  60954. matrix: Matrix;
  60955. /**
  60956. * Stores the position
  60957. */
  60958. position: Vector3;
  60959. /**
  60960. * Stores the rotation
  60961. */
  60962. rotation: Vector3;
  60963. /**
  60964. * Stores the rotation quaternion
  60965. */
  60966. rotationQuaternion: Nullable<Quaternion>;
  60967. /**
  60968. * Stores the scaling vector
  60969. */
  60970. scaling: Vector3;
  60971. /**
  60972. * Convert the Mesh to CSG
  60973. * @param mesh The Mesh to convert to CSG
  60974. * @returns A new CSG from the Mesh
  60975. */
  60976. static FromMesh(mesh: Mesh): CSG;
  60977. /**
  60978. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60979. * @param polygons Polygons used to construct a CSG solid
  60980. */
  60981. private static FromPolygons;
  60982. /**
  60983. * Clones, or makes a deep copy, of the CSG
  60984. * @returns A new CSG
  60985. */
  60986. clone(): CSG;
  60987. /**
  60988. * Unions this CSG with another CSG
  60989. * @param csg The CSG to union against this CSG
  60990. * @returns The unioned CSG
  60991. */
  60992. union(csg: CSG): CSG;
  60993. /**
  60994. * Unions this CSG with another CSG in place
  60995. * @param csg The CSG to union against this CSG
  60996. */
  60997. unionInPlace(csg: CSG): void;
  60998. /**
  60999. * Subtracts this CSG with another CSG
  61000. * @param csg The CSG to subtract against this CSG
  61001. * @returns A new CSG
  61002. */
  61003. subtract(csg: CSG): CSG;
  61004. /**
  61005. * Subtracts this CSG with another CSG in place
  61006. * @param csg The CSG to subtact against this CSG
  61007. */
  61008. subtractInPlace(csg: CSG): void;
  61009. /**
  61010. * Intersect this CSG with another CSG
  61011. * @param csg The CSG to intersect against this CSG
  61012. * @returns A new CSG
  61013. */
  61014. intersect(csg: CSG): CSG;
  61015. /**
  61016. * Intersects this CSG with another CSG in place
  61017. * @param csg The CSG to intersect against this CSG
  61018. */
  61019. intersectInPlace(csg: CSG): void;
  61020. /**
  61021. * Return a new CSG solid with solid and empty space switched. This solid is
  61022. * not modified.
  61023. * @returns A new CSG solid with solid and empty space switched
  61024. */
  61025. inverse(): CSG;
  61026. /**
  61027. * Inverses the CSG in place
  61028. */
  61029. inverseInPlace(): void;
  61030. /**
  61031. * This is used to keep meshes transformations so they can be restored
  61032. * when we build back a Babylon Mesh
  61033. * NB : All CSG operations are performed in world coordinates
  61034. * @param csg The CSG to copy the transform attributes from
  61035. * @returns This CSG
  61036. */
  61037. copyTransformAttributes(csg: CSG): CSG;
  61038. /**
  61039. * Build Raw mesh from CSG
  61040. * Coordinates here are in world space
  61041. * @param name The name of the mesh geometry
  61042. * @param scene The Scene
  61043. * @param keepSubMeshes Specifies if the submeshes should be kept
  61044. * @returns A new Mesh
  61045. */
  61046. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61047. /**
  61048. * Build Mesh from CSG taking material and transforms into account
  61049. * @param name The name of the Mesh
  61050. * @param material The material of the Mesh
  61051. * @param scene The Scene
  61052. * @param keepSubMeshes Specifies if submeshes should be kept
  61053. * @returns The new Mesh
  61054. */
  61055. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61056. }
  61057. }
  61058. declare module BABYLON {
  61059. /**
  61060. * Class used to create a trail following a mesh
  61061. */
  61062. export class TrailMesh extends Mesh {
  61063. private _generator;
  61064. private _autoStart;
  61065. private _running;
  61066. private _diameter;
  61067. private _length;
  61068. private _sectionPolygonPointsCount;
  61069. private _sectionVectors;
  61070. private _sectionNormalVectors;
  61071. private _beforeRenderObserver;
  61072. /**
  61073. * @constructor
  61074. * @param name The value used by scene.getMeshByName() to do a lookup.
  61075. * @param generator The mesh or transform node to generate a trail.
  61076. * @param scene The scene to add this mesh to.
  61077. * @param diameter Diameter of trailing mesh. Default is 1.
  61078. * @param length Length of trailing mesh. Default is 60.
  61079. * @param autoStart Automatically start trailing mesh. Default true.
  61080. */
  61081. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61082. /**
  61083. * "TrailMesh"
  61084. * @returns "TrailMesh"
  61085. */
  61086. getClassName(): string;
  61087. private _createMesh;
  61088. /**
  61089. * Start trailing mesh.
  61090. */
  61091. start(): void;
  61092. /**
  61093. * Stop trailing mesh.
  61094. */
  61095. stop(): void;
  61096. /**
  61097. * Update trailing mesh geometry.
  61098. */
  61099. update(): void;
  61100. /**
  61101. * Returns a new TrailMesh object.
  61102. * @param name is a string, the name given to the new mesh
  61103. * @param newGenerator use new generator object for cloned trail mesh
  61104. * @returns a new mesh
  61105. */
  61106. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61107. /**
  61108. * Serializes this trail mesh
  61109. * @param serializationObject object to write serialization to
  61110. */
  61111. serialize(serializationObject: any): void;
  61112. /**
  61113. * Parses a serialized trail mesh
  61114. * @param parsedMesh the serialized mesh
  61115. * @param scene the scene to create the trail mesh in
  61116. * @returns the created trail mesh
  61117. */
  61118. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61119. }
  61120. }
  61121. declare module BABYLON {
  61122. /**
  61123. * Class containing static functions to help procedurally build meshes
  61124. */
  61125. export class TiledBoxBuilder {
  61126. /**
  61127. * Creates a box mesh
  61128. * 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)
  61129. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61131. * * 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
  61132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61133. * @param name defines the name of the mesh
  61134. * @param options defines the options used to create the mesh
  61135. * @param scene defines the hosting scene
  61136. * @returns the box mesh
  61137. */
  61138. static CreateTiledBox(name: string, options: {
  61139. pattern?: number;
  61140. width?: number;
  61141. height?: number;
  61142. depth?: number;
  61143. tileSize?: number;
  61144. tileWidth?: number;
  61145. tileHeight?: number;
  61146. alignHorizontal?: number;
  61147. alignVertical?: number;
  61148. faceUV?: Vector4[];
  61149. faceColors?: Color4[];
  61150. sideOrientation?: number;
  61151. updatable?: boolean;
  61152. }, scene?: Nullable<Scene>): Mesh;
  61153. }
  61154. }
  61155. declare module BABYLON {
  61156. /**
  61157. * Class containing static functions to help procedurally build meshes
  61158. */
  61159. export class TorusKnotBuilder {
  61160. /**
  61161. * Creates a torus knot mesh
  61162. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61163. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61164. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61165. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61167. * * 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
  61168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61169. * @param name defines the name of the mesh
  61170. * @param options defines the options used to create the mesh
  61171. * @param scene defines the hosting scene
  61172. * @returns the torus knot mesh
  61173. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61174. */
  61175. static CreateTorusKnot(name: string, options: {
  61176. radius?: number;
  61177. tube?: number;
  61178. radialSegments?: number;
  61179. tubularSegments?: number;
  61180. p?: number;
  61181. q?: number;
  61182. updatable?: boolean;
  61183. sideOrientation?: number;
  61184. frontUVs?: Vector4;
  61185. backUVs?: Vector4;
  61186. }, scene: any): Mesh;
  61187. }
  61188. }
  61189. declare module BABYLON {
  61190. /**
  61191. * Polygon
  61192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61193. */
  61194. export class Polygon {
  61195. /**
  61196. * Creates a rectangle
  61197. * @param xmin bottom X coord
  61198. * @param ymin bottom Y coord
  61199. * @param xmax top X coord
  61200. * @param ymax top Y coord
  61201. * @returns points that make the resulting rectation
  61202. */
  61203. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61204. /**
  61205. * Creates a circle
  61206. * @param radius radius of circle
  61207. * @param cx scale in x
  61208. * @param cy scale in y
  61209. * @param numberOfSides number of sides that make up the circle
  61210. * @returns points that make the resulting circle
  61211. */
  61212. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61213. /**
  61214. * Creates a polygon from input string
  61215. * @param input Input polygon data
  61216. * @returns the parsed points
  61217. */
  61218. static Parse(input: string): Vector2[];
  61219. /**
  61220. * Starts building a polygon from x and y coordinates
  61221. * @param x x coordinate
  61222. * @param y y coordinate
  61223. * @returns the started path2
  61224. */
  61225. static StartingAt(x: number, y: number): Path2;
  61226. }
  61227. /**
  61228. * Builds a polygon
  61229. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61230. */
  61231. export class PolygonMeshBuilder {
  61232. private _points;
  61233. private _outlinepoints;
  61234. private _holes;
  61235. private _name;
  61236. private _scene;
  61237. private _epoints;
  61238. private _eholes;
  61239. private _addToepoint;
  61240. /**
  61241. * Babylon reference to the earcut plugin.
  61242. */
  61243. bjsEarcut: any;
  61244. /**
  61245. * Creates a PolygonMeshBuilder
  61246. * @param name name of the builder
  61247. * @param contours Path of the polygon
  61248. * @param scene scene to add to when creating the mesh
  61249. * @param earcutInjection can be used to inject your own earcut reference
  61250. */
  61251. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61252. /**
  61253. * Adds a whole within the polygon
  61254. * @param hole Array of points defining the hole
  61255. * @returns this
  61256. */
  61257. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61258. /**
  61259. * Creates the polygon
  61260. * @param updatable If the mesh should be updatable
  61261. * @param depth The depth of the mesh created
  61262. * @returns the created mesh
  61263. */
  61264. build(updatable?: boolean, depth?: number): Mesh;
  61265. /**
  61266. * Creates the polygon
  61267. * @param depth The depth of the mesh created
  61268. * @returns the created VertexData
  61269. */
  61270. buildVertexData(depth?: number): VertexData;
  61271. /**
  61272. * Adds a side to the polygon
  61273. * @param positions points that make the polygon
  61274. * @param normals normals of the polygon
  61275. * @param uvs uvs of the polygon
  61276. * @param indices indices of the polygon
  61277. * @param bounds bounds of the polygon
  61278. * @param points points of the polygon
  61279. * @param depth depth of the polygon
  61280. * @param flip flip of the polygon
  61281. */
  61282. private addSide;
  61283. }
  61284. }
  61285. declare module BABYLON {
  61286. /**
  61287. * Class containing static functions to help procedurally build meshes
  61288. */
  61289. export class PolygonBuilder {
  61290. /**
  61291. * Creates a polygon mesh
  61292. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61293. * * 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
  61294. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61296. * * 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)
  61297. * * Remember you can only change the shape positions, not their number when updating a polygon
  61298. * @param name defines the name of the mesh
  61299. * @param options defines the options used to create the mesh
  61300. * @param scene defines the hosting scene
  61301. * @param earcutInjection can be used to inject your own earcut reference
  61302. * @returns the polygon mesh
  61303. */
  61304. static CreatePolygon(name: string, options: {
  61305. shape: Vector3[];
  61306. holes?: Vector3[][];
  61307. depth?: number;
  61308. faceUV?: Vector4[];
  61309. faceColors?: Color4[];
  61310. updatable?: boolean;
  61311. sideOrientation?: number;
  61312. frontUVs?: Vector4;
  61313. backUVs?: Vector4;
  61314. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61315. /**
  61316. * Creates an extruded polygon mesh, with depth in the Y direction.
  61317. * * 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)
  61318. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61319. * @param name defines the name of the mesh
  61320. * @param options defines the options used to create the mesh
  61321. * @param scene defines the hosting scene
  61322. * @param earcutInjection can be used to inject your own earcut reference
  61323. * @returns the polygon mesh
  61324. */
  61325. static ExtrudePolygon(name: string, options: {
  61326. shape: Vector3[];
  61327. holes?: Vector3[][];
  61328. depth?: number;
  61329. faceUV?: Vector4[];
  61330. faceColors?: Color4[];
  61331. updatable?: boolean;
  61332. sideOrientation?: number;
  61333. frontUVs?: Vector4;
  61334. backUVs?: Vector4;
  61335. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61336. }
  61337. }
  61338. declare module BABYLON {
  61339. /**
  61340. * Class containing static functions to help procedurally build meshes
  61341. */
  61342. export class LatheBuilder {
  61343. /**
  61344. * Creates lathe mesh.
  61345. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61346. * * 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
  61347. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61348. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61349. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61350. * * 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
  61351. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61352. * * 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
  61353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61354. * * 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
  61355. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61357. * @param name defines the name of the mesh
  61358. * @param options defines the options used to create the mesh
  61359. * @param scene defines the hosting scene
  61360. * @returns the lathe mesh
  61361. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61362. */
  61363. static CreateLathe(name: string, options: {
  61364. shape: Vector3[];
  61365. radius?: number;
  61366. tessellation?: number;
  61367. clip?: number;
  61368. arc?: number;
  61369. closed?: boolean;
  61370. updatable?: boolean;
  61371. sideOrientation?: number;
  61372. frontUVs?: Vector4;
  61373. backUVs?: Vector4;
  61374. cap?: number;
  61375. invertUV?: boolean;
  61376. }, scene?: Nullable<Scene>): Mesh;
  61377. }
  61378. }
  61379. declare module BABYLON {
  61380. /**
  61381. * Class containing static functions to help procedurally build meshes
  61382. */
  61383. export class TiledPlaneBuilder {
  61384. /**
  61385. * Creates a tiled plane mesh
  61386. * * The parameter `pattern` will, depending on value, do nothing or
  61387. * * * flip (reflect about central vertical) alternate tiles across and up
  61388. * * * flip every tile on alternate rows
  61389. * * * rotate (180 degs) alternate tiles across and up
  61390. * * * rotate every tile on alternate rows
  61391. * * * flip and rotate alternate tiles across and up
  61392. * * * flip and rotate every tile on alternate rows
  61393. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61394. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61395. * * 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
  61396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61397. * * 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)
  61398. * * 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)
  61399. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61400. * @param name defines the name of the mesh
  61401. * @param options defines the options used to create the mesh
  61402. * @param scene defines the hosting scene
  61403. * @returns the box mesh
  61404. */
  61405. static CreateTiledPlane(name: string, options: {
  61406. pattern?: number;
  61407. tileSize?: number;
  61408. tileWidth?: number;
  61409. tileHeight?: number;
  61410. size?: number;
  61411. width?: number;
  61412. height?: number;
  61413. alignHorizontal?: number;
  61414. alignVertical?: number;
  61415. sideOrientation?: number;
  61416. frontUVs?: Vector4;
  61417. backUVs?: Vector4;
  61418. updatable?: boolean;
  61419. }, scene?: Nullable<Scene>): Mesh;
  61420. }
  61421. }
  61422. declare module BABYLON {
  61423. /**
  61424. * Class containing static functions to help procedurally build meshes
  61425. */
  61426. export class TubeBuilder {
  61427. /**
  61428. * Creates a tube mesh.
  61429. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61430. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61431. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61432. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61433. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61434. * * 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)
  61435. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61436. * * 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
  61437. * * 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
  61438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61439. * * 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
  61440. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61442. * @param name defines the name of the mesh
  61443. * @param options defines the options used to create the mesh
  61444. * @param scene defines the hosting scene
  61445. * @returns the tube mesh
  61446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61447. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61448. */
  61449. static CreateTube(name: string, options: {
  61450. path: Vector3[];
  61451. radius?: number;
  61452. tessellation?: number;
  61453. radiusFunction?: {
  61454. (i: number, distance: number): number;
  61455. };
  61456. cap?: number;
  61457. arc?: number;
  61458. updatable?: boolean;
  61459. sideOrientation?: number;
  61460. frontUVs?: Vector4;
  61461. backUVs?: Vector4;
  61462. instance?: Mesh;
  61463. invertUV?: boolean;
  61464. }, scene?: Nullable<Scene>): Mesh;
  61465. }
  61466. }
  61467. declare module BABYLON {
  61468. /**
  61469. * Class containing static functions to help procedurally build meshes
  61470. */
  61471. export class IcoSphereBuilder {
  61472. /**
  61473. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61474. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61475. * * 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`)
  61476. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61477. * * 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
  61478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61479. * * 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
  61480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61481. * @param name defines the name of the mesh
  61482. * @param options defines the options used to create the mesh
  61483. * @param scene defines the hosting scene
  61484. * @returns the icosahedron mesh
  61485. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61486. */
  61487. static CreateIcoSphere(name: string, options: {
  61488. radius?: number;
  61489. radiusX?: number;
  61490. radiusY?: number;
  61491. radiusZ?: number;
  61492. flat?: boolean;
  61493. subdivisions?: number;
  61494. sideOrientation?: number;
  61495. frontUVs?: Vector4;
  61496. backUVs?: Vector4;
  61497. updatable?: boolean;
  61498. }, scene?: Nullable<Scene>): Mesh;
  61499. }
  61500. }
  61501. declare module BABYLON {
  61502. /**
  61503. * Class containing static functions to help procedurally build meshes
  61504. */
  61505. export class DecalBuilder {
  61506. /**
  61507. * Creates a decal mesh.
  61508. * 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
  61509. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61510. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61511. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61512. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61513. * @param name defines the name of the mesh
  61514. * @param sourceMesh defines the mesh where the decal must be applied
  61515. * @param options defines the options used to create the mesh
  61516. * @param scene defines the hosting scene
  61517. * @returns the decal mesh
  61518. * @see https://doc.babylonjs.com/how_to/decals
  61519. */
  61520. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61521. position?: Vector3;
  61522. normal?: Vector3;
  61523. size?: Vector3;
  61524. angle?: number;
  61525. }): Mesh;
  61526. }
  61527. }
  61528. declare module BABYLON {
  61529. /**
  61530. * Class containing static functions to help procedurally build meshes
  61531. */
  61532. export class MeshBuilder {
  61533. /**
  61534. * Creates a box mesh
  61535. * * The parameter `size` sets the size (float) of each box side (default 1)
  61536. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61537. * * 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)
  61538. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61540. * * 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
  61541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61542. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61543. * @param name defines the name of the mesh
  61544. * @param options defines the options used to create the mesh
  61545. * @param scene defines the hosting scene
  61546. * @returns the box mesh
  61547. */
  61548. static CreateBox(name: string, options: {
  61549. size?: number;
  61550. width?: number;
  61551. height?: number;
  61552. depth?: number;
  61553. faceUV?: Vector4[];
  61554. faceColors?: Color4[];
  61555. sideOrientation?: number;
  61556. frontUVs?: Vector4;
  61557. backUVs?: Vector4;
  61558. wrap?: boolean;
  61559. topBaseAt?: number;
  61560. bottomBaseAt?: number;
  61561. updatable?: boolean;
  61562. }, scene?: Nullable<Scene>): Mesh;
  61563. /**
  61564. * Creates a tiled box mesh
  61565. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61567. * @param name defines the name of the mesh
  61568. * @param options defines the options used to create the mesh
  61569. * @param scene defines the hosting scene
  61570. * @returns the tiled box mesh
  61571. */
  61572. static CreateTiledBox(name: string, options: {
  61573. pattern?: number;
  61574. size?: number;
  61575. width?: number;
  61576. height?: number;
  61577. depth: number;
  61578. tileSize?: number;
  61579. tileWidth?: number;
  61580. tileHeight?: number;
  61581. faceUV?: Vector4[];
  61582. faceColors?: Color4[];
  61583. alignHorizontal?: number;
  61584. alignVertical?: number;
  61585. sideOrientation?: number;
  61586. updatable?: boolean;
  61587. }, scene?: Nullable<Scene>): Mesh;
  61588. /**
  61589. * Creates a sphere mesh
  61590. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61591. * * 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`)
  61592. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61593. * * 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
  61594. * * 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)
  61595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61596. * * 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
  61597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61598. * @param name defines the name of the mesh
  61599. * @param options defines the options used to create the mesh
  61600. * @param scene defines the hosting scene
  61601. * @returns the sphere mesh
  61602. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61603. */
  61604. static CreateSphere(name: string, options: {
  61605. segments?: number;
  61606. diameter?: number;
  61607. diameterX?: number;
  61608. diameterY?: number;
  61609. diameterZ?: number;
  61610. arc?: number;
  61611. slice?: number;
  61612. sideOrientation?: number;
  61613. frontUVs?: Vector4;
  61614. backUVs?: Vector4;
  61615. updatable?: boolean;
  61616. }, scene?: Nullable<Scene>): Mesh;
  61617. /**
  61618. * Creates a plane polygonal mesh. By default, this is a disc
  61619. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61620. * * 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
  61621. * * 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
  61622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61623. * * 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
  61624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61625. * @param name defines the name of the mesh
  61626. * @param options defines the options used to create the mesh
  61627. * @param scene defines the hosting scene
  61628. * @returns the plane polygonal mesh
  61629. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61630. */
  61631. static CreateDisc(name: string, options: {
  61632. radius?: number;
  61633. tessellation?: number;
  61634. arc?: number;
  61635. updatable?: boolean;
  61636. sideOrientation?: number;
  61637. frontUVs?: Vector4;
  61638. backUVs?: Vector4;
  61639. }, scene?: Nullable<Scene>): Mesh;
  61640. /**
  61641. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61642. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61643. * * 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`)
  61644. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61645. * * 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
  61646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61647. * * 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
  61648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61649. * @param name defines the name of the mesh
  61650. * @param options defines the options used to create the mesh
  61651. * @param scene defines the hosting scene
  61652. * @returns the icosahedron mesh
  61653. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61654. */
  61655. static CreateIcoSphere(name: string, options: {
  61656. radius?: number;
  61657. radiusX?: number;
  61658. radiusY?: number;
  61659. radiusZ?: number;
  61660. flat?: boolean;
  61661. subdivisions?: number;
  61662. sideOrientation?: number;
  61663. frontUVs?: Vector4;
  61664. backUVs?: Vector4;
  61665. updatable?: boolean;
  61666. }, scene?: Nullable<Scene>): Mesh;
  61667. /**
  61668. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61669. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61670. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61671. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61672. * * 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
  61673. * * 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
  61674. * * 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
  61675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61678. * * 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
  61679. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61680. * * 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
  61681. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61683. * @param name defines the name of the mesh
  61684. * @param options defines the options used to create the mesh
  61685. * @param scene defines the hosting scene
  61686. * @returns the ribbon mesh
  61687. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61688. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61689. */
  61690. static CreateRibbon(name: string, options: {
  61691. pathArray: Vector3[][];
  61692. closeArray?: boolean;
  61693. closePath?: boolean;
  61694. offset?: number;
  61695. updatable?: boolean;
  61696. sideOrientation?: number;
  61697. frontUVs?: Vector4;
  61698. backUVs?: Vector4;
  61699. instance?: Mesh;
  61700. invertUV?: boolean;
  61701. uvs?: Vector2[];
  61702. colors?: Color4[];
  61703. }, scene?: Nullable<Scene>): Mesh;
  61704. /**
  61705. * Creates a cylinder or a cone mesh
  61706. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61707. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61708. * * 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.
  61709. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61710. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61711. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61712. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61713. * * 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).
  61714. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61715. * * 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).
  61716. * * 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
  61717. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61718. * * 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
  61719. * * 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.
  61720. * * If `enclose` is false, a ring surface is one element.
  61721. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61722. * * 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
  61723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61724. * * 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
  61725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61726. * @param name defines the name of the mesh
  61727. * @param options defines the options used to create the mesh
  61728. * @param scene defines the hosting scene
  61729. * @returns the cylinder mesh
  61730. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61731. */
  61732. static CreateCylinder(name: string, options: {
  61733. height?: number;
  61734. diameterTop?: number;
  61735. diameterBottom?: number;
  61736. diameter?: number;
  61737. tessellation?: number;
  61738. subdivisions?: number;
  61739. arc?: number;
  61740. faceColors?: Color4[];
  61741. faceUV?: Vector4[];
  61742. updatable?: boolean;
  61743. hasRings?: boolean;
  61744. enclose?: boolean;
  61745. cap?: number;
  61746. sideOrientation?: number;
  61747. frontUVs?: Vector4;
  61748. backUVs?: Vector4;
  61749. }, scene?: Nullable<Scene>): Mesh;
  61750. /**
  61751. * Creates a torus mesh
  61752. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61753. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61754. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61756. * * 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
  61757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61758. * @param name defines the name of the mesh
  61759. * @param options defines the options used to create the mesh
  61760. * @param scene defines the hosting scene
  61761. * @returns the torus mesh
  61762. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61763. */
  61764. static CreateTorus(name: string, options: {
  61765. diameter?: number;
  61766. thickness?: number;
  61767. tessellation?: number;
  61768. updatable?: boolean;
  61769. sideOrientation?: number;
  61770. frontUVs?: Vector4;
  61771. backUVs?: Vector4;
  61772. }, scene?: Nullable<Scene>): Mesh;
  61773. /**
  61774. * Creates a torus knot mesh
  61775. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61776. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61777. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61778. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61780. * * 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
  61781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61782. * @param name defines the name of the mesh
  61783. * @param options defines the options used to create the mesh
  61784. * @param scene defines the hosting scene
  61785. * @returns the torus knot mesh
  61786. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61787. */
  61788. static CreateTorusKnot(name: string, options: {
  61789. radius?: number;
  61790. tube?: number;
  61791. radialSegments?: number;
  61792. tubularSegments?: number;
  61793. p?: number;
  61794. q?: number;
  61795. updatable?: boolean;
  61796. sideOrientation?: number;
  61797. frontUVs?: Vector4;
  61798. backUVs?: Vector4;
  61799. }, scene?: Nullable<Scene>): Mesh;
  61800. /**
  61801. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61802. * * 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
  61803. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61804. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61805. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61806. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61807. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61808. * * 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
  61809. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61812. * @param name defines the name of the new line system
  61813. * @param options defines the options used to create the line system
  61814. * @param scene defines the hosting scene
  61815. * @returns a new line system mesh
  61816. */
  61817. static CreateLineSystem(name: string, options: {
  61818. lines: Vector3[][];
  61819. updatable?: boolean;
  61820. instance?: Nullable<LinesMesh>;
  61821. colors?: Nullable<Color4[][]>;
  61822. useVertexAlpha?: boolean;
  61823. }, scene: Nullable<Scene>): LinesMesh;
  61824. /**
  61825. * Creates a line mesh
  61826. * 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
  61827. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61828. * * The parameter `points` is an array successive Vector3
  61829. * * 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
  61830. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61831. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61832. * * When updating an instance, remember that only point positions can change, not the number of points
  61833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61834. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61835. * @param name defines the name of the new line system
  61836. * @param options defines the options used to create the line system
  61837. * @param scene defines the hosting scene
  61838. * @returns a new line mesh
  61839. */
  61840. static CreateLines(name: string, options: {
  61841. points: Vector3[];
  61842. updatable?: boolean;
  61843. instance?: Nullable<LinesMesh>;
  61844. colors?: Color4[];
  61845. useVertexAlpha?: boolean;
  61846. }, scene?: Nullable<Scene>): LinesMesh;
  61847. /**
  61848. * Creates a dashed line mesh
  61849. * * 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
  61850. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61851. * * The parameter `points` is an array successive Vector3
  61852. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61853. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61854. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61855. * * 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
  61856. * * When updating an instance, remember that only point positions can change, not the number of points
  61857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61858. * @param name defines the name of the mesh
  61859. * @param options defines the options used to create the mesh
  61860. * @param scene defines the hosting scene
  61861. * @returns the dashed line mesh
  61862. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61863. */
  61864. static CreateDashedLines(name: string, options: {
  61865. points: Vector3[];
  61866. dashSize?: number;
  61867. gapSize?: number;
  61868. dashNb?: number;
  61869. updatable?: boolean;
  61870. instance?: LinesMesh;
  61871. }, scene?: Nullable<Scene>): LinesMesh;
  61872. /**
  61873. * 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.
  61874. * * 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.
  61875. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61876. * * 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.
  61877. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61878. * * 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
  61879. * * 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
  61880. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61882. * * 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
  61883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61885. * @param name defines the name of the mesh
  61886. * @param options defines the options used to create the mesh
  61887. * @param scene defines the hosting scene
  61888. * @returns the extruded shape mesh
  61889. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61891. */
  61892. static ExtrudeShape(name: string, options: {
  61893. shape: Vector3[];
  61894. path: Vector3[];
  61895. scale?: number;
  61896. rotation?: number;
  61897. cap?: number;
  61898. updatable?: boolean;
  61899. sideOrientation?: number;
  61900. frontUVs?: Vector4;
  61901. backUVs?: Vector4;
  61902. instance?: Mesh;
  61903. invertUV?: boolean;
  61904. }, scene?: Nullable<Scene>): Mesh;
  61905. /**
  61906. * Creates an custom extruded shape mesh.
  61907. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61908. * * 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.
  61909. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61910. * * 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
  61911. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61912. * * 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
  61913. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61914. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61915. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61916. * * 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
  61917. * * 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
  61918. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61920. * * 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
  61921. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61923. * @param name defines the name of the mesh
  61924. * @param options defines the options used to create the mesh
  61925. * @param scene defines the hosting scene
  61926. * @returns the custom extruded shape mesh
  61927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61930. */
  61931. static ExtrudeShapeCustom(name: string, options: {
  61932. shape: Vector3[];
  61933. path: Vector3[];
  61934. scaleFunction?: any;
  61935. rotationFunction?: any;
  61936. ribbonCloseArray?: boolean;
  61937. ribbonClosePath?: boolean;
  61938. cap?: number;
  61939. updatable?: boolean;
  61940. sideOrientation?: number;
  61941. frontUVs?: Vector4;
  61942. backUVs?: Vector4;
  61943. instance?: Mesh;
  61944. invertUV?: boolean;
  61945. }, scene?: Nullable<Scene>): Mesh;
  61946. /**
  61947. * Creates lathe mesh.
  61948. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61949. * * 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
  61950. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61951. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61952. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61953. * * 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
  61954. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61955. * * 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
  61956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61957. * * 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
  61958. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61960. * @param name defines the name of the mesh
  61961. * @param options defines the options used to create the mesh
  61962. * @param scene defines the hosting scene
  61963. * @returns the lathe mesh
  61964. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61965. */
  61966. static CreateLathe(name: string, options: {
  61967. shape: Vector3[];
  61968. radius?: number;
  61969. tessellation?: number;
  61970. clip?: number;
  61971. arc?: number;
  61972. closed?: boolean;
  61973. updatable?: boolean;
  61974. sideOrientation?: number;
  61975. frontUVs?: Vector4;
  61976. backUVs?: Vector4;
  61977. cap?: number;
  61978. invertUV?: boolean;
  61979. }, scene?: Nullable<Scene>): Mesh;
  61980. /**
  61981. * Creates a tiled plane mesh
  61982. * * You can set a limited pattern arrangement with the tiles
  61983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61984. * * 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
  61985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61986. * @param name defines the name of the mesh
  61987. * @param options defines the options used to create the mesh
  61988. * @param scene defines the hosting scene
  61989. * @returns the plane mesh
  61990. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61991. */
  61992. static CreateTiledPlane(name: string, options: {
  61993. pattern?: number;
  61994. tileSize?: number;
  61995. tileWidth?: number;
  61996. tileHeight?: number;
  61997. size?: number;
  61998. width?: number;
  61999. height?: number;
  62000. alignHorizontal?: number;
  62001. alignVertical?: number;
  62002. sideOrientation?: number;
  62003. frontUVs?: Vector4;
  62004. backUVs?: Vector4;
  62005. updatable?: boolean;
  62006. }, scene?: Nullable<Scene>): Mesh;
  62007. /**
  62008. * Creates a plane mesh
  62009. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62010. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62011. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62013. * * 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
  62014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62015. * @param name defines the name of the mesh
  62016. * @param options defines the options used to create the mesh
  62017. * @param scene defines the hosting scene
  62018. * @returns the plane mesh
  62019. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62020. */
  62021. static CreatePlane(name: string, options: {
  62022. size?: number;
  62023. width?: number;
  62024. height?: number;
  62025. sideOrientation?: number;
  62026. frontUVs?: Vector4;
  62027. backUVs?: Vector4;
  62028. updatable?: boolean;
  62029. sourcePlane?: Plane;
  62030. }, scene?: Nullable<Scene>): Mesh;
  62031. /**
  62032. * Creates a ground mesh
  62033. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62034. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62036. * @param name defines the name of the mesh
  62037. * @param options defines the options used to create the mesh
  62038. * @param scene defines the hosting scene
  62039. * @returns the ground mesh
  62040. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62041. */
  62042. static CreateGround(name: string, options: {
  62043. width?: number;
  62044. height?: number;
  62045. subdivisions?: number;
  62046. subdivisionsX?: number;
  62047. subdivisionsY?: number;
  62048. updatable?: boolean;
  62049. }, scene?: Nullable<Scene>): Mesh;
  62050. /**
  62051. * Creates a tiled ground mesh
  62052. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62053. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62054. * * 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
  62055. * * 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
  62056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62057. * @param name defines the name of the mesh
  62058. * @param options defines the options used to create the mesh
  62059. * @param scene defines the hosting scene
  62060. * @returns the tiled ground mesh
  62061. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62062. */
  62063. static CreateTiledGround(name: string, options: {
  62064. xmin: number;
  62065. zmin: number;
  62066. xmax: number;
  62067. zmax: number;
  62068. subdivisions?: {
  62069. w: number;
  62070. h: number;
  62071. };
  62072. precision?: {
  62073. w: number;
  62074. h: number;
  62075. };
  62076. updatable?: boolean;
  62077. }, scene?: Nullable<Scene>): Mesh;
  62078. /**
  62079. * Creates a ground mesh from a height map
  62080. * * The parameter `url` sets the URL of the height map image resource.
  62081. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62082. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62083. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62084. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62085. * * 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.
  62086. * * 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).
  62087. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62089. * @param name defines the name of the mesh
  62090. * @param url defines the url to the height map
  62091. * @param options defines the options used to create the mesh
  62092. * @param scene defines the hosting scene
  62093. * @returns the ground mesh
  62094. * @see https://doc.babylonjs.com/babylon101/height_map
  62095. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62096. */
  62097. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62098. width?: number;
  62099. height?: number;
  62100. subdivisions?: number;
  62101. minHeight?: number;
  62102. maxHeight?: number;
  62103. colorFilter?: Color3;
  62104. alphaFilter?: number;
  62105. updatable?: boolean;
  62106. onReady?: (mesh: GroundMesh) => void;
  62107. }, scene?: Nullable<Scene>): GroundMesh;
  62108. /**
  62109. * Creates a polygon mesh
  62110. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62111. * * 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
  62112. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62114. * * 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)
  62115. * * Remember you can only change the shape positions, not their number when updating a polygon
  62116. * @param name defines the name of the mesh
  62117. * @param options defines the options used to create the mesh
  62118. * @param scene defines the hosting scene
  62119. * @param earcutInjection can be used to inject your own earcut reference
  62120. * @returns the polygon mesh
  62121. */
  62122. static CreatePolygon(name: string, options: {
  62123. shape: Vector3[];
  62124. holes?: Vector3[][];
  62125. depth?: number;
  62126. faceUV?: Vector4[];
  62127. faceColors?: Color4[];
  62128. updatable?: boolean;
  62129. sideOrientation?: number;
  62130. frontUVs?: Vector4;
  62131. backUVs?: Vector4;
  62132. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62133. /**
  62134. * Creates an extruded polygon mesh, with depth in the Y direction.
  62135. * * 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)
  62136. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62137. * @param name defines the name of the mesh
  62138. * @param options defines the options used to create the mesh
  62139. * @param scene defines the hosting scene
  62140. * @param earcutInjection can be used to inject your own earcut reference
  62141. * @returns the polygon mesh
  62142. */
  62143. static ExtrudePolygon(name: string, options: {
  62144. shape: Vector3[];
  62145. holes?: Vector3[][];
  62146. depth?: number;
  62147. faceUV?: Vector4[];
  62148. faceColors?: Color4[];
  62149. updatable?: boolean;
  62150. sideOrientation?: number;
  62151. frontUVs?: Vector4;
  62152. backUVs?: Vector4;
  62153. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62154. /**
  62155. * Creates a tube mesh.
  62156. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62157. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62158. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62159. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62160. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62161. * * 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)
  62162. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62163. * * 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
  62164. * * 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
  62165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62166. * * 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
  62167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62169. * @param name defines the name of the mesh
  62170. * @param options defines the options used to create the mesh
  62171. * @param scene defines the hosting scene
  62172. * @returns the tube mesh
  62173. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62174. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62175. */
  62176. static CreateTube(name: string, options: {
  62177. path: Vector3[];
  62178. radius?: number;
  62179. tessellation?: number;
  62180. radiusFunction?: {
  62181. (i: number, distance: number): number;
  62182. };
  62183. cap?: number;
  62184. arc?: number;
  62185. updatable?: boolean;
  62186. sideOrientation?: number;
  62187. frontUVs?: Vector4;
  62188. backUVs?: Vector4;
  62189. instance?: Mesh;
  62190. invertUV?: boolean;
  62191. }, scene?: Nullable<Scene>): Mesh;
  62192. /**
  62193. * Creates a polyhedron mesh
  62194. * * 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
  62195. * * The parameter `size` (positive float, default 1) sets the polygon size
  62196. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62197. * * 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`
  62198. * * 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
  62199. * * 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)`)
  62200. * * 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
  62201. * * 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
  62202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62203. * * 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
  62204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62205. * @param name defines the name of the mesh
  62206. * @param options defines the options used to create the mesh
  62207. * @param scene defines the hosting scene
  62208. * @returns the polyhedron mesh
  62209. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62210. */
  62211. static CreatePolyhedron(name: string, options: {
  62212. type?: number;
  62213. size?: number;
  62214. sizeX?: number;
  62215. sizeY?: number;
  62216. sizeZ?: number;
  62217. custom?: any;
  62218. faceUV?: Vector4[];
  62219. faceColors?: Color4[];
  62220. flat?: boolean;
  62221. updatable?: boolean;
  62222. sideOrientation?: number;
  62223. frontUVs?: Vector4;
  62224. backUVs?: Vector4;
  62225. }, scene?: Nullable<Scene>): Mesh;
  62226. /**
  62227. * Creates a decal mesh.
  62228. * 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
  62229. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62230. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62231. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62232. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62233. * @param name defines the name of the mesh
  62234. * @param sourceMesh defines the mesh where the decal must be applied
  62235. * @param options defines the options used to create the mesh
  62236. * @param scene defines the hosting scene
  62237. * @returns the decal mesh
  62238. * @see https://doc.babylonjs.com/how_to/decals
  62239. */
  62240. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62241. position?: Vector3;
  62242. normal?: Vector3;
  62243. size?: Vector3;
  62244. angle?: number;
  62245. }): Mesh;
  62246. }
  62247. }
  62248. declare module BABYLON {
  62249. /**
  62250. * A simplifier interface for future simplification implementations
  62251. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62252. */
  62253. export interface ISimplifier {
  62254. /**
  62255. * Simplification of a given mesh according to the given settings.
  62256. * Since this requires computation, it is assumed that the function runs async.
  62257. * @param settings The settings of the simplification, including quality and distance
  62258. * @param successCallback A callback that will be called after the mesh was simplified.
  62259. * @param errorCallback in case of an error, this callback will be called. optional.
  62260. */
  62261. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62262. }
  62263. /**
  62264. * Expected simplification settings.
  62265. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62266. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62267. */
  62268. export interface ISimplificationSettings {
  62269. /**
  62270. * Gets or sets the expected quality
  62271. */
  62272. quality: number;
  62273. /**
  62274. * Gets or sets the distance when this optimized version should be used
  62275. */
  62276. distance: number;
  62277. /**
  62278. * Gets an already optimized mesh
  62279. */
  62280. optimizeMesh?: boolean;
  62281. }
  62282. /**
  62283. * Class used to specify simplification options
  62284. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62285. */
  62286. export class SimplificationSettings implements ISimplificationSettings {
  62287. /** expected quality */
  62288. quality: number;
  62289. /** distance when this optimized version should be used */
  62290. distance: number;
  62291. /** already optimized mesh */
  62292. optimizeMesh?: boolean | undefined;
  62293. /**
  62294. * Creates a SimplificationSettings
  62295. * @param quality expected quality
  62296. * @param distance distance when this optimized version should be used
  62297. * @param optimizeMesh already optimized mesh
  62298. */
  62299. constructor(
  62300. /** expected quality */
  62301. quality: number,
  62302. /** distance when this optimized version should be used */
  62303. distance: number,
  62304. /** already optimized mesh */
  62305. optimizeMesh?: boolean | undefined);
  62306. }
  62307. /**
  62308. * Interface used to define a simplification task
  62309. */
  62310. export interface ISimplificationTask {
  62311. /**
  62312. * Array of settings
  62313. */
  62314. settings: Array<ISimplificationSettings>;
  62315. /**
  62316. * Simplification type
  62317. */
  62318. simplificationType: SimplificationType;
  62319. /**
  62320. * Mesh to simplify
  62321. */
  62322. mesh: Mesh;
  62323. /**
  62324. * Callback called on success
  62325. */
  62326. successCallback?: () => void;
  62327. /**
  62328. * Defines if parallel processing can be used
  62329. */
  62330. parallelProcessing: boolean;
  62331. }
  62332. /**
  62333. * Queue used to order the simplification tasks
  62334. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62335. */
  62336. export class SimplificationQueue {
  62337. private _simplificationArray;
  62338. /**
  62339. * Gets a boolean indicating that the process is still running
  62340. */
  62341. running: boolean;
  62342. /**
  62343. * Creates a new queue
  62344. */
  62345. constructor();
  62346. /**
  62347. * Adds a new simplification task
  62348. * @param task defines a task to add
  62349. */
  62350. addTask(task: ISimplificationTask): void;
  62351. /**
  62352. * Execute next task
  62353. */
  62354. executeNext(): void;
  62355. /**
  62356. * Execute a simplification task
  62357. * @param task defines the task to run
  62358. */
  62359. runSimplification(task: ISimplificationTask): void;
  62360. private getSimplifier;
  62361. }
  62362. /**
  62363. * The implemented types of simplification
  62364. * At the moment only Quadratic Error Decimation is implemented
  62365. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62366. */
  62367. export enum SimplificationType {
  62368. /** Quadratic error decimation */
  62369. QUADRATIC = 0
  62370. }
  62371. /**
  62372. * An implementation of the Quadratic Error simplification algorithm.
  62373. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62374. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62375. * @author RaananW
  62376. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62377. */
  62378. export class QuadraticErrorSimplification implements ISimplifier {
  62379. private _mesh;
  62380. private triangles;
  62381. private vertices;
  62382. private references;
  62383. private _reconstructedMesh;
  62384. /** Gets or sets the number pf sync interations */
  62385. syncIterations: number;
  62386. /** Gets or sets the aggressiveness of the simplifier */
  62387. aggressiveness: number;
  62388. /** Gets or sets the number of allowed iterations for decimation */
  62389. decimationIterations: number;
  62390. /** Gets or sets the espilon to use for bounding box computation */
  62391. boundingBoxEpsilon: number;
  62392. /**
  62393. * Creates a new QuadraticErrorSimplification
  62394. * @param _mesh defines the target mesh
  62395. */
  62396. constructor(_mesh: Mesh);
  62397. /**
  62398. * Simplification of a given mesh according to the given settings.
  62399. * Since this requires computation, it is assumed that the function runs async.
  62400. * @param settings The settings of the simplification, including quality and distance
  62401. * @param successCallback A callback that will be called after the mesh was simplified.
  62402. */
  62403. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62404. private runDecimation;
  62405. private initWithMesh;
  62406. private init;
  62407. private reconstructMesh;
  62408. private initDecimatedMesh;
  62409. private isFlipped;
  62410. private updateTriangles;
  62411. private identifyBorder;
  62412. private updateMesh;
  62413. private vertexError;
  62414. private calculateError;
  62415. }
  62416. }
  62417. declare module BABYLON {
  62418. interface Scene {
  62419. /** @hidden (Backing field) */
  62420. _simplificationQueue: SimplificationQueue;
  62421. /**
  62422. * Gets or sets the simplification queue attached to the scene
  62423. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62424. */
  62425. simplificationQueue: SimplificationQueue;
  62426. }
  62427. interface Mesh {
  62428. /**
  62429. * Simplify the mesh according to the given array of settings.
  62430. * Function will return immediately and will simplify async
  62431. * @param settings a collection of simplification settings
  62432. * @param parallelProcessing should all levels calculate parallel or one after the other
  62433. * @param simplificationType the type of simplification to run
  62434. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62435. * @returns the current mesh
  62436. */
  62437. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62438. }
  62439. /**
  62440. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62441. * created in a scene
  62442. */
  62443. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62444. /**
  62445. * The component name helpfull to identify the component in the list of scene components.
  62446. */
  62447. readonly name: string;
  62448. /**
  62449. * The scene the component belongs to.
  62450. */
  62451. scene: Scene;
  62452. /**
  62453. * Creates a new instance of the component for the given scene
  62454. * @param scene Defines the scene to register the component in
  62455. */
  62456. constructor(scene: Scene);
  62457. /**
  62458. * Registers the component in a given scene
  62459. */
  62460. register(): void;
  62461. /**
  62462. * Rebuilds the elements related to this component in case of
  62463. * context lost for instance.
  62464. */
  62465. rebuild(): void;
  62466. /**
  62467. * Disposes the component and the associated ressources
  62468. */
  62469. dispose(): void;
  62470. private _beforeCameraUpdate;
  62471. }
  62472. }
  62473. declare module BABYLON {
  62474. /**
  62475. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62476. */
  62477. export interface INavigationEnginePlugin {
  62478. /**
  62479. * plugin name
  62480. */
  62481. name: string;
  62482. /**
  62483. * Creates a navigation mesh
  62484. * @param meshes array of all the geometry used to compute the navigatio mesh
  62485. * @param parameters bunch of parameters used to filter geometry
  62486. */
  62487. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62488. /**
  62489. * Create a navigation mesh debug mesh
  62490. * @param scene is where the mesh will be added
  62491. * @returns debug display mesh
  62492. */
  62493. createDebugNavMesh(scene: Scene): Mesh;
  62494. /**
  62495. * Get a navigation mesh constrained position, closest to the parameter position
  62496. * @param position world position
  62497. * @returns the closest point to position constrained by the navigation mesh
  62498. */
  62499. getClosestPoint(position: Vector3): Vector3;
  62500. /**
  62501. * Get a navigation mesh constrained position, closest to the parameter position
  62502. * @param position world position
  62503. * @param result output the closest point to position constrained by the navigation mesh
  62504. */
  62505. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62506. /**
  62507. * Get a navigation mesh constrained position, within a particular radius
  62508. * @param position world position
  62509. * @param maxRadius the maximum distance to the constrained world position
  62510. * @returns the closest point to position constrained by the navigation mesh
  62511. */
  62512. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62513. /**
  62514. * Get a navigation mesh constrained position, within a particular radius
  62515. * @param position world position
  62516. * @param maxRadius the maximum distance to the constrained world position
  62517. * @param result output the closest point to position constrained by the navigation mesh
  62518. */
  62519. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62520. /**
  62521. * Compute the final position from a segment made of destination-position
  62522. * @param position world position
  62523. * @param destination world position
  62524. * @returns the resulting point along the navmesh
  62525. */
  62526. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62527. /**
  62528. * Compute the final position from a segment made of destination-position
  62529. * @param position world position
  62530. * @param destination world position
  62531. * @param result output the resulting point along the navmesh
  62532. */
  62533. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62534. /**
  62535. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62536. * @param start world position
  62537. * @param end world position
  62538. * @returns array containing world position composing the path
  62539. */
  62540. computePath(start: Vector3, end: Vector3): Vector3[];
  62541. /**
  62542. * If this plugin is supported
  62543. * @returns true if plugin is supported
  62544. */
  62545. isSupported(): boolean;
  62546. /**
  62547. * Create a new Crowd so you can add agents
  62548. * @param maxAgents the maximum agent count in the crowd
  62549. * @param maxAgentRadius the maximum radius an agent can have
  62550. * @param scene to attach the crowd to
  62551. * @returns the crowd you can add agents to
  62552. */
  62553. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62554. /**
  62555. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62556. * The queries will try to find a solution within those bounds
  62557. * default is (1,1,1)
  62558. * @param extent x,y,z value that define the extent around the queries point of reference
  62559. */
  62560. setDefaultQueryExtent(extent: Vector3): void;
  62561. /**
  62562. * Get the Bounding box extent specified by setDefaultQueryExtent
  62563. * @returns the box extent values
  62564. */
  62565. getDefaultQueryExtent(): Vector3;
  62566. /**
  62567. * build the navmesh from a previously saved state using getNavmeshData
  62568. * @param data the Uint8Array returned by getNavmeshData
  62569. */
  62570. buildFromNavmeshData(data: Uint8Array): void;
  62571. /**
  62572. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62573. * @returns data the Uint8Array that can be saved and reused
  62574. */
  62575. getNavmeshData(): Uint8Array;
  62576. /**
  62577. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62578. * @param result output the box extent values
  62579. */
  62580. getDefaultQueryExtentToRef(result: Vector3): void;
  62581. /**
  62582. * Release all resources
  62583. */
  62584. dispose(): void;
  62585. }
  62586. /**
  62587. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62588. */
  62589. export interface ICrowd {
  62590. /**
  62591. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62592. * You can attach anything to that node. The node position is updated in the scene update tick.
  62593. * @param pos world position that will be constrained by the navigation mesh
  62594. * @param parameters agent parameters
  62595. * @param transform hooked to the agent that will be update by the scene
  62596. * @returns agent index
  62597. */
  62598. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62599. /**
  62600. * Returns the agent position in world space
  62601. * @param index agent index returned by addAgent
  62602. * @returns world space position
  62603. */
  62604. getAgentPosition(index: number): Vector3;
  62605. /**
  62606. * Gets the agent position result in world space
  62607. * @param index agent index returned by addAgent
  62608. * @param result output world space position
  62609. */
  62610. getAgentPositionToRef(index: number, result: Vector3): void;
  62611. /**
  62612. * Gets the agent velocity in world space
  62613. * @param index agent index returned by addAgent
  62614. * @returns world space velocity
  62615. */
  62616. getAgentVelocity(index: number): Vector3;
  62617. /**
  62618. * Gets the agent velocity result in world space
  62619. * @param index agent index returned by addAgent
  62620. * @param result output world space velocity
  62621. */
  62622. getAgentVelocityToRef(index: number, result: Vector3): void;
  62623. /**
  62624. * remove a particular agent previously created
  62625. * @param index agent index returned by addAgent
  62626. */
  62627. removeAgent(index: number): void;
  62628. /**
  62629. * get the list of all agents attached to this crowd
  62630. * @returns list of agent indices
  62631. */
  62632. getAgents(): number[];
  62633. /**
  62634. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62635. * @param deltaTime in seconds
  62636. */
  62637. update(deltaTime: number): void;
  62638. /**
  62639. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62640. * @param index agent index returned by addAgent
  62641. * @param destination targeted world position
  62642. */
  62643. agentGoto(index: number, destination: Vector3): void;
  62644. /**
  62645. * Teleport the agent to a new position
  62646. * @param index agent index returned by addAgent
  62647. * @param destination targeted world position
  62648. */
  62649. agentTeleport(index: number, destination: Vector3): void;
  62650. /**
  62651. * Update agent parameters
  62652. * @param index agent index returned by addAgent
  62653. * @param parameters agent parameters
  62654. */
  62655. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62656. /**
  62657. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62658. * The queries will try to find a solution within those bounds
  62659. * default is (1,1,1)
  62660. * @param extent x,y,z value that define the extent around the queries point of reference
  62661. */
  62662. setDefaultQueryExtent(extent: Vector3): void;
  62663. /**
  62664. * Get the Bounding box extent specified by setDefaultQueryExtent
  62665. * @returns the box extent values
  62666. */
  62667. getDefaultQueryExtent(): Vector3;
  62668. /**
  62669. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62670. * @param result output the box extent values
  62671. */
  62672. getDefaultQueryExtentToRef(result: Vector3): void;
  62673. /**
  62674. * Release all resources
  62675. */
  62676. dispose(): void;
  62677. }
  62678. /**
  62679. * Configures an agent
  62680. */
  62681. export interface IAgentParameters {
  62682. /**
  62683. * Agent radius. [Limit: >= 0]
  62684. */
  62685. radius: number;
  62686. /**
  62687. * Agent height. [Limit: > 0]
  62688. */
  62689. height: number;
  62690. /**
  62691. * Maximum allowed acceleration. [Limit: >= 0]
  62692. */
  62693. maxAcceleration: number;
  62694. /**
  62695. * Maximum allowed speed. [Limit: >= 0]
  62696. */
  62697. maxSpeed: number;
  62698. /**
  62699. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62700. */
  62701. collisionQueryRange: number;
  62702. /**
  62703. * The path visibility optimization range. [Limit: > 0]
  62704. */
  62705. pathOptimizationRange: number;
  62706. /**
  62707. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62708. */
  62709. separationWeight: number;
  62710. }
  62711. /**
  62712. * Configures the navigation mesh creation
  62713. */
  62714. export interface INavMeshParameters {
  62715. /**
  62716. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62717. */
  62718. cs: number;
  62719. /**
  62720. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62721. */
  62722. ch: number;
  62723. /**
  62724. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62725. */
  62726. walkableSlopeAngle: number;
  62727. /**
  62728. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62729. * be considered walkable. [Limit: >= 3] [Units: vx]
  62730. */
  62731. walkableHeight: number;
  62732. /**
  62733. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62734. */
  62735. walkableClimb: number;
  62736. /**
  62737. * The distance to erode/shrink the walkable area of the heightfield away from
  62738. * obstructions. [Limit: >=0] [Units: vx]
  62739. */
  62740. walkableRadius: number;
  62741. /**
  62742. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62743. */
  62744. maxEdgeLen: number;
  62745. /**
  62746. * The maximum distance a simplfied contour's border edges should deviate
  62747. * the original raw contour. [Limit: >=0] [Units: vx]
  62748. */
  62749. maxSimplificationError: number;
  62750. /**
  62751. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62752. */
  62753. minRegionArea: number;
  62754. /**
  62755. * Any regions with a span count smaller than this value will, if possible,
  62756. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62757. */
  62758. mergeRegionArea: number;
  62759. /**
  62760. * The maximum number of vertices allowed for polygons generated during the
  62761. * contour to polygon conversion process. [Limit: >= 3]
  62762. */
  62763. maxVertsPerPoly: number;
  62764. /**
  62765. * Sets the sampling distance to use when generating the detail mesh.
  62766. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62767. */
  62768. detailSampleDist: number;
  62769. /**
  62770. * The maximum distance the detail mesh surface should deviate from heightfield
  62771. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62772. */
  62773. detailSampleMaxError: number;
  62774. }
  62775. }
  62776. declare module BABYLON {
  62777. /**
  62778. * RecastJS navigation plugin
  62779. */
  62780. export class RecastJSPlugin implements INavigationEnginePlugin {
  62781. /**
  62782. * Reference to the Recast library
  62783. */
  62784. bjsRECAST: any;
  62785. /**
  62786. * plugin name
  62787. */
  62788. name: string;
  62789. /**
  62790. * the first navmesh created. We might extend this to support multiple navmeshes
  62791. */
  62792. navMesh: any;
  62793. /**
  62794. * Initializes the recastJS plugin
  62795. * @param recastInjection can be used to inject your own recast reference
  62796. */
  62797. constructor(recastInjection?: any);
  62798. /**
  62799. * Creates a navigation mesh
  62800. * @param meshes array of all the geometry used to compute the navigatio mesh
  62801. * @param parameters bunch of parameters used to filter geometry
  62802. */
  62803. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62804. /**
  62805. * Create a navigation mesh debug mesh
  62806. * @param scene is where the mesh will be added
  62807. * @returns debug display mesh
  62808. */
  62809. createDebugNavMesh(scene: Scene): Mesh;
  62810. /**
  62811. * Get a navigation mesh constrained position, closest to the parameter position
  62812. * @param position world position
  62813. * @returns the closest point to position constrained by the navigation mesh
  62814. */
  62815. getClosestPoint(position: Vector3): Vector3;
  62816. /**
  62817. * Get a navigation mesh constrained position, closest to the parameter position
  62818. * @param position world position
  62819. * @param result output the closest point to position constrained by the navigation mesh
  62820. */
  62821. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62822. /**
  62823. * Get a navigation mesh constrained position, within a particular radius
  62824. * @param position world position
  62825. * @param maxRadius the maximum distance to the constrained world position
  62826. * @returns the closest point to position constrained by the navigation mesh
  62827. */
  62828. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62829. /**
  62830. * Get a navigation mesh constrained position, within a particular radius
  62831. * @param position world position
  62832. * @param maxRadius the maximum distance to the constrained world position
  62833. * @param result output the closest point to position constrained by the navigation mesh
  62834. */
  62835. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62836. /**
  62837. * Compute the final position from a segment made of destination-position
  62838. * @param position world position
  62839. * @param destination world position
  62840. * @returns the resulting point along the navmesh
  62841. */
  62842. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62843. /**
  62844. * Compute the final position from a segment made of destination-position
  62845. * @param position world position
  62846. * @param destination world position
  62847. * @param result output the resulting point along the navmesh
  62848. */
  62849. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62850. /**
  62851. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62852. * @param start world position
  62853. * @param end world position
  62854. * @returns array containing world position composing the path
  62855. */
  62856. computePath(start: Vector3, end: Vector3): Vector3[];
  62857. /**
  62858. * Create a new Crowd so you can add agents
  62859. * @param maxAgents the maximum agent count in the crowd
  62860. * @param maxAgentRadius the maximum radius an agent can have
  62861. * @param scene to attach the crowd to
  62862. * @returns the crowd you can add agents to
  62863. */
  62864. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62865. /**
  62866. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62867. * The queries will try to find a solution within those bounds
  62868. * default is (1,1,1)
  62869. * @param extent x,y,z value that define the extent around the queries point of reference
  62870. */
  62871. setDefaultQueryExtent(extent: Vector3): void;
  62872. /**
  62873. * Get the Bounding box extent specified by setDefaultQueryExtent
  62874. * @returns the box extent values
  62875. */
  62876. getDefaultQueryExtent(): Vector3;
  62877. /**
  62878. * build the navmesh from a previously saved state using getNavmeshData
  62879. * @param data the Uint8Array returned by getNavmeshData
  62880. */
  62881. buildFromNavmeshData(data: Uint8Array): void;
  62882. /**
  62883. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62884. * @returns data the Uint8Array that can be saved and reused
  62885. */
  62886. getNavmeshData(): Uint8Array;
  62887. /**
  62888. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62889. * @param result output the box extent values
  62890. */
  62891. getDefaultQueryExtentToRef(result: Vector3): void;
  62892. /**
  62893. * Disposes
  62894. */
  62895. dispose(): void;
  62896. /**
  62897. * If this plugin is supported
  62898. * @returns true if plugin is supported
  62899. */
  62900. isSupported(): boolean;
  62901. }
  62902. /**
  62903. * Recast detour crowd implementation
  62904. */
  62905. export class RecastJSCrowd implements ICrowd {
  62906. /**
  62907. * Recast/detour plugin
  62908. */
  62909. bjsRECASTPlugin: RecastJSPlugin;
  62910. /**
  62911. * Link to the detour crowd
  62912. */
  62913. recastCrowd: any;
  62914. /**
  62915. * One transform per agent
  62916. */
  62917. transforms: TransformNode[];
  62918. /**
  62919. * All agents created
  62920. */
  62921. agents: number[];
  62922. /**
  62923. * Link to the scene is kept to unregister the crowd from the scene
  62924. */
  62925. private _scene;
  62926. /**
  62927. * Observer for crowd updates
  62928. */
  62929. private _onBeforeAnimationsObserver;
  62930. /**
  62931. * Constructor
  62932. * @param plugin recastJS plugin
  62933. * @param maxAgents the maximum agent count in the crowd
  62934. * @param maxAgentRadius the maximum radius an agent can have
  62935. * @param scene to attach the crowd to
  62936. * @returns the crowd you can add agents to
  62937. */
  62938. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62939. /**
  62940. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62941. * You can attach anything to that node. The node position is updated in the scene update tick.
  62942. * @param pos world position that will be constrained by the navigation mesh
  62943. * @param parameters agent parameters
  62944. * @param transform hooked to the agent that will be update by the scene
  62945. * @returns agent index
  62946. */
  62947. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62948. /**
  62949. * Returns the agent position in world space
  62950. * @param index agent index returned by addAgent
  62951. * @returns world space position
  62952. */
  62953. getAgentPosition(index: number): Vector3;
  62954. /**
  62955. * Returns the agent position result in world space
  62956. * @param index agent index returned by addAgent
  62957. * @param result output world space position
  62958. */
  62959. getAgentPositionToRef(index: number, result: Vector3): void;
  62960. /**
  62961. * Returns the agent velocity in world space
  62962. * @param index agent index returned by addAgent
  62963. * @returns world space velocity
  62964. */
  62965. getAgentVelocity(index: number): Vector3;
  62966. /**
  62967. * Returns the agent velocity result in world space
  62968. * @param index agent index returned by addAgent
  62969. * @param result output world space velocity
  62970. */
  62971. getAgentVelocityToRef(index: number, result: Vector3): void;
  62972. /**
  62973. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62974. * @param index agent index returned by addAgent
  62975. * @param destination targeted world position
  62976. */
  62977. agentGoto(index: number, destination: Vector3): void;
  62978. /**
  62979. * Teleport the agent to a new position
  62980. * @param index agent index returned by addAgent
  62981. * @param destination targeted world position
  62982. */
  62983. agentTeleport(index: number, destination: Vector3): void;
  62984. /**
  62985. * Update agent parameters
  62986. * @param index agent index returned by addAgent
  62987. * @param parameters agent parameters
  62988. */
  62989. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62990. /**
  62991. * remove a particular agent previously created
  62992. * @param index agent index returned by addAgent
  62993. */
  62994. removeAgent(index: number): void;
  62995. /**
  62996. * get the list of all agents attached to this crowd
  62997. * @returns list of agent indices
  62998. */
  62999. getAgents(): number[];
  63000. /**
  63001. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63002. * @param deltaTime in seconds
  63003. */
  63004. update(deltaTime: number): void;
  63005. /**
  63006. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63007. * The queries will try to find a solution within those bounds
  63008. * default is (1,1,1)
  63009. * @param extent x,y,z value that define the extent around the queries point of reference
  63010. */
  63011. setDefaultQueryExtent(extent: Vector3): void;
  63012. /**
  63013. * Get the Bounding box extent specified by setDefaultQueryExtent
  63014. * @returns the box extent values
  63015. */
  63016. getDefaultQueryExtent(): Vector3;
  63017. /**
  63018. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63019. * @param result output the box extent values
  63020. */
  63021. getDefaultQueryExtentToRef(result: Vector3): void;
  63022. /**
  63023. * Release all resources
  63024. */
  63025. dispose(): void;
  63026. }
  63027. }
  63028. declare module BABYLON {
  63029. /**
  63030. * Class used to enable access to IndexedDB
  63031. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63032. */
  63033. export class Database implements IOfflineProvider {
  63034. private _callbackManifestChecked;
  63035. private _currentSceneUrl;
  63036. private _db;
  63037. private _enableSceneOffline;
  63038. private _enableTexturesOffline;
  63039. private _manifestVersionFound;
  63040. private _mustUpdateRessources;
  63041. private _hasReachedQuota;
  63042. private _isSupported;
  63043. private _idbFactory;
  63044. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63045. private static IsUASupportingBlobStorage;
  63046. /**
  63047. * Gets a boolean indicating if Database storate is enabled (off by default)
  63048. */
  63049. static IDBStorageEnabled: boolean;
  63050. /**
  63051. * Gets a boolean indicating if scene must be saved in the database
  63052. */
  63053. get enableSceneOffline(): boolean;
  63054. /**
  63055. * Gets a boolean indicating if textures must be saved in the database
  63056. */
  63057. get enableTexturesOffline(): boolean;
  63058. /**
  63059. * Creates a new Database
  63060. * @param urlToScene defines the url to load the scene
  63061. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63062. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63063. */
  63064. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63065. private static _ParseURL;
  63066. private static _ReturnFullUrlLocation;
  63067. private _checkManifestFile;
  63068. /**
  63069. * Open the database and make it available
  63070. * @param successCallback defines the callback to call on success
  63071. * @param errorCallback defines the callback to call on error
  63072. */
  63073. open(successCallback: () => void, errorCallback: () => void): void;
  63074. /**
  63075. * Loads an image from the database
  63076. * @param url defines the url to load from
  63077. * @param image defines the target DOM image
  63078. */
  63079. loadImage(url: string, image: HTMLImageElement): void;
  63080. private _loadImageFromDBAsync;
  63081. private _saveImageIntoDBAsync;
  63082. private _checkVersionFromDB;
  63083. private _loadVersionFromDBAsync;
  63084. private _saveVersionIntoDBAsync;
  63085. /**
  63086. * Loads a file from database
  63087. * @param url defines the URL to load from
  63088. * @param sceneLoaded defines a callback to call on success
  63089. * @param progressCallBack defines a callback to call when progress changed
  63090. * @param errorCallback defines a callback to call on error
  63091. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63092. */
  63093. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63094. private _loadFileAsync;
  63095. private _saveFileAsync;
  63096. /**
  63097. * Validates if xhr data is correct
  63098. * @param xhr defines the request to validate
  63099. * @param dataType defines the expected data type
  63100. * @returns true if data is correct
  63101. */
  63102. private static _ValidateXHRData;
  63103. }
  63104. }
  63105. declare module BABYLON {
  63106. /** @hidden */
  63107. export var gpuUpdateParticlesPixelShader: {
  63108. name: string;
  63109. shader: string;
  63110. };
  63111. }
  63112. declare module BABYLON {
  63113. /** @hidden */
  63114. export var gpuUpdateParticlesVertexShader: {
  63115. name: string;
  63116. shader: string;
  63117. };
  63118. }
  63119. declare module BABYLON {
  63120. /** @hidden */
  63121. export var clipPlaneFragmentDeclaration2: {
  63122. name: string;
  63123. shader: string;
  63124. };
  63125. }
  63126. declare module BABYLON {
  63127. /** @hidden */
  63128. export var gpuRenderParticlesPixelShader: {
  63129. name: string;
  63130. shader: string;
  63131. };
  63132. }
  63133. declare module BABYLON {
  63134. /** @hidden */
  63135. export var clipPlaneVertexDeclaration2: {
  63136. name: string;
  63137. shader: string;
  63138. };
  63139. }
  63140. declare module BABYLON {
  63141. /** @hidden */
  63142. export var gpuRenderParticlesVertexShader: {
  63143. name: string;
  63144. shader: string;
  63145. };
  63146. }
  63147. declare module BABYLON {
  63148. /**
  63149. * This represents a GPU particle system in Babylon
  63150. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63151. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63152. */
  63153. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63154. /**
  63155. * The layer mask we are rendering the particles through.
  63156. */
  63157. layerMask: number;
  63158. private _capacity;
  63159. private _activeCount;
  63160. private _currentActiveCount;
  63161. private _accumulatedCount;
  63162. private _renderEffect;
  63163. private _updateEffect;
  63164. private _buffer0;
  63165. private _buffer1;
  63166. private _spriteBuffer;
  63167. private _updateVAO;
  63168. private _renderVAO;
  63169. private _targetIndex;
  63170. private _sourceBuffer;
  63171. private _targetBuffer;
  63172. private _engine;
  63173. private _currentRenderId;
  63174. private _started;
  63175. private _stopped;
  63176. private _timeDelta;
  63177. private _randomTexture;
  63178. private _randomTexture2;
  63179. private _attributesStrideSize;
  63180. private _updateEffectOptions;
  63181. private _randomTextureSize;
  63182. private _actualFrame;
  63183. private readonly _rawTextureWidth;
  63184. /**
  63185. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63186. */
  63187. static get IsSupported(): boolean;
  63188. /**
  63189. * An event triggered when the system is disposed.
  63190. */
  63191. onDisposeObservable: Observable<GPUParticleSystem>;
  63192. /**
  63193. * Gets the maximum number of particles active at the same time.
  63194. * @returns The max number of active particles.
  63195. */
  63196. getCapacity(): number;
  63197. /**
  63198. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63199. * to override the particles.
  63200. */
  63201. forceDepthWrite: boolean;
  63202. /**
  63203. * Gets or set the number of active particles
  63204. */
  63205. get activeParticleCount(): number;
  63206. set activeParticleCount(value: number);
  63207. private _preWarmDone;
  63208. /**
  63209. * Specifies if the particles are updated in emitter local space or world space.
  63210. * This is always false for GPU particles
  63211. */
  63212. get isLocal(): boolean;
  63213. set isLocal(value: boolean);
  63214. /**
  63215. * Is this system ready to be used/rendered
  63216. * @return true if the system is ready
  63217. */
  63218. isReady(): boolean;
  63219. /**
  63220. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63221. * @returns True if it has been started, otherwise false.
  63222. */
  63223. isStarted(): boolean;
  63224. /**
  63225. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63226. * @returns True if it has been stopped, otherwise false.
  63227. */
  63228. isStopped(): boolean;
  63229. /**
  63230. * Gets a boolean indicating that the system is stopping
  63231. * @returns true if the system is currently stopping
  63232. */
  63233. isStopping(): boolean;
  63234. /**
  63235. * Gets the number of particles active at the same time.
  63236. * @returns The number of active particles.
  63237. */
  63238. getActiveCount(): number;
  63239. /**
  63240. * Starts the particle system and begins to emit
  63241. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63242. */
  63243. start(delay?: number): void;
  63244. /**
  63245. * Stops the particle system.
  63246. */
  63247. stop(): void;
  63248. /**
  63249. * Remove all active particles
  63250. */
  63251. reset(): void;
  63252. /**
  63253. * Returns the string "GPUParticleSystem"
  63254. * @returns a string containing the class name
  63255. */
  63256. getClassName(): string;
  63257. private _colorGradientsTexture;
  63258. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63259. /**
  63260. * Adds a new color gradient
  63261. * @param gradient defines the gradient to use (between 0 and 1)
  63262. * @param color1 defines the color to affect to the specified gradient
  63263. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63264. * @returns the current particle system
  63265. */
  63266. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63267. private _refreshColorGradient;
  63268. /** Force the system to rebuild all gradients that need to be resync */
  63269. forceRefreshGradients(): void;
  63270. /**
  63271. * Remove a specific color gradient
  63272. * @param gradient defines the gradient to remove
  63273. * @returns the current particle system
  63274. */
  63275. removeColorGradient(gradient: number): GPUParticleSystem;
  63276. private _angularSpeedGradientsTexture;
  63277. private _sizeGradientsTexture;
  63278. private _velocityGradientsTexture;
  63279. private _limitVelocityGradientsTexture;
  63280. private _dragGradientsTexture;
  63281. private _addFactorGradient;
  63282. /**
  63283. * Adds a new size gradient
  63284. * @param gradient defines the gradient to use (between 0 and 1)
  63285. * @param factor defines the size factor to affect to the specified gradient
  63286. * @returns the current particle system
  63287. */
  63288. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63289. /**
  63290. * Remove a specific size gradient
  63291. * @param gradient defines the gradient to remove
  63292. * @returns the current particle system
  63293. */
  63294. removeSizeGradient(gradient: number): GPUParticleSystem;
  63295. private _refreshFactorGradient;
  63296. /**
  63297. * Adds a new angular speed gradient
  63298. * @param gradient defines the gradient to use (between 0 and 1)
  63299. * @param factor defines the angular speed to affect to the specified gradient
  63300. * @returns the current particle system
  63301. */
  63302. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63303. /**
  63304. * Remove a specific angular speed gradient
  63305. * @param gradient defines the gradient to remove
  63306. * @returns the current particle system
  63307. */
  63308. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63309. /**
  63310. * Adds a new velocity gradient
  63311. * @param gradient defines the gradient to use (between 0 and 1)
  63312. * @param factor defines the velocity to affect to the specified gradient
  63313. * @returns the current particle system
  63314. */
  63315. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63316. /**
  63317. * Remove a specific velocity gradient
  63318. * @param gradient defines the gradient to remove
  63319. * @returns the current particle system
  63320. */
  63321. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63322. /**
  63323. * Adds a new limit velocity gradient
  63324. * @param gradient defines the gradient to use (between 0 and 1)
  63325. * @param factor defines the limit velocity value to affect to the specified gradient
  63326. * @returns the current particle system
  63327. */
  63328. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63329. /**
  63330. * Remove a specific limit velocity gradient
  63331. * @param gradient defines the gradient to remove
  63332. * @returns the current particle system
  63333. */
  63334. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63335. /**
  63336. * Adds a new drag gradient
  63337. * @param gradient defines the gradient to use (between 0 and 1)
  63338. * @param factor defines the drag value to affect to the specified gradient
  63339. * @returns the current particle system
  63340. */
  63341. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63342. /**
  63343. * Remove a specific drag gradient
  63344. * @param gradient defines the gradient to remove
  63345. * @returns the current particle system
  63346. */
  63347. removeDragGradient(gradient: number): GPUParticleSystem;
  63348. /**
  63349. * Not supported by GPUParticleSystem
  63350. * @param gradient defines the gradient to use (between 0 and 1)
  63351. * @param factor defines the emit rate value to affect to the specified gradient
  63352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63353. * @returns the current particle system
  63354. */
  63355. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63356. /**
  63357. * Not supported by GPUParticleSystem
  63358. * @param gradient defines the gradient to remove
  63359. * @returns the current particle system
  63360. */
  63361. removeEmitRateGradient(gradient: number): IParticleSystem;
  63362. /**
  63363. * Not supported by GPUParticleSystem
  63364. * @param gradient defines the gradient to use (between 0 and 1)
  63365. * @param factor defines the start size value to affect to the specified gradient
  63366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63367. * @returns the current particle system
  63368. */
  63369. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63370. /**
  63371. * Not supported by GPUParticleSystem
  63372. * @param gradient defines the gradient to remove
  63373. * @returns the current particle system
  63374. */
  63375. removeStartSizeGradient(gradient: number): IParticleSystem;
  63376. /**
  63377. * Not supported by GPUParticleSystem
  63378. * @param gradient defines the gradient to use (between 0 and 1)
  63379. * @param min defines the color remap minimal range
  63380. * @param max defines the color remap maximal range
  63381. * @returns the current particle system
  63382. */
  63383. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63384. /**
  63385. * Not supported by GPUParticleSystem
  63386. * @param gradient defines the gradient to remove
  63387. * @returns the current particle system
  63388. */
  63389. removeColorRemapGradient(): IParticleSystem;
  63390. /**
  63391. * Not supported by GPUParticleSystem
  63392. * @param gradient defines the gradient to use (between 0 and 1)
  63393. * @param min defines the alpha remap minimal range
  63394. * @param max defines the alpha remap maximal range
  63395. * @returns the current particle system
  63396. */
  63397. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63398. /**
  63399. * Not supported by GPUParticleSystem
  63400. * @param gradient defines the gradient to remove
  63401. * @returns the current particle system
  63402. */
  63403. removeAlphaRemapGradient(): IParticleSystem;
  63404. /**
  63405. * Not supported by GPUParticleSystem
  63406. * @param gradient defines the gradient to use (between 0 and 1)
  63407. * @param color defines the color to affect to the specified gradient
  63408. * @returns the current particle system
  63409. */
  63410. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63411. /**
  63412. * Not supported by GPUParticleSystem
  63413. * @param gradient defines the gradient to remove
  63414. * @returns the current particle system
  63415. */
  63416. removeRampGradient(): IParticleSystem;
  63417. /**
  63418. * Not supported by GPUParticleSystem
  63419. * @returns the list of ramp gradients
  63420. */
  63421. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63422. /**
  63423. * Not supported by GPUParticleSystem
  63424. * Gets or sets a boolean indicating that ramp gradients must be used
  63425. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63426. */
  63427. get useRampGradients(): boolean;
  63428. set useRampGradients(value: boolean);
  63429. /**
  63430. * Not supported by GPUParticleSystem
  63431. * @param gradient defines the gradient to use (between 0 and 1)
  63432. * @param factor defines the life time factor to affect to the specified gradient
  63433. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63434. * @returns the current particle system
  63435. */
  63436. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63437. /**
  63438. * Not supported by GPUParticleSystem
  63439. * @param gradient defines the gradient to remove
  63440. * @returns the current particle system
  63441. */
  63442. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63443. /**
  63444. * Instantiates a GPU particle system.
  63445. * 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.
  63446. * @param name The name of the particle system
  63447. * @param options The options used to create the system
  63448. * @param scene The scene the particle system belongs to
  63449. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63450. */
  63451. constructor(name: string, options: Partial<{
  63452. capacity: number;
  63453. randomTextureSize: number;
  63454. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63455. protected _reset(): void;
  63456. private _createUpdateVAO;
  63457. private _createRenderVAO;
  63458. private _initialize;
  63459. /** @hidden */
  63460. _recreateUpdateEffect(): void;
  63461. /** @hidden */
  63462. _recreateRenderEffect(): void;
  63463. /**
  63464. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63465. * @param preWarm defines if we are in the pre-warmimg phase
  63466. */
  63467. animate(preWarm?: boolean): void;
  63468. private _createFactorGradientTexture;
  63469. private _createSizeGradientTexture;
  63470. private _createAngularSpeedGradientTexture;
  63471. private _createVelocityGradientTexture;
  63472. private _createLimitVelocityGradientTexture;
  63473. private _createDragGradientTexture;
  63474. private _createColorGradientTexture;
  63475. /**
  63476. * Renders the particle system in its current state
  63477. * @param preWarm defines if the system should only update the particles but not render them
  63478. * @returns the current number of particles
  63479. */
  63480. render(preWarm?: boolean): number;
  63481. /**
  63482. * Rebuilds the particle system
  63483. */
  63484. rebuild(): void;
  63485. private _releaseBuffers;
  63486. private _releaseVAOs;
  63487. /**
  63488. * Disposes the particle system and free the associated resources
  63489. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63490. */
  63491. dispose(disposeTexture?: boolean): void;
  63492. /**
  63493. * Clones the particle system.
  63494. * @param name The name of the cloned object
  63495. * @param newEmitter The new emitter to use
  63496. * @returns the cloned particle system
  63497. */
  63498. clone(name: string, newEmitter: any): GPUParticleSystem;
  63499. /**
  63500. * Serializes the particle system to a JSON object
  63501. * @param serializeTexture defines if the texture must be serialized as well
  63502. * @returns the JSON object
  63503. */
  63504. serialize(serializeTexture?: boolean): any;
  63505. /**
  63506. * Parses a JSON object to create a GPU particle system.
  63507. * @param parsedParticleSystem The JSON object to parse
  63508. * @param scene The scene to create the particle system in
  63509. * @param rootUrl The root url to use to load external dependencies like texture
  63510. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63511. * @returns the parsed GPU particle system
  63512. */
  63513. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63514. }
  63515. }
  63516. declare module BABYLON {
  63517. /**
  63518. * Represents a set of particle systems working together to create a specific effect
  63519. */
  63520. export class ParticleSystemSet implements IDisposable {
  63521. /**
  63522. * Gets or sets base Assets URL
  63523. */
  63524. static BaseAssetsUrl: string;
  63525. private _emitterCreationOptions;
  63526. private _emitterNode;
  63527. /**
  63528. * Gets the particle system list
  63529. */
  63530. systems: IParticleSystem[];
  63531. /**
  63532. * Gets the emitter node used with this set
  63533. */
  63534. get emitterNode(): Nullable<TransformNode>;
  63535. /**
  63536. * Creates a new emitter mesh as a sphere
  63537. * @param options defines the options used to create the sphere
  63538. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63539. * @param scene defines the hosting scene
  63540. */
  63541. setEmitterAsSphere(options: {
  63542. diameter: number;
  63543. segments: number;
  63544. color: Color3;
  63545. }, renderingGroupId: number, scene: Scene): void;
  63546. /**
  63547. * Starts all particle systems of the set
  63548. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63549. */
  63550. start(emitter?: AbstractMesh): void;
  63551. /**
  63552. * Release all associated resources
  63553. */
  63554. dispose(): void;
  63555. /**
  63556. * Serialize the set into a JSON compatible object
  63557. * @param serializeTexture defines if the texture must be serialized as well
  63558. * @returns a JSON compatible representation of the set
  63559. */
  63560. serialize(serializeTexture?: boolean): any;
  63561. /**
  63562. * Parse a new ParticleSystemSet from a serialized source
  63563. * @param data defines a JSON compatible representation of the set
  63564. * @param scene defines the hosting scene
  63565. * @param gpu defines if we want GPU particles or CPU particles
  63566. * @returns a new ParticleSystemSet
  63567. */
  63568. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63569. }
  63570. }
  63571. declare module BABYLON {
  63572. /**
  63573. * This class is made for on one-liner static method to help creating particle system set.
  63574. */
  63575. export class ParticleHelper {
  63576. /**
  63577. * Gets or sets base Assets URL
  63578. */
  63579. static BaseAssetsUrl: string;
  63580. /** Define the Url to load snippets */
  63581. static SnippetUrl: string;
  63582. /**
  63583. * Create a default particle system that you can tweak
  63584. * @param emitter defines the emitter to use
  63585. * @param capacity defines the system capacity (default is 500 particles)
  63586. * @param scene defines the hosting scene
  63587. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63588. * @returns the new Particle system
  63589. */
  63590. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63591. /**
  63592. * This is the main static method (one-liner) of this helper to create different particle systems
  63593. * @param type This string represents the type to the particle system to create
  63594. * @param scene The scene where the particle system should live
  63595. * @param gpu If the system will use gpu
  63596. * @returns the ParticleSystemSet created
  63597. */
  63598. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63599. /**
  63600. * Static function used to export a particle system to a ParticleSystemSet variable.
  63601. * Please note that the emitter shape is not exported
  63602. * @param systems defines the particle systems to export
  63603. * @returns the created particle system set
  63604. */
  63605. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63606. /**
  63607. * Creates a particle system from a snippet saved in a remote file
  63608. * @param name defines the name of the particle system to create
  63609. * @param url defines the url to load from
  63610. * @param scene defines the hosting scene
  63611. * @param gpu If the system will use gpu
  63612. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63613. * @returns a promise that will resolve to the new particle system
  63614. */
  63615. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63616. /**
  63617. * Creates a particle system from a snippet saved by the particle system editor
  63618. * @param snippetId defines the snippet to load
  63619. * @param scene defines the hosting scene
  63620. * @param gpu If the system will use gpu
  63621. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63622. * @returns a promise that will resolve to the new particle system
  63623. */
  63624. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63625. }
  63626. }
  63627. declare module BABYLON {
  63628. interface Engine {
  63629. /**
  63630. * Create an effect to use with particle systems.
  63631. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63632. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63633. * @param uniformsNames defines a list of attribute names
  63634. * @param samplers defines an array of string used to represent textures
  63635. * @param defines defines the string containing the defines to use to compile the shaders
  63636. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63637. * @param onCompiled defines a function to call when the effect creation is successful
  63638. * @param onError defines a function to call when the effect creation has failed
  63639. * @returns the new Effect
  63640. */
  63641. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63642. }
  63643. interface Mesh {
  63644. /**
  63645. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63646. * @returns an array of IParticleSystem
  63647. */
  63648. getEmittedParticleSystems(): IParticleSystem[];
  63649. /**
  63650. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63651. * @returns an array of IParticleSystem
  63652. */
  63653. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63654. }
  63655. /**
  63656. * @hidden
  63657. */
  63658. export var _IDoNeedToBeInTheBuild: number;
  63659. }
  63660. declare module BABYLON {
  63661. /** Defines the 4 color options */
  63662. export enum PointColor {
  63663. /** color value */
  63664. Color = 2,
  63665. /** uv value */
  63666. UV = 1,
  63667. /** random value */
  63668. Random = 0,
  63669. /** stated value */
  63670. Stated = 3
  63671. }
  63672. /**
  63673. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63674. * 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.
  63675. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63676. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63677. *
  63678. * Full documentation here : TO BE ENTERED
  63679. */
  63680. export class PointsCloudSystem implements IDisposable {
  63681. /**
  63682. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63683. * Example : var p = SPS.particles[i];
  63684. */
  63685. particles: CloudPoint[];
  63686. /**
  63687. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63688. */
  63689. nbParticles: number;
  63690. /**
  63691. * This a counter for your own usage. It's not set by any SPS functions.
  63692. */
  63693. counter: number;
  63694. /**
  63695. * The PCS name. This name is also given to the underlying mesh.
  63696. */
  63697. name: string;
  63698. /**
  63699. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63700. */
  63701. mesh: Mesh;
  63702. /**
  63703. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63704. * Please read :
  63705. */
  63706. vars: any;
  63707. /**
  63708. * @hidden
  63709. */
  63710. _size: number;
  63711. private _scene;
  63712. private _promises;
  63713. private _positions;
  63714. private _indices;
  63715. private _normals;
  63716. private _colors;
  63717. private _uvs;
  63718. private _indices32;
  63719. private _positions32;
  63720. private _colors32;
  63721. private _uvs32;
  63722. private _updatable;
  63723. private _isVisibilityBoxLocked;
  63724. private _alwaysVisible;
  63725. private _groups;
  63726. private _groupCounter;
  63727. private _computeParticleColor;
  63728. private _computeParticleTexture;
  63729. private _computeParticleRotation;
  63730. private _computeBoundingBox;
  63731. private _isReady;
  63732. /**
  63733. * Creates a PCS (Points Cloud System) object
  63734. * @param name (String) is the PCS name, this will be the underlying mesh name
  63735. * @param pointSize (number) is the size for each point
  63736. * @param scene (Scene) is the scene in which the PCS is added
  63737. * @param options defines the options of the PCS e.g.
  63738. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63739. */
  63740. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63741. updatable?: boolean;
  63742. });
  63743. /**
  63744. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63745. * If no points were added to the PCS, the returned mesh is just a single point.
  63746. * @returns a promise for the created mesh
  63747. */
  63748. buildMeshAsync(): Promise<Mesh>;
  63749. /**
  63750. * @hidden
  63751. */
  63752. private _buildMesh;
  63753. private _addParticle;
  63754. private _randomUnitVector;
  63755. private _getColorIndicesForCoord;
  63756. private _setPointsColorOrUV;
  63757. private _colorFromTexture;
  63758. private _calculateDensity;
  63759. /**
  63760. * Adds points to the PCS in random positions within a unit sphere
  63761. * @param nb (positive integer) the number of particles to be created from this model
  63762. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63763. * @returns the number of groups in the system
  63764. */
  63765. addPoints(nb: number, pointFunction?: any): number;
  63766. /**
  63767. * Adds points to the PCS from the surface of the model shape
  63768. * @param mesh is any Mesh object that will be used as a surface model for the points
  63769. * @param nb (positive integer) the number of particles to be created from this model
  63770. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63771. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63772. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63773. * @returns the number of groups in the system
  63774. */
  63775. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63776. /**
  63777. * Adds points to the PCS inside the model shape
  63778. * @param mesh is any Mesh object that will be used as a surface model for the points
  63779. * @param nb (positive integer) the number of particles to be created from this model
  63780. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63781. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63782. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63783. * @returns the number of groups in the system
  63784. */
  63785. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63786. /**
  63787. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63788. * This method calls `updateParticle()` for each particle of the SPS.
  63789. * For an animated SPS, it is usually called within the render loop.
  63790. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63791. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63792. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63793. * @returns the PCS.
  63794. */
  63795. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63796. /**
  63797. * Disposes the PCS.
  63798. */
  63799. dispose(): void;
  63800. /**
  63801. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63802. * doc :
  63803. * @returns the PCS.
  63804. */
  63805. refreshVisibleSize(): PointsCloudSystem;
  63806. /**
  63807. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63808. * @param size the size (float) of the visibility box
  63809. * note : this doesn't lock the PCS mesh bounding box.
  63810. * doc :
  63811. */
  63812. setVisibilityBox(size: number): void;
  63813. /**
  63814. * Gets whether the PCS is always visible or not
  63815. * doc :
  63816. */
  63817. get isAlwaysVisible(): boolean;
  63818. /**
  63819. * Sets the PCS as always visible or not
  63820. * doc :
  63821. */
  63822. set isAlwaysVisible(val: boolean);
  63823. /**
  63824. * Tells to `setParticles()` to compute the particle rotations or not
  63825. * Default value : false. The PCS is faster when it's set to false
  63826. * Note : particle rotations are only applied to parent particles
  63827. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63828. */
  63829. set computeParticleRotation(val: boolean);
  63830. /**
  63831. * Tells to `setParticles()` to compute the particle colors or not.
  63832. * Default value : true. The PCS is faster when it's set to false.
  63833. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63834. */
  63835. set computeParticleColor(val: boolean);
  63836. set computeParticleTexture(val: boolean);
  63837. /**
  63838. * Gets if `setParticles()` computes the particle colors or not.
  63839. * Default value : false. The PCS is faster when it's set to false.
  63840. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63841. */
  63842. get computeParticleColor(): boolean;
  63843. /**
  63844. * Gets if `setParticles()` computes the particle textures or not.
  63845. * Default value : false. The PCS is faster when it's set to false.
  63846. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63847. */
  63848. get computeParticleTexture(): boolean;
  63849. /**
  63850. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63851. */
  63852. set computeBoundingBox(val: boolean);
  63853. /**
  63854. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63855. */
  63856. get computeBoundingBox(): boolean;
  63857. /**
  63858. * This function does nothing. It may be overwritten to set all the particle first values.
  63859. * The PCS doesn't call this function, you may have to call it by your own.
  63860. * doc :
  63861. */
  63862. initParticles(): void;
  63863. /**
  63864. * This function does nothing. It may be overwritten to recycle a particle
  63865. * The PCS doesn't call this function, you can to call it
  63866. * doc :
  63867. * @param particle The particle to recycle
  63868. * @returns the recycled particle
  63869. */
  63870. recycleParticle(particle: CloudPoint): CloudPoint;
  63871. /**
  63872. * Updates a particle : this function should be overwritten by the user.
  63873. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63874. * doc :
  63875. * @example : just set a particle position or velocity and recycle conditions
  63876. * @param particle The particle to update
  63877. * @returns the updated particle
  63878. */
  63879. updateParticle(particle: CloudPoint): CloudPoint;
  63880. /**
  63881. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63882. * This does nothing and may be overwritten by the user.
  63883. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63884. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63885. * @param update the boolean update value actually passed to setParticles()
  63886. */
  63887. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63888. /**
  63889. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63890. * This will be passed three parameters.
  63891. * This does nothing and may be overwritten by the user.
  63892. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63893. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63894. * @param update the boolean update value actually passed to setParticles()
  63895. */
  63896. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63897. }
  63898. }
  63899. declare module BABYLON {
  63900. /**
  63901. * Represents one particle of a points cloud system.
  63902. */
  63903. export class CloudPoint {
  63904. /**
  63905. * particle global index
  63906. */
  63907. idx: number;
  63908. /**
  63909. * The color of the particle
  63910. */
  63911. color: Nullable<Color4>;
  63912. /**
  63913. * The world space position of the particle.
  63914. */
  63915. position: Vector3;
  63916. /**
  63917. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63918. */
  63919. rotation: Vector3;
  63920. /**
  63921. * The world space rotation quaternion of the particle.
  63922. */
  63923. rotationQuaternion: Nullable<Quaternion>;
  63924. /**
  63925. * The uv of the particle.
  63926. */
  63927. uv: Nullable<Vector2>;
  63928. /**
  63929. * The current speed of the particle.
  63930. */
  63931. velocity: Vector3;
  63932. /**
  63933. * The pivot point in the particle local space.
  63934. */
  63935. pivot: Vector3;
  63936. /**
  63937. * Must the particle be translated from its pivot point in its local space ?
  63938. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63939. * Default : false
  63940. */
  63941. translateFromPivot: boolean;
  63942. /**
  63943. * Index of this particle in the global "positions" array (Internal use)
  63944. * @hidden
  63945. */
  63946. _pos: number;
  63947. /**
  63948. * @hidden Index of this particle in the global "indices" array (Internal use)
  63949. */
  63950. _ind: number;
  63951. /**
  63952. * Group this particle belongs to
  63953. */
  63954. _group: PointsGroup;
  63955. /**
  63956. * Group id of this particle
  63957. */
  63958. groupId: number;
  63959. /**
  63960. * Index of the particle in its group id (Internal use)
  63961. */
  63962. idxInGroup: number;
  63963. /**
  63964. * @hidden Particle BoundingInfo object (Internal use)
  63965. */
  63966. _boundingInfo: BoundingInfo;
  63967. /**
  63968. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63969. */
  63970. _pcs: PointsCloudSystem;
  63971. /**
  63972. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63973. */
  63974. _stillInvisible: boolean;
  63975. /**
  63976. * @hidden Last computed particle rotation matrix
  63977. */
  63978. _rotationMatrix: number[];
  63979. /**
  63980. * Parent particle Id, if any.
  63981. * Default null.
  63982. */
  63983. parentId: Nullable<number>;
  63984. /**
  63985. * @hidden Internal global position in the PCS.
  63986. */
  63987. _globalPosition: Vector3;
  63988. /**
  63989. * Creates a Point Cloud object.
  63990. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63991. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63992. * @param group (PointsGroup) is the group the particle belongs to
  63993. * @param groupId (integer) is the group identifier in the PCS.
  63994. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63995. * @param pcs defines the PCS it is associated to
  63996. */
  63997. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63998. /**
  63999. * get point size
  64000. */
  64001. get size(): Vector3;
  64002. /**
  64003. * Set point size
  64004. */
  64005. set size(scale: Vector3);
  64006. /**
  64007. * Legacy support, changed quaternion to rotationQuaternion
  64008. */
  64009. get quaternion(): Nullable<Quaternion>;
  64010. /**
  64011. * Legacy support, changed quaternion to rotationQuaternion
  64012. */
  64013. set quaternion(q: Nullable<Quaternion>);
  64014. /**
  64015. * Returns a boolean. True if the particle intersects a mesh, else false
  64016. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64017. * @param target is the object (point or mesh) what the intersection is computed against
  64018. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64019. * @returns true if it intersects
  64020. */
  64021. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64022. /**
  64023. * get the rotation matrix of the particle
  64024. * @hidden
  64025. */
  64026. getRotationMatrix(m: Matrix): void;
  64027. }
  64028. /**
  64029. * Represents a group of points in a points cloud system
  64030. * * PCS internal tool, don't use it manually.
  64031. */
  64032. export class PointsGroup {
  64033. /**
  64034. * The group id
  64035. * @hidden
  64036. */
  64037. groupID: number;
  64038. /**
  64039. * image data for group (internal use)
  64040. * @hidden
  64041. */
  64042. _groupImageData: Nullable<ArrayBufferView>;
  64043. /**
  64044. * Image Width (internal use)
  64045. * @hidden
  64046. */
  64047. _groupImgWidth: number;
  64048. /**
  64049. * Image Height (internal use)
  64050. * @hidden
  64051. */
  64052. _groupImgHeight: number;
  64053. /**
  64054. * Custom position function (internal use)
  64055. * @hidden
  64056. */
  64057. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64058. /**
  64059. * density per facet for surface points
  64060. * @hidden
  64061. */
  64062. _groupDensity: number[];
  64063. /**
  64064. * Only when points are colored by texture carries pointer to texture list array
  64065. * @hidden
  64066. */
  64067. _textureNb: number;
  64068. /**
  64069. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64070. * PCS internal tool, don't use it manually.
  64071. * @hidden
  64072. */
  64073. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64074. }
  64075. }
  64076. declare module BABYLON {
  64077. interface Scene {
  64078. /** @hidden (Backing field) */
  64079. _physicsEngine: Nullable<IPhysicsEngine>;
  64080. /** @hidden */
  64081. _physicsTimeAccumulator: number;
  64082. /**
  64083. * Gets the current physics engine
  64084. * @returns a IPhysicsEngine or null if none attached
  64085. */
  64086. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64087. /**
  64088. * Enables physics to the current scene
  64089. * @param gravity defines the scene's gravity for the physics engine
  64090. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64091. * @return a boolean indicating if the physics engine was initialized
  64092. */
  64093. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64094. /**
  64095. * Disables and disposes the physics engine associated with the scene
  64096. */
  64097. disablePhysicsEngine(): void;
  64098. /**
  64099. * Gets a boolean indicating if there is an active physics engine
  64100. * @returns a boolean indicating if there is an active physics engine
  64101. */
  64102. isPhysicsEnabled(): boolean;
  64103. /**
  64104. * Deletes a physics compound impostor
  64105. * @param compound defines the compound to delete
  64106. */
  64107. deleteCompoundImpostor(compound: any): void;
  64108. /**
  64109. * An event triggered when physic simulation is about to be run
  64110. */
  64111. onBeforePhysicsObservable: Observable<Scene>;
  64112. /**
  64113. * An event triggered when physic simulation has been done
  64114. */
  64115. onAfterPhysicsObservable: Observable<Scene>;
  64116. }
  64117. interface AbstractMesh {
  64118. /** @hidden */
  64119. _physicsImpostor: Nullable<PhysicsImpostor>;
  64120. /**
  64121. * Gets or sets impostor used for physic simulation
  64122. * @see http://doc.babylonjs.com/features/physics_engine
  64123. */
  64124. physicsImpostor: Nullable<PhysicsImpostor>;
  64125. /**
  64126. * Gets the current physics impostor
  64127. * @see http://doc.babylonjs.com/features/physics_engine
  64128. * @returns a physics impostor or null
  64129. */
  64130. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64131. /** Apply a physic impulse to the mesh
  64132. * @param force defines the force to apply
  64133. * @param contactPoint defines where to apply the force
  64134. * @returns the current mesh
  64135. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64136. */
  64137. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64138. /**
  64139. * Creates a physic joint between two meshes
  64140. * @param otherMesh defines the other mesh to use
  64141. * @param pivot1 defines the pivot to use on this mesh
  64142. * @param pivot2 defines the pivot to use on the other mesh
  64143. * @param options defines additional options (can be plugin dependent)
  64144. * @returns the current mesh
  64145. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64146. */
  64147. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64148. /** @hidden */
  64149. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64150. }
  64151. /**
  64152. * Defines the physics engine scene component responsible to manage a physics engine
  64153. */
  64154. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64155. /**
  64156. * The component name helpful to identify the component in the list of scene components.
  64157. */
  64158. readonly name: string;
  64159. /**
  64160. * The scene the component belongs to.
  64161. */
  64162. scene: Scene;
  64163. /**
  64164. * Creates a new instance of the component for the given scene
  64165. * @param scene Defines the scene to register the component in
  64166. */
  64167. constructor(scene: Scene);
  64168. /**
  64169. * Registers the component in a given scene
  64170. */
  64171. register(): void;
  64172. /**
  64173. * Rebuilds the elements related to this component in case of
  64174. * context lost for instance.
  64175. */
  64176. rebuild(): void;
  64177. /**
  64178. * Disposes the component and the associated ressources
  64179. */
  64180. dispose(): void;
  64181. }
  64182. }
  64183. declare module BABYLON {
  64184. /**
  64185. * A helper for physics simulations
  64186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64187. */
  64188. export class PhysicsHelper {
  64189. private _scene;
  64190. private _physicsEngine;
  64191. /**
  64192. * Initializes the Physics helper
  64193. * @param scene Babylon.js scene
  64194. */
  64195. constructor(scene: Scene);
  64196. /**
  64197. * Applies a radial explosion impulse
  64198. * @param origin the origin of the explosion
  64199. * @param radiusOrEventOptions the radius or the options of radial explosion
  64200. * @param strength the explosion strength
  64201. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64202. * @returns A physics radial explosion event, or null
  64203. */
  64204. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64205. /**
  64206. * Applies a radial explosion force
  64207. * @param origin the origin of the explosion
  64208. * @param radiusOrEventOptions the radius or the options of radial explosion
  64209. * @param strength the explosion strength
  64210. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64211. * @returns A physics radial explosion event, or null
  64212. */
  64213. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64214. /**
  64215. * Creates a gravitational field
  64216. * @param origin the origin of the explosion
  64217. * @param radiusOrEventOptions the radius or the options of radial explosion
  64218. * @param strength the explosion strength
  64219. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64220. * @returns A physics gravitational field event, or null
  64221. */
  64222. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64223. /**
  64224. * Creates a physics updraft event
  64225. * @param origin the origin of the updraft
  64226. * @param radiusOrEventOptions the radius or the options of the updraft
  64227. * @param strength the strength of the updraft
  64228. * @param height the height of the updraft
  64229. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64230. * @returns A physics updraft event, or null
  64231. */
  64232. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64233. /**
  64234. * Creates a physics vortex event
  64235. * @param origin the of the vortex
  64236. * @param radiusOrEventOptions the radius or the options of the vortex
  64237. * @param strength the strength of the vortex
  64238. * @param height the height of the vortex
  64239. * @returns a Physics vortex event, or null
  64240. * A physics vortex event or null
  64241. */
  64242. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64243. }
  64244. /**
  64245. * Represents a physics radial explosion event
  64246. */
  64247. class PhysicsRadialExplosionEvent {
  64248. private _scene;
  64249. private _options;
  64250. private _sphere;
  64251. private _dataFetched;
  64252. /**
  64253. * Initializes a radial explosioin event
  64254. * @param _scene BabylonJS scene
  64255. * @param _options The options for the vortex event
  64256. */
  64257. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64258. /**
  64259. * Returns the data related to the radial explosion event (sphere).
  64260. * @returns The radial explosion event data
  64261. */
  64262. getData(): PhysicsRadialExplosionEventData;
  64263. /**
  64264. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64265. * @param impostor A physics imposter
  64266. * @param origin the origin of the explosion
  64267. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64268. */
  64269. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64270. /**
  64271. * Triggers affecterd impostors callbacks
  64272. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64273. */
  64274. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64275. /**
  64276. * Disposes the sphere.
  64277. * @param force Specifies if the sphere should be disposed by force
  64278. */
  64279. dispose(force?: boolean): void;
  64280. /*** Helpers ***/
  64281. private _prepareSphere;
  64282. private _intersectsWithSphere;
  64283. }
  64284. /**
  64285. * Represents a gravitational field event
  64286. */
  64287. class PhysicsGravitationalFieldEvent {
  64288. private _physicsHelper;
  64289. private _scene;
  64290. private _origin;
  64291. private _options;
  64292. private _tickCallback;
  64293. private _sphere;
  64294. private _dataFetched;
  64295. /**
  64296. * Initializes the physics gravitational field event
  64297. * @param _physicsHelper A physics helper
  64298. * @param _scene BabylonJS scene
  64299. * @param _origin The origin position of the gravitational field event
  64300. * @param _options The options for the vortex event
  64301. */
  64302. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64303. /**
  64304. * Returns the data related to the gravitational field event (sphere).
  64305. * @returns A gravitational field event
  64306. */
  64307. getData(): PhysicsGravitationalFieldEventData;
  64308. /**
  64309. * Enables the gravitational field.
  64310. */
  64311. enable(): void;
  64312. /**
  64313. * Disables the gravitational field.
  64314. */
  64315. disable(): void;
  64316. /**
  64317. * Disposes the sphere.
  64318. * @param force The force to dispose from the gravitational field event
  64319. */
  64320. dispose(force?: boolean): void;
  64321. private _tick;
  64322. }
  64323. /**
  64324. * Represents a physics updraft event
  64325. */
  64326. class PhysicsUpdraftEvent {
  64327. private _scene;
  64328. private _origin;
  64329. private _options;
  64330. private _physicsEngine;
  64331. private _originTop;
  64332. private _originDirection;
  64333. private _tickCallback;
  64334. private _cylinder;
  64335. private _cylinderPosition;
  64336. private _dataFetched;
  64337. /**
  64338. * Initializes the physics updraft event
  64339. * @param _scene BabylonJS scene
  64340. * @param _origin The origin position of the updraft
  64341. * @param _options The options for the updraft event
  64342. */
  64343. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64344. /**
  64345. * Returns the data related to the updraft event (cylinder).
  64346. * @returns A physics updraft event
  64347. */
  64348. getData(): PhysicsUpdraftEventData;
  64349. /**
  64350. * Enables the updraft.
  64351. */
  64352. enable(): void;
  64353. /**
  64354. * Disables the updraft.
  64355. */
  64356. disable(): void;
  64357. /**
  64358. * Disposes the cylinder.
  64359. * @param force Specifies if the updraft should be disposed by force
  64360. */
  64361. dispose(force?: boolean): void;
  64362. private getImpostorHitData;
  64363. private _tick;
  64364. /*** Helpers ***/
  64365. private _prepareCylinder;
  64366. private _intersectsWithCylinder;
  64367. }
  64368. /**
  64369. * Represents a physics vortex event
  64370. */
  64371. class PhysicsVortexEvent {
  64372. private _scene;
  64373. private _origin;
  64374. private _options;
  64375. private _physicsEngine;
  64376. private _originTop;
  64377. private _tickCallback;
  64378. private _cylinder;
  64379. private _cylinderPosition;
  64380. private _dataFetched;
  64381. /**
  64382. * Initializes the physics vortex event
  64383. * @param _scene The BabylonJS scene
  64384. * @param _origin The origin position of the vortex
  64385. * @param _options The options for the vortex event
  64386. */
  64387. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64388. /**
  64389. * Returns the data related to the vortex event (cylinder).
  64390. * @returns The physics vortex event data
  64391. */
  64392. getData(): PhysicsVortexEventData;
  64393. /**
  64394. * Enables the vortex.
  64395. */
  64396. enable(): void;
  64397. /**
  64398. * Disables the cortex.
  64399. */
  64400. disable(): void;
  64401. /**
  64402. * Disposes the sphere.
  64403. * @param force
  64404. */
  64405. dispose(force?: boolean): void;
  64406. private getImpostorHitData;
  64407. private _tick;
  64408. /*** Helpers ***/
  64409. private _prepareCylinder;
  64410. private _intersectsWithCylinder;
  64411. }
  64412. /**
  64413. * Options fot the radial explosion event
  64414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64415. */
  64416. export class PhysicsRadialExplosionEventOptions {
  64417. /**
  64418. * The radius of the sphere for the radial explosion.
  64419. */
  64420. radius: number;
  64421. /**
  64422. * The strenth of the explosion.
  64423. */
  64424. strength: number;
  64425. /**
  64426. * The strenght of the force in correspondence to the distance of the affected object
  64427. */
  64428. falloff: PhysicsRadialImpulseFalloff;
  64429. /**
  64430. * Sphere options for the radial explosion.
  64431. */
  64432. sphere: {
  64433. segments: number;
  64434. diameter: number;
  64435. };
  64436. /**
  64437. * Sphere options for the radial explosion.
  64438. */
  64439. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64440. }
  64441. /**
  64442. * Options fot the updraft event
  64443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64444. */
  64445. export class PhysicsUpdraftEventOptions {
  64446. /**
  64447. * The radius of the cylinder for the vortex
  64448. */
  64449. radius: number;
  64450. /**
  64451. * The strenth of the updraft.
  64452. */
  64453. strength: number;
  64454. /**
  64455. * The height of the cylinder for the updraft.
  64456. */
  64457. height: number;
  64458. /**
  64459. * The mode for the the updraft.
  64460. */
  64461. updraftMode: PhysicsUpdraftMode;
  64462. }
  64463. /**
  64464. * Options fot the vortex event
  64465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64466. */
  64467. export class PhysicsVortexEventOptions {
  64468. /**
  64469. * The radius of the cylinder for the vortex
  64470. */
  64471. radius: number;
  64472. /**
  64473. * The strenth of the vortex.
  64474. */
  64475. strength: number;
  64476. /**
  64477. * The height of the cylinder for the vortex.
  64478. */
  64479. height: number;
  64480. /**
  64481. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64482. */
  64483. centripetalForceThreshold: number;
  64484. /**
  64485. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64486. */
  64487. centripetalForceMultiplier: number;
  64488. /**
  64489. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64490. */
  64491. centrifugalForceMultiplier: number;
  64492. /**
  64493. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64494. */
  64495. updraftForceMultiplier: number;
  64496. }
  64497. /**
  64498. * The strenght of the force in correspondence to the distance of the affected object
  64499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64500. */
  64501. export enum PhysicsRadialImpulseFalloff {
  64502. /** Defines that impulse is constant in strength across it's whole radius */
  64503. Constant = 0,
  64504. /** Defines that impulse gets weaker if it's further from the origin */
  64505. Linear = 1
  64506. }
  64507. /**
  64508. * The strength of the force in correspondence to the distance of the affected object
  64509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64510. */
  64511. export enum PhysicsUpdraftMode {
  64512. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64513. Center = 0,
  64514. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64515. Perpendicular = 1
  64516. }
  64517. /**
  64518. * Interface for a physics hit data
  64519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64520. */
  64521. export interface PhysicsHitData {
  64522. /**
  64523. * The force applied at the contact point
  64524. */
  64525. force: Vector3;
  64526. /**
  64527. * The contact point
  64528. */
  64529. contactPoint: Vector3;
  64530. /**
  64531. * The distance from the origin to the contact point
  64532. */
  64533. distanceFromOrigin: number;
  64534. }
  64535. /**
  64536. * Interface for radial explosion event data
  64537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64538. */
  64539. export interface PhysicsRadialExplosionEventData {
  64540. /**
  64541. * A sphere used for the radial explosion event
  64542. */
  64543. sphere: Mesh;
  64544. }
  64545. /**
  64546. * Interface for gravitational field event data
  64547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64548. */
  64549. export interface PhysicsGravitationalFieldEventData {
  64550. /**
  64551. * A sphere mesh used for the gravitational field event
  64552. */
  64553. sphere: Mesh;
  64554. }
  64555. /**
  64556. * Interface for updraft event data
  64557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64558. */
  64559. export interface PhysicsUpdraftEventData {
  64560. /**
  64561. * A cylinder used for the updraft event
  64562. */
  64563. cylinder: Mesh;
  64564. }
  64565. /**
  64566. * Interface for vortex event data
  64567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64568. */
  64569. export interface PhysicsVortexEventData {
  64570. /**
  64571. * A cylinder used for the vortex event
  64572. */
  64573. cylinder: Mesh;
  64574. }
  64575. /**
  64576. * Interface for an affected physics impostor
  64577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64578. */
  64579. export interface PhysicsAffectedImpostorWithData {
  64580. /**
  64581. * The impostor affected by the effect
  64582. */
  64583. impostor: PhysicsImpostor;
  64584. /**
  64585. * The data about the hit/horce from the explosion
  64586. */
  64587. hitData: PhysicsHitData;
  64588. }
  64589. }
  64590. declare module BABYLON {
  64591. /** @hidden */
  64592. export var blackAndWhitePixelShader: {
  64593. name: string;
  64594. shader: string;
  64595. };
  64596. }
  64597. declare module BABYLON {
  64598. /**
  64599. * Post process used to render in black and white
  64600. */
  64601. export class BlackAndWhitePostProcess extends PostProcess {
  64602. /**
  64603. * Linear about to convert he result to black and white (default: 1)
  64604. */
  64605. degree: number;
  64606. /**
  64607. * Creates a black and white post process
  64608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64609. * @param name The name of the effect.
  64610. * @param options The required width/height ratio to downsize to before computing the render pass.
  64611. * @param camera The camera to apply the render pass to.
  64612. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64613. * @param engine The engine which the post process will be applied. (default: current engine)
  64614. * @param reusable If the post process can be reused on the same frame. (default: false)
  64615. */
  64616. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64617. }
  64618. }
  64619. declare module BABYLON {
  64620. /**
  64621. * This represents a set of one or more post processes in Babylon.
  64622. * A post process can be used to apply a shader to a texture after it is rendered.
  64623. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64624. */
  64625. export class PostProcessRenderEffect {
  64626. private _postProcesses;
  64627. private _getPostProcesses;
  64628. private _singleInstance;
  64629. private _cameras;
  64630. private _indicesForCamera;
  64631. /**
  64632. * Name of the effect
  64633. * @hidden
  64634. */
  64635. _name: string;
  64636. /**
  64637. * Instantiates a post process render effect.
  64638. * A post process can be used to apply a shader to a texture after it is rendered.
  64639. * @param engine The engine the effect is tied to
  64640. * @param name The name of the effect
  64641. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64642. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64643. */
  64644. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64645. /**
  64646. * Checks if all the post processes in the effect are supported.
  64647. */
  64648. get isSupported(): boolean;
  64649. /**
  64650. * Updates the current state of the effect
  64651. * @hidden
  64652. */
  64653. _update(): void;
  64654. /**
  64655. * Attaches the effect on cameras
  64656. * @param cameras The camera to attach to.
  64657. * @hidden
  64658. */
  64659. _attachCameras(cameras: Camera): void;
  64660. /**
  64661. * Attaches the effect on cameras
  64662. * @param cameras The camera to attach to.
  64663. * @hidden
  64664. */
  64665. _attachCameras(cameras: Camera[]): void;
  64666. /**
  64667. * Detaches the effect on cameras
  64668. * @param cameras The camera to detatch from.
  64669. * @hidden
  64670. */
  64671. _detachCameras(cameras: Camera): void;
  64672. /**
  64673. * Detatches the effect on cameras
  64674. * @param cameras The camera to detatch from.
  64675. * @hidden
  64676. */
  64677. _detachCameras(cameras: Camera[]): void;
  64678. /**
  64679. * Enables the effect on given cameras
  64680. * @param cameras The camera to enable.
  64681. * @hidden
  64682. */
  64683. _enable(cameras: Camera): void;
  64684. /**
  64685. * Enables the effect on given cameras
  64686. * @param cameras The camera to enable.
  64687. * @hidden
  64688. */
  64689. _enable(cameras: Nullable<Camera[]>): void;
  64690. /**
  64691. * Disables the effect on the given cameras
  64692. * @param cameras The camera to disable.
  64693. * @hidden
  64694. */
  64695. _disable(cameras: Camera): void;
  64696. /**
  64697. * Disables the effect on the given cameras
  64698. * @param cameras The camera to disable.
  64699. * @hidden
  64700. */
  64701. _disable(cameras: Nullable<Camera[]>): void;
  64702. /**
  64703. * Gets a list of the post processes contained in the effect.
  64704. * @param camera The camera to get the post processes on.
  64705. * @returns The list of the post processes in the effect.
  64706. */
  64707. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64708. }
  64709. }
  64710. declare module BABYLON {
  64711. /** @hidden */
  64712. export var extractHighlightsPixelShader: {
  64713. name: string;
  64714. shader: string;
  64715. };
  64716. }
  64717. declare module BABYLON {
  64718. /**
  64719. * 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.
  64720. */
  64721. export class ExtractHighlightsPostProcess extends PostProcess {
  64722. /**
  64723. * The luminance threshold, pixels below this value will be set to black.
  64724. */
  64725. threshold: number;
  64726. /** @hidden */
  64727. _exposure: number;
  64728. /**
  64729. * Post process which has the input texture to be used when performing highlight extraction
  64730. * @hidden
  64731. */
  64732. _inputPostProcess: Nullable<PostProcess>;
  64733. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64734. }
  64735. }
  64736. declare module BABYLON {
  64737. /** @hidden */
  64738. export var bloomMergePixelShader: {
  64739. name: string;
  64740. shader: string;
  64741. };
  64742. }
  64743. declare module BABYLON {
  64744. /**
  64745. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64746. */
  64747. export class BloomMergePostProcess extends PostProcess {
  64748. /** Weight of the bloom to be added to the original input. */
  64749. weight: number;
  64750. /**
  64751. * Creates a new instance of @see BloomMergePostProcess
  64752. * @param name The name of the effect.
  64753. * @param originalFromInput Post process which's input will be used for the merge.
  64754. * @param blurred Blurred highlights post process which's output will be used.
  64755. * @param weight Weight of the bloom to be added to the original input.
  64756. * @param options The required width/height ratio to downsize to before computing the render pass.
  64757. * @param camera The camera to apply the render pass to.
  64758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64759. * @param engine The engine which the post process will be applied. (default: current engine)
  64760. * @param reusable If the post process can be reused on the same frame. (default: false)
  64761. * @param textureType Type of textures used when performing the post process. (default: 0)
  64762. * @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)
  64763. */
  64764. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64765. /** Weight of the bloom to be added to the original input. */
  64766. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64767. }
  64768. }
  64769. declare module BABYLON {
  64770. /**
  64771. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64772. */
  64773. export class BloomEffect extends PostProcessRenderEffect {
  64774. private bloomScale;
  64775. /**
  64776. * @hidden Internal
  64777. */
  64778. _effects: Array<PostProcess>;
  64779. /**
  64780. * @hidden Internal
  64781. */
  64782. _downscale: ExtractHighlightsPostProcess;
  64783. private _blurX;
  64784. private _blurY;
  64785. private _merge;
  64786. /**
  64787. * The luminance threshold to find bright areas of the image to bloom.
  64788. */
  64789. get threshold(): number;
  64790. set threshold(value: number);
  64791. /**
  64792. * The strength of the bloom.
  64793. */
  64794. get weight(): number;
  64795. set weight(value: number);
  64796. /**
  64797. * Specifies the size of the bloom blur kernel, relative to the final output size
  64798. */
  64799. get kernel(): number;
  64800. set kernel(value: number);
  64801. /**
  64802. * Creates a new instance of @see BloomEffect
  64803. * @param scene The scene the effect belongs to.
  64804. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64805. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64806. * @param bloomWeight The the strength of bloom.
  64807. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64808. * @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)
  64809. */
  64810. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64811. /**
  64812. * Disposes each of the internal effects for a given camera.
  64813. * @param camera The camera to dispose the effect on.
  64814. */
  64815. disposeEffects(camera: Camera): void;
  64816. /**
  64817. * @hidden Internal
  64818. */
  64819. _updateEffects(): void;
  64820. /**
  64821. * Internal
  64822. * @returns if all the contained post processes are ready.
  64823. * @hidden
  64824. */
  64825. _isReady(): boolean;
  64826. }
  64827. }
  64828. declare module BABYLON {
  64829. /** @hidden */
  64830. export var chromaticAberrationPixelShader: {
  64831. name: string;
  64832. shader: string;
  64833. };
  64834. }
  64835. declare module BABYLON {
  64836. /**
  64837. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64838. */
  64839. export class ChromaticAberrationPostProcess extends PostProcess {
  64840. /**
  64841. * The amount of seperation of rgb channels (default: 30)
  64842. */
  64843. aberrationAmount: number;
  64844. /**
  64845. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64846. */
  64847. radialIntensity: number;
  64848. /**
  64849. * 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))
  64850. */
  64851. direction: Vector2;
  64852. /**
  64853. * 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))
  64854. */
  64855. centerPosition: Vector2;
  64856. /**
  64857. * Creates a new instance ChromaticAberrationPostProcess
  64858. * @param name The name of the effect.
  64859. * @param screenWidth The width of the screen to apply the effect on.
  64860. * @param screenHeight The height of the screen to apply the effect on.
  64861. * @param options The required width/height ratio to downsize to before computing the render pass.
  64862. * @param camera The camera to apply the render pass to.
  64863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64864. * @param engine The engine which the post process will be applied. (default: current engine)
  64865. * @param reusable If the post process can be reused on the same frame. (default: false)
  64866. * @param textureType Type of textures used when performing the post process. (default: 0)
  64867. * @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)
  64868. */
  64869. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64870. }
  64871. }
  64872. declare module BABYLON {
  64873. /** @hidden */
  64874. export var circleOfConfusionPixelShader: {
  64875. name: string;
  64876. shader: string;
  64877. };
  64878. }
  64879. declare module BABYLON {
  64880. /**
  64881. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64882. */
  64883. export class CircleOfConfusionPostProcess extends PostProcess {
  64884. /**
  64885. * 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.
  64886. */
  64887. lensSize: number;
  64888. /**
  64889. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64890. */
  64891. fStop: number;
  64892. /**
  64893. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64894. */
  64895. focusDistance: number;
  64896. /**
  64897. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64898. */
  64899. focalLength: number;
  64900. private _depthTexture;
  64901. /**
  64902. * Creates a new instance CircleOfConfusionPostProcess
  64903. * @param name The name of the effect.
  64904. * @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.
  64905. * @param options The required width/height ratio to downsize to before computing the render pass.
  64906. * @param camera The camera to apply the render pass to.
  64907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64908. * @param engine The engine which the post process will be applied. (default: current engine)
  64909. * @param reusable If the post process can be reused on the same frame. (default: false)
  64910. * @param textureType Type of textures used when performing the post process. (default: 0)
  64911. * @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)
  64912. */
  64913. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64914. /**
  64915. * 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.
  64916. */
  64917. set depthTexture(value: RenderTargetTexture);
  64918. }
  64919. }
  64920. declare module BABYLON {
  64921. /** @hidden */
  64922. export var colorCorrectionPixelShader: {
  64923. name: string;
  64924. shader: string;
  64925. };
  64926. }
  64927. declare module BABYLON {
  64928. /**
  64929. *
  64930. * This post-process allows the modification of rendered colors by using
  64931. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64932. *
  64933. * The object needs to be provided an url to a texture containing the color
  64934. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64935. * Use an image editing software to tweak the LUT to match your needs.
  64936. *
  64937. * For an example of a color LUT, see here:
  64938. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64939. * For explanations on color grading, see here:
  64940. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64941. *
  64942. */
  64943. export class ColorCorrectionPostProcess extends PostProcess {
  64944. private _colorTableTexture;
  64945. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64946. }
  64947. }
  64948. declare module BABYLON {
  64949. /** @hidden */
  64950. export var convolutionPixelShader: {
  64951. name: string;
  64952. shader: string;
  64953. };
  64954. }
  64955. declare module BABYLON {
  64956. /**
  64957. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64958. * input texture to perform effects such as edge detection or sharpening
  64959. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64960. */
  64961. export class ConvolutionPostProcess extends PostProcess {
  64962. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64963. kernel: number[];
  64964. /**
  64965. * Creates a new instance ConvolutionPostProcess
  64966. * @param name The name of the effect.
  64967. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64968. * @param options The required width/height ratio to downsize to before computing the render pass.
  64969. * @param camera The camera to apply the render pass to.
  64970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64971. * @param engine The engine which the post process will be applied. (default: current engine)
  64972. * @param reusable If the post process can be reused on the same frame. (default: false)
  64973. * @param textureType Type of textures used when performing the post process. (default: 0)
  64974. */
  64975. constructor(name: string,
  64976. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64977. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64978. /**
  64979. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64980. */
  64981. static EdgeDetect0Kernel: number[];
  64982. /**
  64983. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64984. */
  64985. static EdgeDetect1Kernel: number[];
  64986. /**
  64987. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64988. */
  64989. static EdgeDetect2Kernel: number[];
  64990. /**
  64991. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64992. */
  64993. static SharpenKernel: number[];
  64994. /**
  64995. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64996. */
  64997. static EmbossKernel: number[];
  64998. /**
  64999. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65000. */
  65001. static GaussianKernel: number[];
  65002. }
  65003. }
  65004. declare module BABYLON {
  65005. /**
  65006. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65007. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65008. * based on samples that have a large difference in distance than the center pixel.
  65009. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65010. */
  65011. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65012. direction: Vector2;
  65013. /**
  65014. * Creates a new instance CircleOfConfusionPostProcess
  65015. * @param name The name of the effect.
  65016. * @param scene The scene the effect belongs to.
  65017. * @param direction The direction the blur should be applied.
  65018. * @param kernel The size of the kernel used to blur.
  65019. * @param options The required width/height ratio to downsize to before computing the render pass.
  65020. * @param camera The camera to apply the render pass to.
  65021. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65022. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65024. * @param engine The engine which the post process will be applied. (default: current engine)
  65025. * @param reusable If the post process can be reused on the same frame. (default: false)
  65026. * @param textureType Type of textures used when performing the post process. (default: 0)
  65027. * @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)
  65028. */
  65029. 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);
  65030. }
  65031. }
  65032. declare module BABYLON {
  65033. /** @hidden */
  65034. export var depthOfFieldMergePixelShader: {
  65035. name: string;
  65036. shader: string;
  65037. };
  65038. }
  65039. declare module BABYLON {
  65040. /**
  65041. * Options to be set when merging outputs from the default pipeline.
  65042. */
  65043. export class DepthOfFieldMergePostProcessOptions {
  65044. /**
  65045. * The original image to merge on top of
  65046. */
  65047. originalFromInput: PostProcess;
  65048. /**
  65049. * Parameters to perform the merge of the depth of field effect
  65050. */
  65051. depthOfField?: {
  65052. circleOfConfusion: PostProcess;
  65053. blurSteps: Array<PostProcess>;
  65054. };
  65055. /**
  65056. * Parameters to perform the merge of bloom effect
  65057. */
  65058. bloom?: {
  65059. blurred: PostProcess;
  65060. weight: number;
  65061. };
  65062. }
  65063. /**
  65064. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65065. */
  65066. export class DepthOfFieldMergePostProcess extends PostProcess {
  65067. private blurSteps;
  65068. /**
  65069. * Creates a new instance of DepthOfFieldMergePostProcess
  65070. * @param name The name of the effect.
  65071. * @param originalFromInput Post process which's input will be used for the merge.
  65072. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65073. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65074. * @param options The required width/height ratio to downsize to before computing the render pass.
  65075. * @param camera The camera to apply the render pass to.
  65076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65077. * @param engine The engine which the post process will be applied. (default: current engine)
  65078. * @param reusable If the post process can be reused on the same frame. (default: false)
  65079. * @param textureType Type of textures used when performing the post process. (default: 0)
  65080. * @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)
  65081. */
  65082. 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);
  65083. /**
  65084. * Updates the effect with the current post process compile time values and recompiles the shader.
  65085. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65086. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65087. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65088. * @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
  65089. * @param onCompiled Called when the shader has been compiled.
  65090. * @param onError Called if there is an error when compiling a shader.
  65091. */
  65092. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65093. }
  65094. }
  65095. declare module BABYLON {
  65096. /**
  65097. * Specifies the level of max blur that should be applied when using the depth of field effect
  65098. */
  65099. export enum DepthOfFieldEffectBlurLevel {
  65100. /**
  65101. * Subtle blur
  65102. */
  65103. Low = 0,
  65104. /**
  65105. * Medium blur
  65106. */
  65107. Medium = 1,
  65108. /**
  65109. * Large blur
  65110. */
  65111. High = 2
  65112. }
  65113. /**
  65114. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65115. */
  65116. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65117. private _circleOfConfusion;
  65118. /**
  65119. * @hidden Internal, blurs from high to low
  65120. */
  65121. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65122. private _depthOfFieldBlurY;
  65123. private _dofMerge;
  65124. /**
  65125. * @hidden Internal post processes in depth of field effect
  65126. */
  65127. _effects: Array<PostProcess>;
  65128. /**
  65129. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65130. */
  65131. set focalLength(value: number);
  65132. get focalLength(): number;
  65133. /**
  65134. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65135. */
  65136. set fStop(value: number);
  65137. get fStop(): number;
  65138. /**
  65139. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65140. */
  65141. set focusDistance(value: number);
  65142. get focusDistance(): number;
  65143. /**
  65144. * 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.
  65145. */
  65146. set lensSize(value: number);
  65147. get lensSize(): number;
  65148. /**
  65149. * Creates a new instance DepthOfFieldEffect
  65150. * @param scene The scene the effect belongs to.
  65151. * @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.
  65152. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65153. * @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)
  65154. */
  65155. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65156. /**
  65157. * Get the current class name of the current effet
  65158. * @returns "DepthOfFieldEffect"
  65159. */
  65160. getClassName(): string;
  65161. /**
  65162. * 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.
  65163. */
  65164. set depthTexture(value: RenderTargetTexture);
  65165. /**
  65166. * Disposes each of the internal effects for a given camera.
  65167. * @param camera The camera to dispose the effect on.
  65168. */
  65169. disposeEffects(camera: Camera): void;
  65170. /**
  65171. * @hidden Internal
  65172. */
  65173. _updateEffects(): void;
  65174. /**
  65175. * Internal
  65176. * @returns if all the contained post processes are ready.
  65177. * @hidden
  65178. */
  65179. _isReady(): boolean;
  65180. }
  65181. }
  65182. declare module BABYLON {
  65183. /** @hidden */
  65184. export var displayPassPixelShader: {
  65185. name: string;
  65186. shader: string;
  65187. };
  65188. }
  65189. declare module BABYLON {
  65190. /**
  65191. * DisplayPassPostProcess which produces an output the same as it's input
  65192. */
  65193. export class DisplayPassPostProcess extends PostProcess {
  65194. /**
  65195. * Creates the DisplayPassPostProcess
  65196. * @param name The name of the effect.
  65197. * @param options The required width/height ratio to downsize to before computing the render pass.
  65198. * @param camera The camera to apply the render pass to.
  65199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65200. * @param engine The engine which the post process will be applied. (default: current engine)
  65201. * @param reusable If the post process can be reused on the same frame. (default: false)
  65202. */
  65203. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65204. }
  65205. }
  65206. declare module BABYLON {
  65207. /** @hidden */
  65208. export var filterPixelShader: {
  65209. name: string;
  65210. shader: string;
  65211. };
  65212. }
  65213. declare module BABYLON {
  65214. /**
  65215. * Applies a kernel filter to the image
  65216. */
  65217. export class FilterPostProcess extends PostProcess {
  65218. /** The matrix to be applied to the image */
  65219. kernelMatrix: Matrix;
  65220. /**
  65221. *
  65222. * @param name The name of the effect.
  65223. * @param kernelMatrix The matrix to be applied to the image
  65224. * @param options The required width/height ratio to downsize to before computing the render pass.
  65225. * @param camera The camera to apply the render pass to.
  65226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65227. * @param engine The engine which the post process will be applied. (default: current engine)
  65228. * @param reusable If the post process can be reused on the same frame. (default: false)
  65229. */
  65230. constructor(name: string,
  65231. /** The matrix to be applied to the image */
  65232. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65233. }
  65234. }
  65235. declare module BABYLON {
  65236. /** @hidden */
  65237. export var fxaaPixelShader: {
  65238. name: string;
  65239. shader: string;
  65240. };
  65241. }
  65242. declare module BABYLON {
  65243. /** @hidden */
  65244. export var fxaaVertexShader: {
  65245. name: string;
  65246. shader: string;
  65247. };
  65248. }
  65249. declare module BABYLON {
  65250. /**
  65251. * Fxaa post process
  65252. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65253. */
  65254. export class FxaaPostProcess extends PostProcess {
  65255. /** @hidden */
  65256. texelWidth: number;
  65257. /** @hidden */
  65258. texelHeight: number;
  65259. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65260. private _getDefines;
  65261. }
  65262. }
  65263. declare module BABYLON {
  65264. /** @hidden */
  65265. export var grainPixelShader: {
  65266. name: string;
  65267. shader: string;
  65268. };
  65269. }
  65270. declare module BABYLON {
  65271. /**
  65272. * The GrainPostProcess adds noise to the image at mid luminance levels
  65273. */
  65274. export class GrainPostProcess extends PostProcess {
  65275. /**
  65276. * The intensity of the grain added (default: 30)
  65277. */
  65278. intensity: number;
  65279. /**
  65280. * If the grain should be randomized on every frame
  65281. */
  65282. animated: boolean;
  65283. /**
  65284. * Creates a new instance of @see GrainPostProcess
  65285. * @param name The name of the effect.
  65286. * @param options The required width/height ratio to downsize to before computing the render pass.
  65287. * @param camera The camera to apply the render pass to.
  65288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65289. * @param engine The engine which the post process will be applied. (default: current engine)
  65290. * @param reusable If the post process can be reused on the same frame. (default: false)
  65291. * @param textureType Type of textures used when performing the post process. (default: 0)
  65292. * @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)
  65293. */
  65294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65295. }
  65296. }
  65297. declare module BABYLON {
  65298. /** @hidden */
  65299. export var highlightsPixelShader: {
  65300. name: string;
  65301. shader: string;
  65302. };
  65303. }
  65304. declare module BABYLON {
  65305. /**
  65306. * Extracts highlights from the image
  65307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65308. */
  65309. export class HighlightsPostProcess extends PostProcess {
  65310. /**
  65311. * Extracts highlights from the image
  65312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65313. * @param name The name of the effect.
  65314. * @param options The required width/height ratio to downsize to before computing the render pass.
  65315. * @param camera The camera to apply the render pass to.
  65316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65317. * @param engine The engine which the post process will be applied. (default: current engine)
  65318. * @param reusable If the post process can be reused on the same frame. (default: false)
  65319. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65320. */
  65321. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65322. }
  65323. }
  65324. declare module BABYLON {
  65325. /** @hidden */
  65326. export var mrtFragmentDeclaration: {
  65327. name: string;
  65328. shader: string;
  65329. };
  65330. }
  65331. declare module BABYLON {
  65332. /** @hidden */
  65333. export var geometryPixelShader: {
  65334. name: string;
  65335. shader: string;
  65336. };
  65337. }
  65338. declare module BABYLON {
  65339. /** @hidden */
  65340. export var geometryVertexShader: {
  65341. name: string;
  65342. shader: string;
  65343. };
  65344. }
  65345. declare module BABYLON {
  65346. /** @hidden */
  65347. interface ISavedTransformationMatrix {
  65348. world: Matrix;
  65349. viewProjection: Matrix;
  65350. }
  65351. /**
  65352. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65353. */
  65354. export class GeometryBufferRenderer {
  65355. /**
  65356. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65357. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65358. */
  65359. static readonly POSITION_TEXTURE_TYPE: number;
  65360. /**
  65361. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65362. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65363. */
  65364. static readonly VELOCITY_TEXTURE_TYPE: number;
  65365. /**
  65366. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65367. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65368. */
  65369. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65370. /**
  65371. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65372. * in order to compute objects velocities when enableVelocity is set to "true"
  65373. * @hidden
  65374. */
  65375. _previousTransformationMatrices: {
  65376. [index: number]: ISavedTransformationMatrix;
  65377. };
  65378. /**
  65379. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65380. * in order to compute objects velocities when enableVelocity is set to "true"
  65381. * @hidden
  65382. */
  65383. _previousBonesTransformationMatrices: {
  65384. [index: number]: Float32Array;
  65385. };
  65386. /**
  65387. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65388. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65389. */
  65390. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65391. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65392. renderTransparentMeshes: boolean;
  65393. private _scene;
  65394. private _multiRenderTarget;
  65395. private _ratio;
  65396. private _enablePosition;
  65397. private _enableVelocity;
  65398. private _enableReflectivity;
  65399. private _positionIndex;
  65400. private _velocityIndex;
  65401. private _reflectivityIndex;
  65402. protected _effect: Effect;
  65403. protected _cachedDefines: string;
  65404. /**
  65405. * Set the render list (meshes to be rendered) used in the G buffer.
  65406. */
  65407. set renderList(meshes: Mesh[]);
  65408. /**
  65409. * Gets wether or not G buffer are supported by the running hardware.
  65410. * This requires draw buffer supports
  65411. */
  65412. get isSupported(): boolean;
  65413. /**
  65414. * Returns the index of the given texture type in the G-Buffer textures array
  65415. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65416. * @returns the index of the given texture type in the G-Buffer textures array
  65417. */
  65418. getTextureIndex(textureType: number): number;
  65419. /**
  65420. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65421. */
  65422. get enablePosition(): boolean;
  65423. /**
  65424. * Sets whether or not objects positions are enabled for the G buffer.
  65425. */
  65426. set enablePosition(enable: boolean);
  65427. /**
  65428. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65429. */
  65430. get enableVelocity(): boolean;
  65431. /**
  65432. * Sets wether or not objects velocities are enabled for the G buffer.
  65433. */
  65434. set enableVelocity(enable: boolean);
  65435. /**
  65436. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65437. */
  65438. get enableReflectivity(): boolean;
  65439. /**
  65440. * Sets wether or not objects roughness are enabled for the G buffer.
  65441. */
  65442. set enableReflectivity(enable: boolean);
  65443. /**
  65444. * Gets the scene associated with the buffer.
  65445. */
  65446. get scene(): Scene;
  65447. /**
  65448. * Gets the ratio used by the buffer during its creation.
  65449. * How big is the buffer related to the main canvas.
  65450. */
  65451. get ratio(): number;
  65452. /** @hidden */
  65453. static _SceneComponentInitialization: (scene: Scene) => void;
  65454. /**
  65455. * Creates a new G Buffer for the scene
  65456. * @param scene The scene the buffer belongs to
  65457. * @param ratio How big is the buffer related to the main canvas.
  65458. */
  65459. constructor(scene: Scene, ratio?: number);
  65460. /**
  65461. * Checks wether everything is ready to render a submesh to the G buffer.
  65462. * @param subMesh the submesh to check readiness for
  65463. * @param useInstances is the mesh drawn using instance or not
  65464. * @returns true if ready otherwise false
  65465. */
  65466. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65467. /**
  65468. * Gets the current underlying G Buffer.
  65469. * @returns the buffer
  65470. */
  65471. getGBuffer(): MultiRenderTarget;
  65472. /**
  65473. * Gets the number of samples used to render the buffer (anti aliasing).
  65474. */
  65475. get samples(): number;
  65476. /**
  65477. * Sets the number of samples used to render the buffer (anti aliasing).
  65478. */
  65479. set samples(value: number);
  65480. /**
  65481. * Disposes the renderer and frees up associated resources.
  65482. */
  65483. dispose(): void;
  65484. protected _createRenderTargets(): void;
  65485. private _copyBonesTransformationMatrices;
  65486. }
  65487. }
  65488. declare module BABYLON {
  65489. interface Scene {
  65490. /** @hidden (Backing field) */
  65491. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65492. /**
  65493. * Gets or Sets the current geometry buffer associated to the scene.
  65494. */
  65495. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65496. /**
  65497. * Enables a GeometryBufferRender and associates it with the scene
  65498. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65499. * @returns the GeometryBufferRenderer
  65500. */
  65501. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65502. /**
  65503. * Disables the GeometryBufferRender associated with the scene
  65504. */
  65505. disableGeometryBufferRenderer(): void;
  65506. }
  65507. /**
  65508. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65509. * in several rendering techniques.
  65510. */
  65511. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65512. /**
  65513. * The component name helpful to identify the component in the list of scene components.
  65514. */
  65515. readonly name: string;
  65516. /**
  65517. * The scene the component belongs to.
  65518. */
  65519. scene: Scene;
  65520. /**
  65521. * Creates a new instance of the component for the given scene
  65522. * @param scene Defines the scene to register the component in
  65523. */
  65524. constructor(scene: Scene);
  65525. /**
  65526. * Registers the component in a given scene
  65527. */
  65528. register(): void;
  65529. /**
  65530. * Rebuilds the elements related to this component in case of
  65531. * context lost for instance.
  65532. */
  65533. rebuild(): void;
  65534. /**
  65535. * Disposes the component and the associated ressources
  65536. */
  65537. dispose(): void;
  65538. private _gatherRenderTargets;
  65539. }
  65540. }
  65541. declare module BABYLON {
  65542. /** @hidden */
  65543. export var motionBlurPixelShader: {
  65544. name: string;
  65545. shader: string;
  65546. };
  65547. }
  65548. declare module BABYLON {
  65549. /**
  65550. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65551. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65552. * As an example, all you have to do is to create the post-process:
  65553. * var mb = new BABYLON.MotionBlurPostProcess(
  65554. * 'mb', // The name of the effect.
  65555. * scene, // The scene containing the objects to blur according to their velocity.
  65556. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65557. * camera // The camera to apply the render pass to.
  65558. * );
  65559. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65560. */
  65561. export class MotionBlurPostProcess extends PostProcess {
  65562. /**
  65563. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65564. */
  65565. motionStrength: number;
  65566. /**
  65567. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65568. */
  65569. get motionBlurSamples(): number;
  65570. /**
  65571. * Sets the number of iterations to be used for motion blur quality
  65572. */
  65573. set motionBlurSamples(samples: number);
  65574. private _motionBlurSamples;
  65575. private _geometryBufferRenderer;
  65576. /**
  65577. * Creates a new instance MotionBlurPostProcess
  65578. * @param name The name of the effect.
  65579. * @param scene The scene containing the objects to blur according to their velocity.
  65580. * @param options The required width/height ratio to downsize to before computing the render pass.
  65581. * @param camera The camera to apply the render pass to.
  65582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65583. * @param engine The engine which the post process will be applied. (default: current engine)
  65584. * @param reusable If the post process can be reused on the same frame. (default: false)
  65585. * @param textureType Type of textures used when performing the post process. (default: 0)
  65586. * @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)
  65587. */
  65588. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65589. /**
  65590. * Excludes the given skinned mesh from computing bones velocities.
  65591. * 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.
  65592. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65593. */
  65594. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65595. /**
  65596. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65597. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65598. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65599. */
  65600. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65601. /**
  65602. * Disposes the post process.
  65603. * @param camera The camera to dispose the post process on.
  65604. */
  65605. dispose(camera?: Camera): void;
  65606. }
  65607. }
  65608. declare module BABYLON {
  65609. /** @hidden */
  65610. export var refractionPixelShader: {
  65611. name: string;
  65612. shader: string;
  65613. };
  65614. }
  65615. declare module BABYLON {
  65616. /**
  65617. * Post process which applies a refractin texture
  65618. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65619. */
  65620. export class RefractionPostProcess extends PostProcess {
  65621. /** the base color of the refraction (used to taint the rendering) */
  65622. color: Color3;
  65623. /** simulated refraction depth */
  65624. depth: number;
  65625. /** the coefficient of the base color (0 to remove base color tainting) */
  65626. colorLevel: number;
  65627. private _refTexture;
  65628. private _ownRefractionTexture;
  65629. /**
  65630. * Gets or sets the refraction texture
  65631. * Please note that you are responsible for disposing the texture if you set it manually
  65632. */
  65633. get refractionTexture(): Texture;
  65634. set refractionTexture(value: Texture);
  65635. /**
  65636. * Initializes the RefractionPostProcess
  65637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65638. * @param name The name of the effect.
  65639. * @param refractionTextureUrl Url of the refraction texture to use
  65640. * @param color the base color of the refraction (used to taint the rendering)
  65641. * @param depth simulated refraction depth
  65642. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65643. * @param camera The camera to apply the render pass to.
  65644. * @param options The required width/height ratio to downsize to before computing the render pass.
  65645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65646. * @param engine The engine which the post process will be applied. (default: current engine)
  65647. * @param reusable If the post process can be reused on the same frame. (default: false)
  65648. */
  65649. constructor(name: string, refractionTextureUrl: string,
  65650. /** the base color of the refraction (used to taint the rendering) */
  65651. color: Color3,
  65652. /** simulated refraction depth */
  65653. depth: number,
  65654. /** the coefficient of the base color (0 to remove base color tainting) */
  65655. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65656. /**
  65657. * Disposes of the post process
  65658. * @param camera Camera to dispose post process on
  65659. */
  65660. dispose(camera: Camera): void;
  65661. }
  65662. }
  65663. declare module BABYLON {
  65664. /** @hidden */
  65665. export var sharpenPixelShader: {
  65666. name: string;
  65667. shader: string;
  65668. };
  65669. }
  65670. declare module BABYLON {
  65671. /**
  65672. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65673. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65674. */
  65675. export class SharpenPostProcess extends PostProcess {
  65676. /**
  65677. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65678. */
  65679. colorAmount: number;
  65680. /**
  65681. * How much sharpness should be applied (default: 0.3)
  65682. */
  65683. edgeAmount: number;
  65684. /**
  65685. * Creates a new instance ConvolutionPostProcess
  65686. * @param name The name of the effect.
  65687. * @param options The required width/height ratio to downsize to before computing the render pass.
  65688. * @param camera The camera to apply the render pass to.
  65689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65690. * @param engine The engine which the post process will be applied. (default: current engine)
  65691. * @param reusable If the post process can be reused on the same frame. (default: false)
  65692. * @param textureType Type of textures used when performing the post process. (default: 0)
  65693. * @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)
  65694. */
  65695. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65696. }
  65697. }
  65698. declare module BABYLON {
  65699. /**
  65700. * PostProcessRenderPipeline
  65701. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65702. */
  65703. export class PostProcessRenderPipeline {
  65704. private engine;
  65705. private _renderEffects;
  65706. private _renderEffectsForIsolatedPass;
  65707. /**
  65708. * List of inspectable custom properties (used by the Inspector)
  65709. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65710. */
  65711. inspectableCustomProperties: IInspectable[];
  65712. /**
  65713. * @hidden
  65714. */
  65715. protected _cameras: Camera[];
  65716. /** @hidden */
  65717. _name: string;
  65718. /**
  65719. * Gets pipeline name
  65720. */
  65721. get name(): string;
  65722. /** Gets the list of attached cameras */
  65723. get cameras(): Camera[];
  65724. /**
  65725. * Initializes a PostProcessRenderPipeline
  65726. * @param engine engine to add the pipeline to
  65727. * @param name name of the pipeline
  65728. */
  65729. constructor(engine: Engine, name: string);
  65730. /**
  65731. * Gets the class name
  65732. * @returns "PostProcessRenderPipeline"
  65733. */
  65734. getClassName(): string;
  65735. /**
  65736. * If all the render effects in the pipeline are supported
  65737. */
  65738. get isSupported(): boolean;
  65739. /**
  65740. * Adds an effect to the pipeline
  65741. * @param renderEffect the effect to add
  65742. */
  65743. addEffect(renderEffect: PostProcessRenderEffect): void;
  65744. /** @hidden */
  65745. _rebuild(): void;
  65746. /** @hidden */
  65747. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65748. /** @hidden */
  65749. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65750. /** @hidden */
  65751. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65752. /** @hidden */
  65753. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65754. /** @hidden */
  65755. _attachCameras(cameras: Camera, unique: boolean): void;
  65756. /** @hidden */
  65757. _attachCameras(cameras: Camera[], unique: boolean): void;
  65758. /** @hidden */
  65759. _detachCameras(cameras: Camera): void;
  65760. /** @hidden */
  65761. _detachCameras(cameras: Nullable<Camera[]>): void;
  65762. /** @hidden */
  65763. _update(): void;
  65764. /** @hidden */
  65765. _reset(): void;
  65766. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65767. /**
  65768. * Disposes of the pipeline
  65769. */
  65770. dispose(): void;
  65771. }
  65772. }
  65773. declare module BABYLON {
  65774. /**
  65775. * PostProcessRenderPipelineManager class
  65776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65777. */
  65778. export class PostProcessRenderPipelineManager {
  65779. private _renderPipelines;
  65780. /**
  65781. * Initializes a PostProcessRenderPipelineManager
  65782. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65783. */
  65784. constructor();
  65785. /**
  65786. * Gets the list of supported render pipelines
  65787. */
  65788. get supportedPipelines(): PostProcessRenderPipeline[];
  65789. /**
  65790. * Adds a pipeline to the manager
  65791. * @param renderPipeline The pipeline to add
  65792. */
  65793. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65794. /**
  65795. * Attaches a camera to the pipeline
  65796. * @param renderPipelineName The name of the pipeline to attach to
  65797. * @param cameras the camera to attach
  65798. * @param unique if the camera can be attached multiple times to the pipeline
  65799. */
  65800. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65801. /**
  65802. * Detaches a camera from the pipeline
  65803. * @param renderPipelineName The name of the pipeline to detach from
  65804. * @param cameras the camera to detach
  65805. */
  65806. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65807. /**
  65808. * Enables an effect by name on a pipeline
  65809. * @param renderPipelineName the name of the pipeline to enable the effect in
  65810. * @param renderEffectName the name of the effect to enable
  65811. * @param cameras the cameras that the effect should be enabled on
  65812. */
  65813. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65814. /**
  65815. * Disables an effect by name on a pipeline
  65816. * @param renderPipelineName the name of the pipeline to disable the effect in
  65817. * @param renderEffectName the name of the effect to disable
  65818. * @param cameras the cameras that the effect should be disabled on
  65819. */
  65820. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65821. /**
  65822. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65823. */
  65824. update(): void;
  65825. /** @hidden */
  65826. _rebuild(): void;
  65827. /**
  65828. * Disposes of the manager and pipelines
  65829. */
  65830. dispose(): void;
  65831. }
  65832. }
  65833. declare module BABYLON {
  65834. interface Scene {
  65835. /** @hidden (Backing field) */
  65836. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65837. /**
  65838. * Gets the postprocess render pipeline manager
  65839. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65840. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65841. */
  65842. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65843. }
  65844. /**
  65845. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65846. */
  65847. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65848. /**
  65849. * The component name helpfull to identify the component in the list of scene components.
  65850. */
  65851. readonly name: string;
  65852. /**
  65853. * The scene the component belongs to.
  65854. */
  65855. scene: Scene;
  65856. /**
  65857. * Creates a new instance of the component for the given scene
  65858. * @param scene Defines the scene to register the component in
  65859. */
  65860. constructor(scene: Scene);
  65861. /**
  65862. * Registers the component in a given scene
  65863. */
  65864. register(): void;
  65865. /**
  65866. * Rebuilds the elements related to this component in case of
  65867. * context lost for instance.
  65868. */
  65869. rebuild(): void;
  65870. /**
  65871. * Disposes the component and the associated ressources
  65872. */
  65873. dispose(): void;
  65874. private _gatherRenderTargets;
  65875. }
  65876. }
  65877. declare module BABYLON {
  65878. /**
  65879. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65880. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65881. */
  65882. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65883. private _scene;
  65884. private _camerasToBeAttached;
  65885. /**
  65886. * ID of the sharpen post process,
  65887. */
  65888. private readonly SharpenPostProcessId;
  65889. /**
  65890. * @ignore
  65891. * ID of the image processing post process;
  65892. */
  65893. readonly ImageProcessingPostProcessId: string;
  65894. /**
  65895. * @ignore
  65896. * ID of the Fast Approximate Anti-Aliasing post process;
  65897. */
  65898. readonly FxaaPostProcessId: string;
  65899. /**
  65900. * ID of the chromatic aberration post process,
  65901. */
  65902. private readonly ChromaticAberrationPostProcessId;
  65903. /**
  65904. * ID of the grain post process
  65905. */
  65906. private readonly GrainPostProcessId;
  65907. /**
  65908. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65909. */
  65910. sharpen: SharpenPostProcess;
  65911. private _sharpenEffect;
  65912. private bloom;
  65913. /**
  65914. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65915. */
  65916. depthOfField: DepthOfFieldEffect;
  65917. /**
  65918. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65919. */
  65920. fxaa: FxaaPostProcess;
  65921. /**
  65922. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65923. */
  65924. imageProcessing: ImageProcessingPostProcess;
  65925. /**
  65926. * Chromatic aberration post process which will shift rgb colors in the image
  65927. */
  65928. chromaticAberration: ChromaticAberrationPostProcess;
  65929. private _chromaticAberrationEffect;
  65930. /**
  65931. * Grain post process which add noise to the image
  65932. */
  65933. grain: GrainPostProcess;
  65934. private _grainEffect;
  65935. /**
  65936. * Glow post process which adds a glow to emissive areas of the image
  65937. */
  65938. private _glowLayer;
  65939. /**
  65940. * Animations which can be used to tweak settings over a period of time
  65941. */
  65942. animations: Animation[];
  65943. private _imageProcessingConfigurationObserver;
  65944. private _sharpenEnabled;
  65945. private _bloomEnabled;
  65946. private _depthOfFieldEnabled;
  65947. private _depthOfFieldBlurLevel;
  65948. private _fxaaEnabled;
  65949. private _imageProcessingEnabled;
  65950. private _defaultPipelineTextureType;
  65951. private _bloomScale;
  65952. private _chromaticAberrationEnabled;
  65953. private _grainEnabled;
  65954. private _buildAllowed;
  65955. /**
  65956. * Gets active scene
  65957. */
  65958. get scene(): Scene;
  65959. /**
  65960. * Enable or disable the sharpen process from the pipeline
  65961. */
  65962. set sharpenEnabled(enabled: boolean);
  65963. get sharpenEnabled(): boolean;
  65964. private _resizeObserver;
  65965. private _hardwareScaleLevel;
  65966. private _bloomKernel;
  65967. /**
  65968. * Specifies the size of the bloom blur kernel, relative to the final output size
  65969. */
  65970. get bloomKernel(): number;
  65971. set bloomKernel(value: number);
  65972. /**
  65973. * Specifies the weight of the bloom in the final rendering
  65974. */
  65975. private _bloomWeight;
  65976. /**
  65977. * Specifies the luma threshold for the area that will be blurred by the bloom
  65978. */
  65979. private _bloomThreshold;
  65980. private _hdr;
  65981. /**
  65982. * The strength of the bloom.
  65983. */
  65984. set bloomWeight(value: number);
  65985. get bloomWeight(): number;
  65986. /**
  65987. * The strength of the bloom.
  65988. */
  65989. set bloomThreshold(value: number);
  65990. get bloomThreshold(): number;
  65991. /**
  65992. * The scale of the bloom, lower value will provide better performance.
  65993. */
  65994. set bloomScale(value: number);
  65995. get bloomScale(): number;
  65996. /**
  65997. * Enable or disable the bloom from the pipeline
  65998. */
  65999. set bloomEnabled(enabled: boolean);
  66000. get bloomEnabled(): boolean;
  66001. private _rebuildBloom;
  66002. /**
  66003. * If the depth of field is enabled.
  66004. */
  66005. get depthOfFieldEnabled(): boolean;
  66006. set depthOfFieldEnabled(enabled: boolean);
  66007. /**
  66008. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66009. */
  66010. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66011. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66012. /**
  66013. * If the anti aliasing is enabled.
  66014. */
  66015. set fxaaEnabled(enabled: boolean);
  66016. get fxaaEnabled(): boolean;
  66017. private _samples;
  66018. /**
  66019. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66020. */
  66021. set samples(sampleCount: number);
  66022. get samples(): number;
  66023. /**
  66024. * If image processing is enabled.
  66025. */
  66026. set imageProcessingEnabled(enabled: boolean);
  66027. get imageProcessingEnabled(): boolean;
  66028. /**
  66029. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66030. */
  66031. set glowLayerEnabled(enabled: boolean);
  66032. get glowLayerEnabled(): boolean;
  66033. /**
  66034. * Gets the glow layer (or null if not defined)
  66035. */
  66036. get glowLayer(): Nullable<GlowLayer>;
  66037. /**
  66038. * Enable or disable the chromaticAberration process from the pipeline
  66039. */
  66040. set chromaticAberrationEnabled(enabled: boolean);
  66041. get chromaticAberrationEnabled(): boolean;
  66042. /**
  66043. * Enable or disable the grain process from the pipeline
  66044. */
  66045. set grainEnabled(enabled: boolean);
  66046. get grainEnabled(): boolean;
  66047. /**
  66048. * @constructor
  66049. * @param name - The rendering pipeline name (default: "")
  66050. * @param hdr - If high dynamic range textures should be used (default: true)
  66051. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66052. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66053. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66054. */
  66055. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66056. /**
  66057. * Get the class name
  66058. * @returns "DefaultRenderingPipeline"
  66059. */
  66060. getClassName(): string;
  66061. /**
  66062. * Force the compilation of the entire pipeline.
  66063. */
  66064. prepare(): void;
  66065. private _hasCleared;
  66066. private _prevPostProcess;
  66067. private _prevPrevPostProcess;
  66068. private _setAutoClearAndTextureSharing;
  66069. private _depthOfFieldSceneObserver;
  66070. private _buildPipeline;
  66071. private _disposePostProcesses;
  66072. /**
  66073. * Adds a camera to the pipeline
  66074. * @param camera the camera to be added
  66075. */
  66076. addCamera(camera: Camera): void;
  66077. /**
  66078. * Removes a camera from the pipeline
  66079. * @param camera the camera to remove
  66080. */
  66081. removeCamera(camera: Camera): void;
  66082. /**
  66083. * Dispose of the pipeline and stop all post processes
  66084. */
  66085. dispose(): void;
  66086. /**
  66087. * Serialize the rendering pipeline (Used when exporting)
  66088. * @returns the serialized object
  66089. */
  66090. serialize(): any;
  66091. /**
  66092. * Parse the serialized pipeline
  66093. * @param source Source pipeline.
  66094. * @param scene The scene to load the pipeline to.
  66095. * @param rootUrl The URL of the serialized pipeline.
  66096. * @returns An instantiated pipeline from the serialized object.
  66097. */
  66098. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66099. }
  66100. }
  66101. declare module BABYLON {
  66102. /** @hidden */
  66103. export var lensHighlightsPixelShader: {
  66104. name: string;
  66105. shader: string;
  66106. };
  66107. }
  66108. declare module BABYLON {
  66109. /** @hidden */
  66110. export var depthOfFieldPixelShader: {
  66111. name: string;
  66112. shader: string;
  66113. };
  66114. }
  66115. declare module BABYLON {
  66116. /**
  66117. * BABYLON.JS Chromatic Aberration GLSL Shader
  66118. * Author: Olivier Guyot
  66119. * Separates very slightly R, G and B colors on the edges of the screen
  66120. * Inspired by Francois Tarlier & Martins Upitis
  66121. */
  66122. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66123. /**
  66124. * @ignore
  66125. * The chromatic aberration PostProcess id in the pipeline
  66126. */
  66127. LensChromaticAberrationEffect: string;
  66128. /**
  66129. * @ignore
  66130. * The highlights enhancing PostProcess id in the pipeline
  66131. */
  66132. HighlightsEnhancingEffect: string;
  66133. /**
  66134. * @ignore
  66135. * The depth-of-field PostProcess id in the pipeline
  66136. */
  66137. LensDepthOfFieldEffect: string;
  66138. private _scene;
  66139. private _depthTexture;
  66140. private _grainTexture;
  66141. private _chromaticAberrationPostProcess;
  66142. private _highlightsPostProcess;
  66143. private _depthOfFieldPostProcess;
  66144. private _edgeBlur;
  66145. private _grainAmount;
  66146. private _chromaticAberration;
  66147. private _distortion;
  66148. private _highlightsGain;
  66149. private _highlightsThreshold;
  66150. private _dofDistance;
  66151. private _dofAperture;
  66152. private _dofDarken;
  66153. private _dofPentagon;
  66154. private _blurNoise;
  66155. /**
  66156. * @constructor
  66157. *
  66158. * Effect parameters are as follow:
  66159. * {
  66160. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66161. * edge_blur: number; // from 0 to x (1 for realism)
  66162. * distortion: number; // from 0 to x (1 for realism)
  66163. * grain_amount: number; // from 0 to 1
  66164. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66165. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66166. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66167. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66168. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66169. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66170. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66171. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66172. * }
  66173. * Note: if an effect parameter is unset, effect is disabled
  66174. *
  66175. * @param name The rendering pipeline name
  66176. * @param parameters - An object containing all parameters (see above)
  66177. * @param scene The scene linked to this pipeline
  66178. * @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)
  66179. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66180. */
  66181. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66182. /**
  66183. * Get the class name
  66184. * @returns "LensRenderingPipeline"
  66185. */
  66186. getClassName(): string;
  66187. /**
  66188. * Gets associated scene
  66189. */
  66190. get scene(): Scene;
  66191. /**
  66192. * Gets or sets the edge blur
  66193. */
  66194. get edgeBlur(): number;
  66195. set edgeBlur(value: number);
  66196. /**
  66197. * Gets or sets the grain amount
  66198. */
  66199. get grainAmount(): number;
  66200. set grainAmount(value: number);
  66201. /**
  66202. * Gets or sets the chromatic aberration amount
  66203. */
  66204. get chromaticAberration(): number;
  66205. set chromaticAberration(value: number);
  66206. /**
  66207. * Gets or sets the depth of field aperture
  66208. */
  66209. get dofAperture(): number;
  66210. set dofAperture(value: number);
  66211. /**
  66212. * Gets or sets the edge distortion
  66213. */
  66214. get edgeDistortion(): number;
  66215. set edgeDistortion(value: number);
  66216. /**
  66217. * Gets or sets the depth of field distortion
  66218. */
  66219. get dofDistortion(): number;
  66220. set dofDistortion(value: number);
  66221. /**
  66222. * Gets or sets the darken out of focus amount
  66223. */
  66224. get darkenOutOfFocus(): number;
  66225. set darkenOutOfFocus(value: number);
  66226. /**
  66227. * Gets or sets a boolean indicating if blur noise is enabled
  66228. */
  66229. get blurNoise(): boolean;
  66230. set blurNoise(value: boolean);
  66231. /**
  66232. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66233. */
  66234. get pentagonBokeh(): boolean;
  66235. set pentagonBokeh(value: boolean);
  66236. /**
  66237. * Gets or sets the highlight grain amount
  66238. */
  66239. get highlightsGain(): number;
  66240. set highlightsGain(value: number);
  66241. /**
  66242. * Gets or sets the highlight threshold
  66243. */
  66244. get highlightsThreshold(): number;
  66245. set highlightsThreshold(value: number);
  66246. /**
  66247. * Sets the amount of blur at the edges
  66248. * @param amount blur amount
  66249. */
  66250. setEdgeBlur(amount: number): void;
  66251. /**
  66252. * Sets edge blur to 0
  66253. */
  66254. disableEdgeBlur(): void;
  66255. /**
  66256. * Sets the amout of grain
  66257. * @param amount Amount of grain
  66258. */
  66259. setGrainAmount(amount: number): void;
  66260. /**
  66261. * Set grain amount to 0
  66262. */
  66263. disableGrain(): void;
  66264. /**
  66265. * Sets the chromatic aberration amount
  66266. * @param amount amount of chromatic aberration
  66267. */
  66268. setChromaticAberration(amount: number): void;
  66269. /**
  66270. * Sets chromatic aberration amount to 0
  66271. */
  66272. disableChromaticAberration(): void;
  66273. /**
  66274. * Sets the EdgeDistortion amount
  66275. * @param amount amount of EdgeDistortion
  66276. */
  66277. setEdgeDistortion(amount: number): void;
  66278. /**
  66279. * Sets edge distortion to 0
  66280. */
  66281. disableEdgeDistortion(): void;
  66282. /**
  66283. * Sets the FocusDistance amount
  66284. * @param amount amount of FocusDistance
  66285. */
  66286. setFocusDistance(amount: number): void;
  66287. /**
  66288. * Disables depth of field
  66289. */
  66290. disableDepthOfField(): void;
  66291. /**
  66292. * Sets the Aperture amount
  66293. * @param amount amount of Aperture
  66294. */
  66295. setAperture(amount: number): void;
  66296. /**
  66297. * Sets the DarkenOutOfFocus amount
  66298. * @param amount amount of DarkenOutOfFocus
  66299. */
  66300. setDarkenOutOfFocus(amount: number): void;
  66301. private _pentagonBokehIsEnabled;
  66302. /**
  66303. * Creates a pentagon bokeh effect
  66304. */
  66305. enablePentagonBokeh(): void;
  66306. /**
  66307. * Disables the pentagon bokeh effect
  66308. */
  66309. disablePentagonBokeh(): void;
  66310. /**
  66311. * Enables noise blur
  66312. */
  66313. enableNoiseBlur(): void;
  66314. /**
  66315. * Disables noise blur
  66316. */
  66317. disableNoiseBlur(): void;
  66318. /**
  66319. * Sets the HighlightsGain amount
  66320. * @param amount amount of HighlightsGain
  66321. */
  66322. setHighlightsGain(amount: number): void;
  66323. /**
  66324. * Sets the HighlightsThreshold amount
  66325. * @param amount amount of HighlightsThreshold
  66326. */
  66327. setHighlightsThreshold(amount: number): void;
  66328. /**
  66329. * Disables highlights
  66330. */
  66331. disableHighlights(): void;
  66332. /**
  66333. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66334. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66335. */
  66336. dispose(disableDepthRender?: boolean): void;
  66337. private _createChromaticAberrationPostProcess;
  66338. private _createHighlightsPostProcess;
  66339. private _createDepthOfFieldPostProcess;
  66340. private _createGrainTexture;
  66341. }
  66342. }
  66343. declare module BABYLON {
  66344. /** @hidden */
  66345. export var ssao2PixelShader: {
  66346. name: string;
  66347. shader: string;
  66348. };
  66349. }
  66350. declare module BABYLON {
  66351. /** @hidden */
  66352. export var ssaoCombinePixelShader: {
  66353. name: string;
  66354. shader: string;
  66355. };
  66356. }
  66357. declare module BABYLON {
  66358. /**
  66359. * Render pipeline to produce ssao effect
  66360. */
  66361. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66362. /**
  66363. * @ignore
  66364. * The PassPostProcess id in the pipeline that contains the original scene color
  66365. */
  66366. SSAOOriginalSceneColorEffect: string;
  66367. /**
  66368. * @ignore
  66369. * The SSAO PostProcess id in the pipeline
  66370. */
  66371. SSAORenderEffect: string;
  66372. /**
  66373. * @ignore
  66374. * The horizontal blur PostProcess id in the pipeline
  66375. */
  66376. SSAOBlurHRenderEffect: string;
  66377. /**
  66378. * @ignore
  66379. * The vertical blur PostProcess id in the pipeline
  66380. */
  66381. SSAOBlurVRenderEffect: string;
  66382. /**
  66383. * @ignore
  66384. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66385. */
  66386. SSAOCombineRenderEffect: string;
  66387. /**
  66388. * The output strength of the SSAO post-process. Default value is 1.0.
  66389. */
  66390. totalStrength: number;
  66391. /**
  66392. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66393. */
  66394. maxZ: number;
  66395. /**
  66396. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66397. */
  66398. minZAspect: number;
  66399. private _samples;
  66400. /**
  66401. * Number of samples used for the SSAO calculations. Default value is 8
  66402. */
  66403. set samples(n: number);
  66404. get samples(): number;
  66405. private _textureSamples;
  66406. /**
  66407. * Number of samples to use for antialiasing
  66408. */
  66409. set textureSamples(n: number);
  66410. get textureSamples(): number;
  66411. /**
  66412. * Ratio object used for SSAO ratio and blur ratio
  66413. */
  66414. private _ratio;
  66415. /**
  66416. * Dynamically generated sphere sampler.
  66417. */
  66418. private _sampleSphere;
  66419. /**
  66420. * Blur filter offsets
  66421. */
  66422. private _samplerOffsets;
  66423. private _expensiveBlur;
  66424. /**
  66425. * If bilateral blur should be used
  66426. */
  66427. set expensiveBlur(b: boolean);
  66428. get expensiveBlur(): boolean;
  66429. /**
  66430. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66431. */
  66432. radius: number;
  66433. /**
  66434. * The base color of the SSAO post-process
  66435. * The final result is "base + ssao" between [0, 1]
  66436. */
  66437. base: number;
  66438. /**
  66439. * Support test.
  66440. */
  66441. static get IsSupported(): boolean;
  66442. private _scene;
  66443. private _depthTexture;
  66444. private _normalTexture;
  66445. private _randomTexture;
  66446. private _originalColorPostProcess;
  66447. private _ssaoPostProcess;
  66448. private _blurHPostProcess;
  66449. private _blurVPostProcess;
  66450. private _ssaoCombinePostProcess;
  66451. /**
  66452. * Gets active scene
  66453. */
  66454. get scene(): Scene;
  66455. /**
  66456. * @constructor
  66457. * @param name The rendering pipeline name
  66458. * @param scene The scene linked to this pipeline
  66459. * @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 }
  66460. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66461. */
  66462. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66463. /**
  66464. * Get the class name
  66465. * @returns "SSAO2RenderingPipeline"
  66466. */
  66467. getClassName(): string;
  66468. /**
  66469. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66470. */
  66471. dispose(disableGeometryBufferRenderer?: boolean): void;
  66472. private _createBlurPostProcess;
  66473. /** @hidden */
  66474. _rebuild(): void;
  66475. private _bits;
  66476. private _radicalInverse_VdC;
  66477. private _hammersley;
  66478. private _hemisphereSample_uniform;
  66479. private _generateHemisphere;
  66480. private _createSSAOPostProcess;
  66481. private _createSSAOCombinePostProcess;
  66482. private _createRandomTexture;
  66483. /**
  66484. * Serialize the rendering pipeline (Used when exporting)
  66485. * @returns the serialized object
  66486. */
  66487. serialize(): any;
  66488. /**
  66489. * Parse the serialized pipeline
  66490. * @param source Source pipeline.
  66491. * @param scene The scene to load the pipeline to.
  66492. * @param rootUrl The URL of the serialized pipeline.
  66493. * @returns An instantiated pipeline from the serialized object.
  66494. */
  66495. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66496. }
  66497. }
  66498. declare module BABYLON {
  66499. /** @hidden */
  66500. export var ssaoPixelShader: {
  66501. name: string;
  66502. shader: string;
  66503. };
  66504. }
  66505. declare module BABYLON {
  66506. /**
  66507. * Render pipeline to produce ssao effect
  66508. */
  66509. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66510. /**
  66511. * @ignore
  66512. * The PassPostProcess id in the pipeline that contains the original scene color
  66513. */
  66514. SSAOOriginalSceneColorEffect: string;
  66515. /**
  66516. * @ignore
  66517. * The SSAO PostProcess id in the pipeline
  66518. */
  66519. SSAORenderEffect: string;
  66520. /**
  66521. * @ignore
  66522. * The horizontal blur PostProcess id in the pipeline
  66523. */
  66524. SSAOBlurHRenderEffect: string;
  66525. /**
  66526. * @ignore
  66527. * The vertical blur PostProcess id in the pipeline
  66528. */
  66529. SSAOBlurVRenderEffect: string;
  66530. /**
  66531. * @ignore
  66532. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66533. */
  66534. SSAOCombineRenderEffect: string;
  66535. /**
  66536. * The output strength of the SSAO post-process. Default value is 1.0.
  66537. */
  66538. totalStrength: number;
  66539. /**
  66540. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66541. */
  66542. radius: number;
  66543. /**
  66544. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66545. * Must not be equal to fallOff and superior to fallOff.
  66546. * Default value is 0.0075
  66547. */
  66548. area: number;
  66549. /**
  66550. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66551. * Must not be equal to area and inferior to area.
  66552. * Default value is 0.000001
  66553. */
  66554. fallOff: number;
  66555. /**
  66556. * The base color of the SSAO post-process
  66557. * The final result is "base + ssao" between [0, 1]
  66558. */
  66559. base: number;
  66560. private _scene;
  66561. private _depthTexture;
  66562. private _randomTexture;
  66563. private _originalColorPostProcess;
  66564. private _ssaoPostProcess;
  66565. private _blurHPostProcess;
  66566. private _blurVPostProcess;
  66567. private _ssaoCombinePostProcess;
  66568. private _firstUpdate;
  66569. /**
  66570. * Gets active scene
  66571. */
  66572. get scene(): Scene;
  66573. /**
  66574. * @constructor
  66575. * @param name - The rendering pipeline name
  66576. * @param scene - The scene linked to this pipeline
  66577. * @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 }
  66578. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66579. */
  66580. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66581. /**
  66582. * Get the class name
  66583. * @returns "SSAORenderingPipeline"
  66584. */
  66585. getClassName(): string;
  66586. /**
  66587. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66588. */
  66589. dispose(disableDepthRender?: boolean): void;
  66590. private _createBlurPostProcess;
  66591. /** @hidden */
  66592. _rebuild(): void;
  66593. private _createSSAOPostProcess;
  66594. private _createSSAOCombinePostProcess;
  66595. private _createRandomTexture;
  66596. }
  66597. }
  66598. declare module BABYLON {
  66599. /** @hidden */
  66600. export var screenSpaceReflectionPixelShader: {
  66601. name: string;
  66602. shader: string;
  66603. };
  66604. }
  66605. declare module BABYLON {
  66606. /**
  66607. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66608. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66609. */
  66610. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66611. /**
  66612. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66613. */
  66614. threshold: number;
  66615. /**
  66616. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66617. */
  66618. strength: number;
  66619. /**
  66620. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66621. */
  66622. reflectionSpecularFalloffExponent: number;
  66623. /**
  66624. * 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]
  66625. */
  66626. step: number;
  66627. /**
  66628. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66629. */
  66630. roughnessFactor: number;
  66631. private _geometryBufferRenderer;
  66632. private _enableSmoothReflections;
  66633. private _reflectionSamples;
  66634. private _smoothSteps;
  66635. /**
  66636. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66637. * @param name The name of the effect.
  66638. * @param scene The scene containing the objects to calculate reflections.
  66639. * @param options The required width/height ratio to downsize to before computing the render pass.
  66640. * @param camera The camera to apply the render pass to.
  66641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66642. * @param engine The engine which the post process will be applied. (default: current engine)
  66643. * @param reusable If the post process can be reused on the same frame. (default: false)
  66644. * @param textureType Type of textures used when performing the post process. (default: 0)
  66645. * @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)
  66646. */
  66647. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66648. /**
  66649. * Gets wether or not smoothing reflections is enabled.
  66650. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66651. */
  66652. get enableSmoothReflections(): boolean;
  66653. /**
  66654. * Sets wether or not smoothing reflections is enabled.
  66655. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66656. */
  66657. set enableSmoothReflections(enabled: boolean);
  66658. /**
  66659. * Gets the number of samples taken while computing reflections. More samples count is high,
  66660. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66661. */
  66662. get reflectionSamples(): number;
  66663. /**
  66664. * Sets the number of samples taken while computing reflections. More samples count is high,
  66665. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66666. */
  66667. set reflectionSamples(samples: number);
  66668. /**
  66669. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66670. * more the post-process will require GPU power and can generate a drop in FPS.
  66671. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66672. */
  66673. get smoothSteps(): number;
  66674. set smoothSteps(steps: number);
  66675. private _updateEffectDefines;
  66676. }
  66677. }
  66678. declare module BABYLON {
  66679. /** @hidden */
  66680. export var standardPixelShader: {
  66681. name: string;
  66682. shader: string;
  66683. };
  66684. }
  66685. declare module BABYLON {
  66686. /**
  66687. * Standard rendering pipeline
  66688. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66689. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66690. */
  66691. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66692. /**
  66693. * Public members
  66694. */
  66695. /**
  66696. * Post-process which contains the original scene color before the pipeline applies all the effects
  66697. */
  66698. originalPostProcess: Nullable<PostProcess>;
  66699. /**
  66700. * Post-process used to down scale an image x4
  66701. */
  66702. downSampleX4PostProcess: Nullable<PostProcess>;
  66703. /**
  66704. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66705. */
  66706. brightPassPostProcess: Nullable<PostProcess>;
  66707. /**
  66708. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66709. */
  66710. blurHPostProcesses: PostProcess[];
  66711. /**
  66712. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66713. */
  66714. blurVPostProcesses: PostProcess[];
  66715. /**
  66716. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66717. */
  66718. textureAdderPostProcess: Nullable<PostProcess>;
  66719. /**
  66720. * Post-process used to create volumetric lighting effect
  66721. */
  66722. volumetricLightPostProcess: Nullable<PostProcess>;
  66723. /**
  66724. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66725. */
  66726. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66727. /**
  66728. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66729. */
  66730. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66731. /**
  66732. * Post-process used to merge the volumetric light effect and the real scene color
  66733. */
  66734. volumetricLightMergePostProces: Nullable<PostProcess>;
  66735. /**
  66736. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66737. */
  66738. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66739. /**
  66740. * Base post-process used to calculate the average luminance of the final image for HDR
  66741. */
  66742. luminancePostProcess: Nullable<PostProcess>;
  66743. /**
  66744. * Post-processes used to create down sample post-processes in order to get
  66745. * the average luminance of the final image for HDR
  66746. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66747. */
  66748. luminanceDownSamplePostProcesses: PostProcess[];
  66749. /**
  66750. * Post-process used to create a HDR effect (light adaptation)
  66751. */
  66752. hdrPostProcess: Nullable<PostProcess>;
  66753. /**
  66754. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66755. */
  66756. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66757. /**
  66758. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66759. */
  66760. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66761. /**
  66762. * Post-process used to merge the final HDR post-process and the real scene color
  66763. */
  66764. hdrFinalPostProcess: Nullable<PostProcess>;
  66765. /**
  66766. * Post-process used to create a lens flare effect
  66767. */
  66768. lensFlarePostProcess: Nullable<PostProcess>;
  66769. /**
  66770. * Post-process that merges the result of the lens flare post-process and the real scene color
  66771. */
  66772. lensFlareComposePostProcess: Nullable<PostProcess>;
  66773. /**
  66774. * Post-process used to create a motion blur effect
  66775. */
  66776. motionBlurPostProcess: Nullable<PostProcess>;
  66777. /**
  66778. * Post-process used to create a depth of field effect
  66779. */
  66780. depthOfFieldPostProcess: Nullable<PostProcess>;
  66781. /**
  66782. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66783. */
  66784. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66785. /**
  66786. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66787. */
  66788. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66789. /**
  66790. * Represents the brightness threshold in order to configure the illuminated surfaces
  66791. */
  66792. brightThreshold: number;
  66793. /**
  66794. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66795. */
  66796. blurWidth: number;
  66797. /**
  66798. * Sets if the blur for highlighted surfaces must be only horizontal
  66799. */
  66800. horizontalBlur: boolean;
  66801. /**
  66802. * Gets the overall exposure used by the pipeline
  66803. */
  66804. get exposure(): number;
  66805. /**
  66806. * Sets the overall exposure used by the pipeline
  66807. */
  66808. set exposure(value: number);
  66809. /**
  66810. * Texture used typically to simulate "dirty" on camera lens
  66811. */
  66812. lensTexture: Nullable<Texture>;
  66813. /**
  66814. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66815. */
  66816. volumetricLightCoefficient: number;
  66817. /**
  66818. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66819. */
  66820. volumetricLightPower: number;
  66821. /**
  66822. * Used the set the blur intensity to smooth the volumetric lights
  66823. */
  66824. volumetricLightBlurScale: number;
  66825. /**
  66826. * Light (spot or directional) used to generate the volumetric lights rays
  66827. * The source light must have a shadow generate so the pipeline can get its
  66828. * depth map
  66829. */
  66830. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66831. /**
  66832. * For eye adaptation, represents the minimum luminance the eye can see
  66833. */
  66834. hdrMinimumLuminance: number;
  66835. /**
  66836. * For eye adaptation, represents the decrease luminance speed
  66837. */
  66838. hdrDecreaseRate: number;
  66839. /**
  66840. * For eye adaptation, represents the increase luminance speed
  66841. */
  66842. hdrIncreaseRate: number;
  66843. /**
  66844. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66845. */
  66846. get hdrAutoExposure(): boolean;
  66847. /**
  66848. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66849. */
  66850. set hdrAutoExposure(value: boolean);
  66851. /**
  66852. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66853. */
  66854. lensColorTexture: Nullable<Texture>;
  66855. /**
  66856. * The overall strengh for the lens flare effect
  66857. */
  66858. lensFlareStrength: number;
  66859. /**
  66860. * Dispersion coefficient for lens flare ghosts
  66861. */
  66862. lensFlareGhostDispersal: number;
  66863. /**
  66864. * Main lens flare halo width
  66865. */
  66866. lensFlareHaloWidth: number;
  66867. /**
  66868. * Based on the lens distortion effect, defines how much the lens flare result
  66869. * is distorted
  66870. */
  66871. lensFlareDistortionStrength: number;
  66872. /**
  66873. * Configures the blur intensity used for for lens flare (halo)
  66874. */
  66875. lensFlareBlurWidth: number;
  66876. /**
  66877. * Lens star texture must be used to simulate rays on the flares and is available
  66878. * in the documentation
  66879. */
  66880. lensStarTexture: Nullable<Texture>;
  66881. /**
  66882. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66883. * flare effect by taking account of the dirt texture
  66884. */
  66885. lensFlareDirtTexture: Nullable<Texture>;
  66886. /**
  66887. * Represents the focal length for the depth of field effect
  66888. */
  66889. depthOfFieldDistance: number;
  66890. /**
  66891. * Represents the blur intensity for the blurred part of the depth of field effect
  66892. */
  66893. depthOfFieldBlurWidth: number;
  66894. /**
  66895. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66896. */
  66897. get motionStrength(): number;
  66898. /**
  66899. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66900. */
  66901. set motionStrength(strength: number);
  66902. /**
  66903. * Gets wether or not the motion blur post-process is object based or screen based.
  66904. */
  66905. get objectBasedMotionBlur(): boolean;
  66906. /**
  66907. * Sets wether or not the motion blur post-process should be object based or screen based
  66908. */
  66909. set objectBasedMotionBlur(value: boolean);
  66910. /**
  66911. * List of animations for the pipeline (IAnimatable implementation)
  66912. */
  66913. animations: Animation[];
  66914. /**
  66915. * Private members
  66916. */
  66917. private _scene;
  66918. private _currentDepthOfFieldSource;
  66919. private _basePostProcess;
  66920. private _fixedExposure;
  66921. private _currentExposure;
  66922. private _hdrAutoExposure;
  66923. private _hdrCurrentLuminance;
  66924. private _motionStrength;
  66925. private _isObjectBasedMotionBlur;
  66926. private _floatTextureType;
  66927. private _camerasToBeAttached;
  66928. private _ratio;
  66929. private _bloomEnabled;
  66930. private _depthOfFieldEnabled;
  66931. private _vlsEnabled;
  66932. private _lensFlareEnabled;
  66933. private _hdrEnabled;
  66934. private _motionBlurEnabled;
  66935. private _fxaaEnabled;
  66936. private _screenSpaceReflectionsEnabled;
  66937. private _motionBlurSamples;
  66938. private _volumetricLightStepsCount;
  66939. private _samples;
  66940. /**
  66941. * @ignore
  66942. * Specifies if the bloom pipeline is enabled
  66943. */
  66944. get BloomEnabled(): boolean;
  66945. set BloomEnabled(enabled: boolean);
  66946. /**
  66947. * @ignore
  66948. * Specifies if the depth of field pipeline is enabed
  66949. */
  66950. get DepthOfFieldEnabled(): boolean;
  66951. set DepthOfFieldEnabled(enabled: boolean);
  66952. /**
  66953. * @ignore
  66954. * Specifies if the lens flare pipeline is enabed
  66955. */
  66956. get LensFlareEnabled(): boolean;
  66957. set LensFlareEnabled(enabled: boolean);
  66958. /**
  66959. * @ignore
  66960. * Specifies if the HDR pipeline is enabled
  66961. */
  66962. get HDREnabled(): boolean;
  66963. set HDREnabled(enabled: boolean);
  66964. /**
  66965. * @ignore
  66966. * Specifies if the volumetric lights scattering effect is enabled
  66967. */
  66968. get VLSEnabled(): boolean;
  66969. set VLSEnabled(enabled: boolean);
  66970. /**
  66971. * @ignore
  66972. * Specifies if the motion blur effect is enabled
  66973. */
  66974. get MotionBlurEnabled(): boolean;
  66975. set MotionBlurEnabled(enabled: boolean);
  66976. /**
  66977. * Specifies if anti-aliasing is enabled
  66978. */
  66979. get fxaaEnabled(): boolean;
  66980. set fxaaEnabled(enabled: boolean);
  66981. /**
  66982. * Specifies if screen space reflections are enabled.
  66983. */
  66984. get screenSpaceReflectionsEnabled(): boolean;
  66985. set screenSpaceReflectionsEnabled(enabled: boolean);
  66986. /**
  66987. * Specifies the number of steps used to calculate the volumetric lights
  66988. * Typically in interval [50, 200]
  66989. */
  66990. get volumetricLightStepsCount(): number;
  66991. set volumetricLightStepsCount(count: number);
  66992. /**
  66993. * Specifies the number of samples used for the motion blur effect
  66994. * Typically in interval [16, 64]
  66995. */
  66996. get motionBlurSamples(): number;
  66997. set motionBlurSamples(samples: number);
  66998. /**
  66999. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67000. */
  67001. get samples(): number;
  67002. set samples(sampleCount: number);
  67003. /**
  67004. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67005. * @constructor
  67006. * @param name The rendering pipeline name
  67007. * @param scene The scene linked to this pipeline
  67008. * @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)
  67009. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67010. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67011. */
  67012. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67013. private _buildPipeline;
  67014. private _createDownSampleX4PostProcess;
  67015. private _createBrightPassPostProcess;
  67016. private _createBlurPostProcesses;
  67017. private _createTextureAdderPostProcess;
  67018. private _createVolumetricLightPostProcess;
  67019. private _createLuminancePostProcesses;
  67020. private _createHdrPostProcess;
  67021. private _createLensFlarePostProcess;
  67022. private _createDepthOfFieldPostProcess;
  67023. private _createMotionBlurPostProcess;
  67024. private _getDepthTexture;
  67025. private _disposePostProcesses;
  67026. /**
  67027. * Dispose of the pipeline and stop all post processes
  67028. */
  67029. dispose(): void;
  67030. /**
  67031. * Serialize the rendering pipeline (Used when exporting)
  67032. * @returns the serialized object
  67033. */
  67034. serialize(): any;
  67035. /**
  67036. * Parse the serialized pipeline
  67037. * @param source Source pipeline.
  67038. * @param scene The scene to load the pipeline to.
  67039. * @param rootUrl The URL of the serialized pipeline.
  67040. * @returns An instantiated pipeline from the serialized object.
  67041. */
  67042. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67043. /**
  67044. * Luminance steps
  67045. */
  67046. static LuminanceSteps: number;
  67047. }
  67048. }
  67049. declare module BABYLON {
  67050. /** @hidden */
  67051. export var tonemapPixelShader: {
  67052. name: string;
  67053. shader: string;
  67054. };
  67055. }
  67056. declare module BABYLON {
  67057. /** Defines operator used for tonemapping */
  67058. export enum TonemappingOperator {
  67059. /** Hable */
  67060. Hable = 0,
  67061. /** Reinhard */
  67062. Reinhard = 1,
  67063. /** HejiDawson */
  67064. HejiDawson = 2,
  67065. /** Photographic */
  67066. Photographic = 3
  67067. }
  67068. /**
  67069. * Defines a post process to apply tone mapping
  67070. */
  67071. export class TonemapPostProcess extends PostProcess {
  67072. private _operator;
  67073. /** Defines the required exposure adjustement */
  67074. exposureAdjustment: number;
  67075. /**
  67076. * Creates a new TonemapPostProcess
  67077. * @param name defines the name of the postprocess
  67078. * @param _operator defines the operator to use
  67079. * @param exposureAdjustment defines the required exposure adjustement
  67080. * @param camera defines the camera to use (can be null)
  67081. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67082. * @param engine defines the hosting engine (can be ignore if camera is set)
  67083. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67084. */
  67085. constructor(name: string, _operator: TonemappingOperator,
  67086. /** Defines the required exposure adjustement */
  67087. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67088. }
  67089. }
  67090. declare module BABYLON {
  67091. /** @hidden */
  67092. export var volumetricLightScatteringPixelShader: {
  67093. name: string;
  67094. shader: string;
  67095. };
  67096. }
  67097. declare module BABYLON {
  67098. /** @hidden */
  67099. export var volumetricLightScatteringPassVertexShader: {
  67100. name: string;
  67101. shader: string;
  67102. };
  67103. }
  67104. declare module BABYLON {
  67105. /** @hidden */
  67106. export var volumetricLightScatteringPassPixelShader: {
  67107. name: string;
  67108. shader: string;
  67109. };
  67110. }
  67111. declare module BABYLON {
  67112. /**
  67113. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67114. */
  67115. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67116. private _volumetricLightScatteringPass;
  67117. private _volumetricLightScatteringRTT;
  67118. private _viewPort;
  67119. private _screenCoordinates;
  67120. private _cachedDefines;
  67121. /**
  67122. * If not undefined, the mesh position is computed from the attached node position
  67123. */
  67124. attachedNode: {
  67125. position: Vector3;
  67126. };
  67127. /**
  67128. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67129. */
  67130. customMeshPosition: Vector3;
  67131. /**
  67132. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67133. */
  67134. useCustomMeshPosition: boolean;
  67135. /**
  67136. * If the post-process should inverse the light scattering direction
  67137. */
  67138. invert: boolean;
  67139. /**
  67140. * The internal mesh used by the post-process
  67141. */
  67142. mesh: Mesh;
  67143. /**
  67144. * @hidden
  67145. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67146. */
  67147. get useDiffuseColor(): boolean;
  67148. set useDiffuseColor(useDiffuseColor: boolean);
  67149. /**
  67150. * Array containing the excluded meshes not rendered in the internal pass
  67151. */
  67152. excludedMeshes: AbstractMesh[];
  67153. /**
  67154. * Controls the overall intensity of the post-process
  67155. */
  67156. exposure: number;
  67157. /**
  67158. * Dissipates each sample's contribution in range [0, 1]
  67159. */
  67160. decay: number;
  67161. /**
  67162. * Controls the overall intensity of each sample
  67163. */
  67164. weight: number;
  67165. /**
  67166. * Controls the density of each sample
  67167. */
  67168. density: number;
  67169. /**
  67170. * @constructor
  67171. * @param name The post-process name
  67172. * @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)
  67173. * @param camera The camera that the post-process will be attached to
  67174. * @param mesh The mesh used to create the light scattering
  67175. * @param samples The post-process quality, default 100
  67176. * @param samplingModeThe post-process filtering mode
  67177. * @param engine The babylon engine
  67178. * @param reusable If the post-process is reusable
  67179. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67180. */
  67181. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67182. /**
  67183. * Returns the string "VolumetricLightScatteringPostProcess"
  67184. * @returns "VolumetricLightScatteringPostProcess"
  67185. */
  67186. getClassName(): string;
  67187. private _isReady;
  67188. /**
  67189. * Sets the new light position for light scattering effect
  67190. * @param position The new custom light position
  67191. */
  67192. setCustomMeshPosition(position: Vector3): void;
  67193. /**
  67194. * Returns the light position for light scattering effect
  67195. * @return Vector3 The custom light position
  67196. */
  67197. getCustomMeshPosition(): Vector3;
  67198. /**
  67199. * Disposes the internal assets and detaches the post-process from the camera
  67200. */
  67201. dispose(camera: Camera): void;
  67202. /**
  67203. * Returns the render target texture used by the post-process
  67204. * @return the render target texture used by the post-process
  67205. */
  67206. getPass(): RenderTargetTexture;
  67207. private _meshExcluded;
  67208. private _createPass;
  67209. private _updateMeshScreenCoordinates;
  67210. /**
  67211. * Creates a default mesh for the Volumeric Light Scattering post-process
  67212. * @param name The mesh name
  67213. * @param scene The scene where to create the mesh
  67214. * @return the default mesh
  67215. */
  67216. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67217. }
  67218. }
  67219. declare module BABYLON {
  67220. interface Scene {
  67221. /** @hidden (Backing field) */
  67222. _boundingBoxRenderer: BoundingBoxRenderer;
  67223. /** @hidden (Backing field) */
  67224. _forceShowBoundingBoxes: boolean;
  67225. /**
  67226. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67227. */
  67228. forceShowBoundingBoxes: boolean;
  67229. /**
  67230. * Gets the bounding box renderer associated with the scene
  67231. * @returns a BoundingBoxRenderer
  67232. */
  67233. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67234. }
  67235. interface AbstractMesh {
  67236. /** @hidden (Backing field) */
  67237. _showBoundingBox: boolean;
  67238. /**
  67239. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67240. */
  67241. showBoundingBox: boolean;
  67242. }
  67243. /**
  67244. * Component responsible of rendering the bounding box of the meshes in a scene.
  67245. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67246. */
  67247. export class BoundingBoxRenderer implements ISceneComponent {
  67248. /**
  67249. * The component name helpfull to identify the component in the list of scene components.
  67250. */
  67251. readonly name: string;
  67252. /**
  67253. * The scene the component belongs to.
  67254. */
  67255. scene: Scene;
  67256. /**
  67257. * Color of the bounding box lines placed in front of an object
  67258. */
  67259. frontColor: Color3;
  67260. /**
  67261. * Color of the bounding box lines placed behind an object
  67262. */
  67263. backColor: Color3;
  67264. /**
  67265. * Defines if the renderer should show the back lines or not
  67266. */
  67267. showBackLines: boolean;
  67268. /**
  67269. * @hidden
  67270. */
  67271. renderList: SmartArray<BoundingBox>;
  67272. private _colorShader;
  67273. private _vertexBuffers;
  67274. private _indexBuffer;
  67275. private _fillIndexBuffer;
  67276. private _fillIndexData;
  67277. /**
  67278. * Instantiates a new bounding box renderer in a scene.
  67279. * @param scene the scene the renderer renders in
  67280. */
  67281. constructor(scene: Scene);
  67282. /**
  67283. * Registers the component in a given scene
  67284. */
  67285. register(): void;
  67286. private _evaluateSubMesh;
  67287. private _activeMesh;
  67288. private _prepareRessources;
  67289. private _createIndexBuffer;
  67290. /**
  67291. * Rebuilds the elements related to this component in case of
  67292. * context lost for instance.
  67293. */
  67294. rebuild(): void;
  67295. /**
  67296. * @hidden
  67297. */
  67298. reset(): void;
  67299. /**
  67300. * Render the bounding boxes of a specific rendering group
  67301. * @param renderingGroupId defines the rendering group to render
  67302. */
  67303. render(renderingGroupId: number): void;
  67304. /**
  67305. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67306. * @param mesh Define the mesh to render the occlusion bounding box for
  67307. */
  67308. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67309. /**
  67310. * Dispose and release the resources attached to this renderer.
  67311. */
  67312. dispose(): void;
  67313. }
  67314. }
  67315. declare module BABYLON {
  67316. interface Scene {
  67317. /** @hidden (Backing field) */
  67318. _depthRenderer: {
  67319. [id: string]: DepthRenderer;
  67320. };
  67321. /**
  67322. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67323. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67324. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67325. * @returns the created depth renderer
  67326. */
  67327. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67328. /**
  67329. * Disables a depth renderer for a given camera
  67330. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67331. */
  67332. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67333. }
  67334. /**
  67335. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67336. * in several rendering techniques.
  67337. */
  67338. export class DepthRendererSceneComponent implements ISceneComponent {
  67339. /**
  67340. * The component name helpfull to identify the component in the list of scene components.
  67341. */
  67342. readonly name: string;
  67343. /**
  67344. * The scene the component belongs to.
  67345. */
  67346. scene: Scene;
  67347. /**
  67348. * Creates a new instance of the component for the given scene
  67349. * @param scene Defines the scene to register the component in
  67350. */
  67351. constructor(scene: Scene);
  67352. /**
  67353. * Registers the component in a given scene
  67354. */
  67355. register(): void;
  67356. /**
  67357. * Rebuilds the elements related to this component in case of
  67358. * context lost for instance.
  67359. */
  67360. rebuild(): void;
  67361. /**
  67362. * Disposes the component and the associated ressources
  67363. */
  67364. dispose(): void;
  67365. private _gatherRenderTargets;
  67366. private _gatherActiveCameraRenderTargets;
  67367. }
  67368. }
  67369. declare module BABYLON {
  67370. /** @hidden */
  67371. export var outlinePixelShader: {
  67372. name: string;
  67373. shader: string;
  67374. };
  67375. }
  67376. declare module BABYLON {
  67377. /** @hidden */
  67378. export var outlineVertexShader: {
  67379. name: string;
  67380. shader: string;
  67381. };
  67382. }
  67383. declare module BABYLON {
  67384. interface Scene {
  67385. /** @hidden */
  67386. _outlineRenderer: OutlineRenderer;
  67387. /**
  67388. * Gets the outline renderer associated with the scene
  67389. * @returns a OutlineRenderer
  67390. */
  67391. getOutlineRenderer(): OutlineRenderer;
  67392. }
  67393. interface AbstractMesh {
  67394. /** @hidden (Backing field) */
  67395. _renderOutline: boolean;
  67396. /**
  67397. * Gets or sets a boolean indicating if the outline must be rendered as well
  67398. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67399. */
  67400. renderOutline: boolean;
  67401. /** @hidden (Backing field) */
  67402. _renderOverlay: boolean;
  67403. /**
  67404. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67405. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67406. */
  67407. renderOverlay: boolean;
  67408. }
  67409. /**
  67410. * This class is responsible to draw bothe outline/overlay of meshes.
  67411. * It should not be used directly but through the available method on mesh.
  67412. */
  67413. export class OutlineRenderer implements ISceneComponent {
  67414. /**
  67415. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67416. */
  67417. private static _StencilReference;
  67418. /**
  67419. * The name of the component. Each component must have a unique name.
  67420. */
  67421. name: string;
  67422. /**
  67423. * The scene the component belongs to.
  67424. */
  67425. scene: Scene;
  67426. /**
  67427. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67428. */
  67429. zOffset: number;
  67430. private _engine;
  67431. private _effect;
  67432. private _cachedDefines;
  67433. private _savedDepthWrite;
  67434. /**
  67435. * Instantiates a new outline renderer. (There could be only one per scene).
  67436. * @param scene Defines the scene it belongs to
  67437. */
  67438. constructor(scene: Scene);
  67439. /**
  67440. * Register the component to one instance of a scene.
  67441. */
  67442. register(): void;
  67443. /**
  67444. * Rebuilds the elements related to this component in case of
  67445. * context lost for instance.
  67446. */
  67447. rebuild(): void;
  67448. /**
  67449. * Disposes the component and the associated ressources.
  67450. */
  67451. dispose(): void;
  67452. /**
  67453. * Renders the outline in the canvas.
  67454. * @param subMesh Defines the sumesh to render
  67455. * @param batch Defines the batch of meshes in case of instances
  67456. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67457. */
  67458. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67459. /**
  67460. * Returns whether or not the outline renderer is ready for a given submesh.
  67461. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67462. * @param subMesh Defines the submesh to check readyness for
  67463. * @param useInstances Defines wheter wee are trying to render instances or not
  67464. * @returns true if ready otherwise false
  67465. */
  67466. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67467. private _beforeRenderingMesh;
  67468. private _afterRenderingMesh;
  67469. }
  67470. }
  67471. declare module BABYLON {
  67472. /**
  67473. * Defines the basic options interface of a Sprite Frame Source Size.
  67474. */
  67475. export interface ISpriteJSONSpriteSourceSize {
  67476. /**
  67477. * number of the original width of the Frame
  67478. */
  67479. w: number;
  67480. /**
  67481. * number of the original height of the Frame
  67482. */
  67483. h: number;
  67484. }
  67485. /**
  67486. * Defines the basic options interface of a Sprite Frame Data.
  67487. */
  67488. export interface ISpriteJSONSpriteFrameData {
  67489. /**
  67490. * number of the x offset of the Frame
  67491. */
  67492. x: number;
  67493. /**
  67494. * number of the y offset of the Frame
  67495. */
  67496. y: number;
  67497. /**
  67498. * number of the width of the Frame
  67499. */
  67500. w: number;
  67501. /**
  67502. * number of the height of the Frame
  67503. */
  67504. h: number;
  67505. }
  67506. /**
  67507. * Defines the basic options interface of a JSON Sprite.
  67508. */
  67509. export interface ISpriteJSONSprite {
  67510. /**
  67511. * string name of the Frame
  67512. */
  67513. filename: string;
  67514. /**
  67515. * ISpriteJSONSpriteFrame basic object of the frame data
  67516. */
  67517. frame: ISpriteJSONSpriteFrameData;
  67518. /**
  67519. * boolean to flag is the frame was rotated.
  67520. */
  67521. rotated: boolean;
  67522. /**
  67523. * boolean to flag is the frame was trimmed.
  67524. */
  67525. trimmed: boolean;
  67526. /**
  67527. * ISpriteJSONSpriteFrame basic object of the source data
  67528. */
  67529. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67530. /**
  67531. * ISpriteJSONSpriteFrame basic object of the source data
  67532. */
  67533. sourceSize: ISpriteJSONSpriteSourceSize;
  67534. }
  67535. /**
  67536. * Defines the basic options interface of a JSON atlas.
  67537. */
  67538. export interface ISpriteJSONAtlas {
  67539. /**
  67540. * Array of objects that contain the frame data.
  67541. */
  67542. frames: Array<ISpriteJSONSprite>;
  67543. /**
  67544. * object basic object containing the sprite meta data.
  67545. */
  67546. meta?: object;
  67547. }
  67548. }
  67549. declare module BABYLON {
  67550. /** @hidden */
  67551. export var spriteMapPixelShader: {
  67552. name: string;
  67553. shader: string;
  67554. };
  67555. }
  67556. declare module BABYLON {
  67557. /** @hidden */
  67558. export var spriteMapVertexShader: {
  67559. name: string;
  67560. shader: string;
  67561. };
  67562. }
  67563. declare module BABYLON {
  67564. /**
  67565. * Defines the basic options interface of a SpriteMap
  67566. */
  67567. export interface ISpriteMapOptions {
  67568. /**
  67569. * Vector2 of the number of cells in the grid.
  67570. */
  67571. stageSize?: Vector2;
  67572. /**
  67573. * Vector2 of the size of the output plane in World Units.
  67574. */
  67575. outputSize?: Vector2;
  67576. /**
  67577. * Vector3 of the position of the output plane in World Units.
  67578. */
  67579. outputPosition?: Vector3;
  67580. /**
  67581. * Vector3 of the rotation of the output plane.
  67582. */
  67583. outputRotation?: Vector3;
  67584. /**
  67585. * number of layers that the system will reserve in resources.
  67586. */
  67587. layerCount?: number;
  67588. /**
  67589. * number of max animation frames a single cell will reserve in resources.
  67590. */
  67591. maxAnimationFrames?: number;
  67592. /**
  67593. * number cell index of the base tile when the system compiles.
  67594. */
  67595. baseTile?: number;
  67596. /**
  67597. * boolean flip the sprite after its been repositioned by the framing data.
  67598. */
  67599. flipU?: boolean;
  67600. /**
  67601. * Vector3 scalar of the global RGB values of the SpriteMap.
  67602. */
  67603. colorMultiply?: Vector3;
  67604. }
  67605. /**
  67606. * Defines the IDisposable interface in order to be cleanable from resources.
  67607. */
  67608. export interface ISpriteMap extends IDisposable {
  67609. /**
  67610. * String name of the SpriteMap.
  67611. */
  67612. name: string;
  67613. /**
  67614. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67615. */
  67616. atlasJSON: ISpriteJSONAtlas;
  67617. /**
  67618. * Texture of the SpriteMap.
  67619. */
  67620. spriteSheet: Texture;
  67621. /**
  67622. * The parameters to initialize the SpriteMap with.
  67623. */
  67624. options: ISpriteMapOptions;
  67625. }
  67626. /**
  67627. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67628. */
  67629. export class SpriteMap implements ISpriteMap {
  67630. /** The Name of the spriteMap */
  67631. name: string;
  67632. /** The JSON file with the frame and meta data */
  67633. atlasJSON: ISpriteJSONAtlas;
  67634. /** The systems Sprite Sheet Texture */
  67635. spriteSheet: Texture;
  67636. /** Arguments passed with the Constructor */
  67637. options: ISpriteMapOptions;
  67638. /** Public Sprite Storage array, parsed from atlasJSON */
  67639. sprites: Array<ISpriteJSONSprite>;
  67640. /** Returns the Number of Sprites in the System */
  67641. get spriteCount(): number;
  67642. /** Returns the Position of Output Plane*/
  67643. get position(): Vector3;
  67644. /** Returns the Position of Output Plane*/
  67645. set position(v: Vector3);
  67646. /** Returns the Rotation of Output Plane*/
  67647. get rotation(): Vector3;
  67648. /** Returns the Rotation of Output Plane*/
  67649. set rotation(v: Vector3);
  67650. /** Sets the AnimationMap*/
  67651. get animationMap(): RawTexture;
  67652. /** Sets the AnimationMap*/
  67653. set animationMap(v: RawTexture);
  67654. /** Scene that the SpriteMap was created in */
  67655. private _scene;
  67656. /** Texture Buffer of Float32 that holds tile frame data*/
  67657. private _frameMap;
  67658. /** Texture Buffers of Float32 that holds tileMap data*/
  67659. private _tileMaps;
  67660. /** Texture Buffer of Float32 that holds Animation Data*/
  67661. private _animationMap;
  67662. /** Custom ShaderMaterial Central to the System*/
  67663. private _material;
  67664. /** Custom ShaderMaterial Central to the System*/
  67665. private _output;
  67666. /** Systems Time Ticker*/
  67667. private _time;
  67668. /**
  67669. * Creates a new SpriteMap
  67670. * @param name defines the SpriteMaps Name
  67671. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67672. * @param spriteSheet is the Texture that the Sprites are on.
  67673. * @param options a basic deployment configuration
  67674. * @param scene The Scene that the map is deployed on
  67675. */
  67676. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67677. /**
  67678. * Returns tileID location
  67679. * @returns Vector2 the cell position ID
  67680. */
  67681. getTileID(): Vector2;
  67682. /**
  67683. * Gets the UV location of the mouse over the SpriteMap.
  67684. * @returns Vector2 the UV position of the mouse interaction
  67685. */
  67686. getMousePosition(): Vector2;
  67687. /**
  67688. * Creates the "frame" texture Buffer
  67689. * -------------------------------------
  67690. * Structure of frames
  67691. * "filename": "Falling-Water-2.png",
  67692. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67693. * "rotated": true,
  67694. * "trimmed": true,
  67695. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67696. * "sourceSize": {"w":32,"h":32}
  67697. * @returns RawTexture of the frameMap
  67698. */
  67699. private _createFrameBuffer;
  67700. /**
  67701. * Creates the tileMap texture Buffer
  67702. * @param buffer normally and array of numbers, or a false to generate from scratch
  67703. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67704. * @returns RawTexture of the tileMap
  67705. */
  67706. private _createTileBuffer;
  67707. /**
  67708. * Modifies the data of the tileMaps
  67709. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67710. * @param pos is the iVector2 Coordinates of the Tile
  67711. * @param tile The SpriteIndex of the new Tile
  67712. */
  67713. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67714. /**
  67715. * Creates the animationMap texture Buffer
  67716. * @param buffer normally and array of numbers, or a false to generate from scratch
  67717. * @returns RawTexture of the animationMap
  67718. */
  67719. private _createTileAnimationBuffer;
  67720. /**
  67721. * Modifies the data of the animationMap
  67722. * @param cellID is the Index of the Sprite
  67723. * @param _frame is the target Animation frame
  67724. * @param toCell is the Target Index of the next frame of the animation
  67725. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67726. * @param speed is a global scalar of the time variable on the map.
  67727. */
  67728. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67729. /**
  67730. * Exports the .tilemaps file
  67731. */
  67732. saveTileMaps(): void;
  67733. /**
  67734. * Imports the .tilemaps file
  67735. * @param url of the .tilemaps file
  67736. */
  67737. loadTileMaps(url: string): void;
  67738. /**
  67739. * Release associated resources
  67740. */
  67741. dispose(): void;
  67742. }
  67743. }
  67744. declare module BABYLON {
  67745. /**
  67746. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67747. * @see http://doc.babylonjs.com/babylon101/sprites
  67748. */
  67749. export class SpritePackedManager extends SpriteManager {
  67750. /** defines the packed manager's name */
  67751. name: string;
  67752. /**
  67753. * Creates a new sprite manager from a packed sprite sheet
  67754. * @param name defines the manager's name
  67755. * @param imgUrl defines the sprite sheet url
  67756. * @param capacity defines the maximum allowed number of sprites
  67757. * @param scene defines the hosting scene
  67758. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67759. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67760. * @param samplingMode defines the smapling mode to use with spritesheet
  67761. * @param fromPacked set to true; do not alter
  67762. */
  67763. constructor(
  67764. /** defines the packed manager's name */
  67765. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67766. }
  67767. }
  67768. declare module BABYLON {
  67769. /**
  67770. * Defines the list of states available for a task inside a AssetsManager
  67771. */
  67772. export enum AssetTaskState {
  67773. /**
  67774. * Initialization
  67775. */
  67776. INIT = 0,
  67777. /**
  67778. * Running
  67779. */
  67780. RUNNING = 1,
  67781. /**
  67782. * Done
  67783. */
  67784. DONE = 2,
  67785. /**
  67786. * Error
  67787. */
  67788. ERROR = 3
  67789. }
  67790. /**
  67791. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67792. */
  67793. export abstract class AbstractAssetTask {
  67794. /**
  67795. * Task name
  67796. */ name: string;
  67797. /**
  67798. * Callback called when the task is successful
  67799. */
  67800. onSuccess: (task: any) => void;
  67801. /**
  67802. * Callback called when the task is not successful
  67803. */
  67804. onError: (task: any, message?: string, exception?: any) => void;
  67805. /**
  67806. * Creates a new AssetsManager
  67807. * @param name defines the name of the task
  67808. */
  67809. constructor(
  67810. /**
  67811. * Task name
  67812. */ name: string);
  67813. private _isCompleted;
  67814. private _taskState;
  67815. private _errorObject;
  67816. /**
  67817. * Get if the task is completed
  67818. */
  67819. get isCompleted(): boolean;
  67820. /**
  67821. * Gets the current state of the task
  67822. */
  67823. get taskState(): AssetTaskState;
  67824. /**
  67825. * Gets the current error object (if task is in error)
  67826. */
  67827. get errorObject(): {
  67828. message?: string;
  67829. exception?: any;
  67830. };
  67831. /**
  67832. * Internal only
  67833. * @hidden
  67834. */
  67835. _setErrorObject(message?: string, exception?: any): void;
  67836. /**
  67837. * Execute the current task
  67838. * @param scene defines the scene where you want your assets to be loaded
  67839. * @param onSuccess is a callback called when the task is successfully executed
  67840. * @param onError is a callback called if an error occurs
  67841. */
  67842. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67843. /**
  67844. * Execute the current task
  67845. * @param scene defines the scene where you want your assets to be loaded
  67846. * @param onSuccess is a callback called when the task is successfully executed
  67847. * @param onError is a callback called if an error occurs
  67848. */
  67849. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67850. /**
  67851. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67852. * This can be used with failed tasks that have the reason for failure fixed.
  67853. */
  67854. reset(): void;
  67855. private onErrorCallback;
  67856. private onDoneCallback;
  67857. }
  67858. /**
  67859. * Define the interface used by progress events raised during assets loading
  67860. */
  67861. export interface IAssetsProgressEvent {
  67862. /**
  67863. * Defines the number of remaining tasks to process
  67864. */
  67865. remainingCount: number;
  67866. /**
  67867. * Defines the total number of tasks
  67868. */
  67869. totalCount: number;
  67870. /**
  67871. * Defines the task that was just processed
  67872. */
  67873. task: AbstractAssetTask;
  67874. }
  67875. /**
  67876. * Class used to share progress information about assets loading
  67877. */
  67878. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67879. /**
  67880. * Defines the number of remaining tasks to process
  67881. */
  67882. remainingCount: number;
  67883. /**
  67884. * Defines the total number of tasks
  67885. */
  67886. totalCount: number;
  67887. /**
  67888. * Defines the task that was just processed
  67889. */
  67890. task: AbstractAssetTask;
  67891. /**
  67892. * Creates a AssetsProgressEvent
  67893. * @param remainingCount defines the number of remaining tasks to process
  67894. * @param totalCount defines the total number of tasks
  67895. * @param task defines the task that was just processed
  67896. */
  67897. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67898. }
  67899. /**
  67900. * Define a task used by AssetsManager to load meshes
  67901. */
  67902. export class MeshAssetTask extends AbstractAssetTask {
  67903. /**
  67904. * Defines the name of the task
  67905. */
  67906. name: string;
  67907. /**
  67908. * Defines the list of mesh's names you want to load
  67909. */
  67910. meshesNames: any;
  67911. /**
  67912. * Defines the root url to use as a base to load your meshes and associated resources
  67913. */
  67914. rootUrl: string;
  67915. /**
  67916. * Defines the filename of the scene to load from
  67917. */
  67918. sceneFilename: string;
  67919. /**
  67920. * Gets the list of loaded meshes
  67921. */
  67922. loadedMeshes: Array<AbstractMesh>;
  67923. /**
  67924. * Gets the list of loaded particle systems
  67925. */
  67926. loadedParticleSystems: Array<IParticleSystem>;
  67927. /**
  67928. * Gets the list of loaded skeletons
  67929. */
  67930. loadedSkeletons: Array<Skeleton>;
  67931. /**
  67932. * Gets the list of loaded animation groups
  67933. */
  67934. loadedAnimationGroups: Array<AnimationGroup>;
  67935. /**
  67936. * Callback called when the task is successful
  67937. */
  67938. onSuccess: (task: MeshAssetTask) => void;
  67939. /**
  67940. * Callback called when the task is successful
  67941. */
  67942. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67943. /**
  67944. * Creates a new MeshAssetTask
  67945. * @param name defines the name of the task
  67946. * @param meshesNames defines the list of mesh's names you want to load
  67947. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67948. * @param sceneFilename defines the filename of the scene to load from
  67949. */
  67950. constructor(
  67951. /**
  67952. * Defines the name of the task
  67953. */
  67954. name: string,
  67955. /**
  67956. * Defines the list of mesh's names you want to load
  67957. */
  67958. meshesNames: any,
  67959. /**
  67960. * Defines the root url to use as a base to load your meshes and associated resources
  67961. */
  67962. rootUrl: string,
  67963. /**
  67964. * Defines the filename of the scene to load from
  67965. */
  67966. sceneFilename: string);
  67967. /**
  67968. * Execute the current task
  67969. * @param scene defines the scene where you want your assets to be loaded
  67970. * @param onSuccess is a callback called when the task is successfully executed
  67971. * @param onError is a callback called if an error occurs
  67972. */
  67973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67974. }
  67975. /**
  67976. * Define a task used by AssetsManager to load text content
  67977. */
  67978. export class TextFileAssetTask extends AbstractAssetTask {
  67979. /**
  67980. * Defines the name of the task
  67981. */
  67982. name: string;
  67983. /**
  67984. * Defines the location of the file to load
  67985. */
  67986. url: string;
  67987. /**
  67988. * Gets the loaded text string
  67989. */
  67990. text: string;
  67991. /**
  67992. * Callback called when the task is successful
  67993. */
  67994. onSuccess: (task: TextFileAssetTask) => void;
  67995. /**
  67996. * Callback called when the task is successful
  67997. */
  67998. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67999. /**
  68000. * Creates a new TextFileAssetTask object
  68001. * @param name defines the name of the task
  68002. * @param url defines the location of the file to load
  68003. */
  68004. constructor(
  68005. /**
  68006. * Defines the name of the task
  68007. */
  68008. name: string,
  68009. /**
  68010. * Defines the location of the file to load
  68011. */
  68012. url: string);
  68013. /**
  68014. * Execute the current task
  68015. * @param scene defines the scene where you want your assets to be loaded
  68016. * @param onSuccess is a callback called when the task is successfully executed
  68017. * @param onError is a callback called if an error occurs
  68018. */
  68019. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68020. }
  68021. /**
  68022. * Define a task used by AssetsManager to load binary data
  68023. */
  68024. export class BinaryFileAssetTask extends AbstractAssetTask {
  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. * Gets the lodaded data (as an array buffer)
  68035. */
  68036. data: ArrayBuffer;
  68037. /**
  68038. * Callback called when the task is successful
  68039. */
  68040. onSuccess: (task: BinaryFileAssetTask) => void;
  68041. /**
  68042. * Callback called when the task is successful
  68043. */
  68044. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68045. /**
  68046. * Creates a new BinaryFileAssetTask object
  68047. * @param name defines the name of the new task
  68048. * @param url defines the location of the file to load
  68049. */
  68050. constructor(
  68051. /**
  68052. * Defines the name of the task
  68053. */
  68054. name: string,
  68055. /**
  68056. * Defines the location of the file to load
  68057. */
  68058. url: string);
  68059. /**
  68060. * Execute the current task
  68061. * @param scene defines the scene where you want your assets to be loaded
  68062. * @param onSuccess is a callback called when the task is successfully executed
  68063. * @param onError is a callback called if an error occurs
  68064. */
  68065. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68066. }
  68067. /**
  68068. * Define a task used by AssetsManager to load images
  68069. */
  68070. export class ImageAssetTask extends AbstractAssetTask {
  68071. /**
  68072. * Defines the name of the task
  68073. */
  68074. name: string;
  68075. /**
  68076. * Defines the location of the image to load
  68077. */
  68078. url: string;
  68079. /**
  68080. * Gets the loaded images
  68081. */
  68082. image: HTMLImageElement;
  68083. /**
  68084. * Callback called when the task is successful
  68085. */
  68086. onSuccess: (task: ImageAssetTask) => void;
  68087. /**
  68088. * Callback called when the task is successful
  68089. */
  68090. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68091. /**
  68092. * Creates a new ImageAssetTask
  68093. * @param name defines the name of the task
  68094. * @param url defines the location of the image to load
  68095. */
  68096. constructor(
  68097. /**
  68098. * Defines the name of the task
  68099. */
  68100. name: string,
  68101. /**
  68102. * Defines the location of the image to load
  68103. */
  68104. url: string);
  68105. /**
  68106. * Execute the current task
  68107. * @param scene defines the scene where you want your assets to be loaded
  68108. * @param onSuccess is a callback called when the task is successfully executed
  68109. * @param onError is a callback called if an error occurs
  68110. */
  68111. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68112. }
  68113. /**
  68114. * Defines the interface used by texture loading tasks
  68115. */
  68116. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68117. /**
  68118. * Gets the loaded texture
  68119. */
  68120. texture: TEX;
  68121. }
  68122. /**
  68123. * Define a task used by AssetsManager to load 2D textures
  68124. */
  68125. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68126. /**
  68127. * Defines the name of the task
  68128. */
  68129. name: string;
  68130. /**
  68131. * Defines the location of the file to load
  68132. */
  68133. url: string;
  68134. /**
  68135. * Defines if mipmap should not be generated (default is false)
  68136. */
  68137. noMipmap?: boolean | undefined;
  68138. /**
  68139. * Defines if texture must be inverted on Y axis (default is true)
  68140. */
  68141. invertY: boolean;
  68142. /**
  68143. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68144. */
  68145. samplingMode: number;
  68146. /**
  68147. * Gets the loaded texture
  68148. */
  68149. texture: Texture;
  68150. /**
  68151. * Callback called when the task is successful
  68152. */
  68153. onSuccess: (task: TextureAssetTask) => void;
  68154. /**
  68155. * Callback called when the task is successful
  68156. */
  68157. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68158. /**
  68159. * Creates a new TextureAssetTask object
  68160. * @param name defines the name of the task
  68161. * @param url defines the location of the file to load
  68162. * @param noMipmap defines if mipmap should not be generated (default is false)
  68163. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68164. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68165. */
  68166. constructor(
  68167. /**
  68168. * Defines the name of the task
  68169. */
  68170. name: string,
  68171. /**
  68172. * Defines the location of the file to load
  68173. */
  68174. url: string,
  68175. /**
  68176. * Defines if mipmap should not be generated (default is false)
  68177. */
  68178. noMipmap?: boolean | undefined,
  68179. /**
  68180. * Defines if texture must be inverted on Y axis (default is true)
  68181. */
  68182. invertY?: boolean,
  68183. /**
  68184. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68185. */
  68186. samplingMode?: number);
  68187. /**
  68188. * Execute the current task
  68189. * @param scene defines the scene where you want your assets to be loaded
  68190. * @param onSuccess is a callback called when the task is successfully executed
  68191. * @param onError is a callback called if an error occurs
  68192. */
  68193. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68194. }
  68195. /**
  68196. * Define a task used by AssetsManager to load cube textures
  68197. */
  68198. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68199. /**
  68200. * Defines the name of the task
  68201. */
  68202. name: string;
  68203. /**
  68204. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68205. */
  68206. url: string;
  68207. /**
  68208. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68209. */
  68210. extensions?: string[] | undefined;
  68211. /**
  68212. * Defines if mipmaps should not be generated (default is false)
  68213. */
  68214. noMipmap?: boolean | undefined;
  68215. /**
  68216. * Defines the explicit list of files (undefined by default)
  68217. */
  68218. files?: string[] | undefined;
  68219. /**
  68220. * Gets the loaded texture
  68221. */
  68222. texture: CubeTexture;
  68223. /**
  68224. * Callback called when the task is successful
  68225. */
  68226. onSuccess: (task: CubeTextureAssetTask) => void;
  68227. /**
  68228. * Callback called when the task is successful
  68229. */
  68230. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68231. /**
  68232. * Creates a new CubeTextureAssetTask
  68233. * @param name defines the name of the task
  68234. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68235. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68236. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68237. * @param files defines the explicit list of files (undefined by default)
  68238. */
  68239. constructor(
  68240. /**
  68241. * Defines the name of the task
  68242. */
  68243. name: string,
  68244. /**
  68245. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68246. */
  68247. url: string,
  68248. /**
  68249. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68250. */
  68251. extensions?: string[] | undefined,
  68252. /**
  68253. * Defines if mipmaps should not be generated (default is false)
  68254. */
  68255. noMipmap?: boolean | undefined,
  68256. /**
  68257. * Defines the explicit list of files (undefined by default)
  68258. */
  68259. files?: string[] | undefined);
  68260. /**
  68261. * Execute the current task
  68262. * @param scene defines the scene where you want your assets to be loaded
  68263. * @param onSuccess is a callback called when the task is successfully executed
  68264. * @param onError is a callback called if an error occurs
  68265. */
  68266. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68267. }
  68268. /**
  68269. * Define a task used by AssetsManager to load HDR cube textures
  68270. */
  68271. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68272. /**
  68273. * Defines the name of the task
  68274. */
  68275. name: string;
  68276. /**
  68277. * Defines the location of the file to load
  68278. */
  68279. url: string;
  68280. /**
  68281. * Defines the desired size (the more it increases the longer the generation will be)
  68282. */
  68283. size: number;
  68284. /**
  68285. * Defines if mipmaps should not be generated (default is false)
  68286. */
  68287. noMipmap: boolean;
  68288. /**
  68289. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68290. */
  68291. generateHarmonics: boolean;
  68292. /**
  68293. * 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)
  68294. */
  68295. gammaSpace: boolean;
  68296. /**
  68297. * Internal Use Only
  68298. */
  68299. reserved: boolean;
  68300. /**
  68301. * Gets the loaded texture
  68302. */
  68303. texture: HDRCubeTexture;
  68304. /**
  68305. * Callback called when the task is successful
  68306. */
  68307. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68308. /**
  68309. * Callback called when the task is successful
  68310. */
  68311. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68312. /**
  68313. * Creates a new HDRCubeTextureAssetTask object
  68314. * @param name defines the name of the task
  68315. * @param url defines the location of the file to load
  68316. * @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.
  68317. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68318. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68319. * @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)
  68320. * @param reserved Internal use only
  68321. */
  68322. constructor(
  68323. /**
  68324. * Defines the name of the task
  68325. */
  68326. name: string,
  68327. /**
  68328. * Defines the location of the file to load
  68329. */
  68330. url: string,
  68331. /**
  68332. * Defines the desired size (the more it increases the longer the generation will be)
  68333. */
  68334. size: number,
  68335. /**
  68336. * Defines if mipmaps should not be generated (default is false)
  68337. */
  68338. noMipmap?: boolean,
  68339. /**
  68340. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68341. */
  68342. generateHarmonics?: boolean,
  68343. /**
  68344. * 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)
  68345. */
  68346. gammaSpace?: boolean,
  68347. /**
  68348. * Internal Use Only
  68349. */
  68350. reserved?: boolean);
  68351. /**
  68352. * Execute the current task
  68353. * @param scene defines the scene where you want your assets to be loaded
  68354. * @param onSuccess is a callback called when the task is successfully executed
  68355. * @param onError is a callback called if an error occurs
  68356. */
  68357. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68358. }
  68359. /**
  68360. * Define a task used by AssetsManager to load Equirectangular cube textures
  68361. */
  68362. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68363. /**
  68364. * Defines the name of the task
  68365. */
  68366. name: string;
  68367. /**
  68368. * Defines the location of the file to load
  68369. */
  68370. url: string;
  68371. /**
  68372. * Defines the desired size (the more it increases the longer the generation will be)
  68373. */
  68374. size: number;
  68375. /**
  68376. * Defines if mipmaps should not be generated (default is false)
  68377. */
  68378. noMipmap: boolean;
  68379. /**
  68380. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68381. * but the standard material would require them in Gamma space) (default is true)
  68382. */
  68383. gammaSpace: boolean;
  68384. /**
  68385. * Gets the loaded texture
  68386. */
  68387. texture: EquiRectangularCubeTexture;
  68388. /**
  68389. * Callback called when the task is successful
  68390. */
  68391. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68392. /**
  68393. * Callback called when the task is successful
  68394. */
  68395. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68396. /**
  68397. * Creates a new EquiRectangularCubeTextureAssetTask object
  68398. * @param name defines the name of the task
  68399. * @param url defines the location of the file to load
  68400. * @param size defines the desired size (the more it increases the longer the generation will be)
  68401. * If the size is omitted this implies you are using a preprocessed cubemap.
  68402. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68403. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68404. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68405. * (default is true)
  68406. */
  68407. constructor(
  68408. /**
  68409. * Defines the name of the task
  68410. */
  68411. name: string,
  68412. /**
  68413. * Defines the location of the file to load
  68414. */
  68415. url: string,
  68416. /**
  68417. * Defines the desired size (the more it increases the longer the generation will be)
  68418. */
  68419. size: number,
  68420. /**
  68421. * Defines if mipmaps should not be generated (default is false)
  68422. */
  68423. noMipmap?: boolean,
  68424. /**
  68425. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68426. * but the standard material would require them in Gamma space) (default is true)
  68427. */
  68428. gammaSpace?: boolean);
  68429. /**
  68430. * Execute the current task
  68431. * @param scene defines the scene where you want your assets to be loaded
  68432. * @param onSuccess is a callback called when the task is successfully executed
  68433. * @param onError is a callback called if an error occurs
  68434. */
  68435. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68436. }
  68437. /**
  68438. * This class can be used to easily import assets into a scene
  68439. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68440. */
  68441. export class AssetsManager {
  68442. private _scene;
  68443. private _isLoading;
  68444. protected _tasks: AbstractAssetTask[];
  68445. protected _waitingTasksCount: number;
  68446. protected _totalTasksCount: number;
  68447. /**
  68448. * Callback called when all tasks are processed
  68449. */
  68450. onFinish: (tasks: AbstractAssetTask[]) => void;
  68451. /**
  68452. * Callback called when a task is successful
  68453. */
  68454. onTaskSuccess: (task: AbstractAssetTask) => void;
  68455. /**
  68456. * Callback called when a task had an error
  68457. */
  68458. onTaskError: (task: AbstractAssetTask) => void;
  68459. /**
  68460. * Callback called when a task is done (whatever the result is)
  68461. */
  68462. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68463. /**
  68464. * Observable called when all tasks are processed
  68465. */
  68466. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68467. /**
  68468. * Observable called when a task had an error
  68469. */
  68470. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68471. /**
  68472. * Observable called when all tasks were executed
  68473. */
  68474. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68475. /**
  68476. * Observable called when a task is done (whatever the result is)
  68477. */
  68478. onProgressObservable: Observable<IAssetsProgressEvent>;
  68479. /**
  68480. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68481. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68482. */
  68483. useDefaultLoadingScreen: boolean;
  68484. /**
  68485. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68486. * when all assets have been downloaded.
  68487. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68488. */
  68489. autoHideLoadingUI: boolean;
  68490. /**
  68491. * Creates a new AssetsManager
  68492. * @param scene defines the scene to work on
  68493. */
  68494. constructor(scene: Scene);
  68495. /**
  68496. * Add a MeshAssetTask to the list of active tasks
  68497. * @param taskName defines the name of the new task
  68498. * @param meshesNames defines the name of meshes to load
  68499. * @param rootUrl defines the root url to use to locate files
  68500. * @param sceneFilename defines the filename of the scene file
  68501. * @returns a new MeshAssetTask object
  68502. */
  68503. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68504. /**
  68505. * Add a TextFileAssetTask to the list of active tasks
  68506. * @param taskName defines the name of the new task
  68507. * @param url defines the url of the file to load
  68508. * @returns a new TextFileAssetTask object
  68509. */
  68510. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68511. /**
  68512. * Add a BinaryFileAssetTask to the list of active tasks
  68513. * @param taskName defines the name of the new task
  68514. * @param url defines the url of the file to load
  68515. * @returns a new BinaryFileAssetTask object
  68516. */
  68517. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68518. /**
  68519. * Add a ImageAssetTask to the list of active tasks
  68520. * @param taskName defines the name of the new task
  68521. * @param url defines the url of the file to load
  68522. * @returns a new ImageAssetTask object
  68523. */
  68524. addImageTask(taskName: string, url: string): ImageAssetTask;
  68525. /**
  68526. * Add a TextureAssetTask to the list of active tasks
  68527. * @param taskName defines the name of the new task
  68528. * @param url defines the url of the file to load
  68529. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68530. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68531. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68532. * @returns a new TextureAssetTask object
  68533. */
  68534. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68535. /**
  68536. * Add a CubeTextureAssetTask to the list of active tasks
  68537. * @param taskName defines the name of the new task
  68538. * @param url defines the url of the file to load
  68539. * @param extensions defines the extension to use to load the cube map (can be null)
  68540. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68541. * @param files defines the list of files to load (can be null)
  68542. * @returns a new CubeTextureAssetTask object
  68543. */
  68544. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68545. /**
  68546. *
  68547. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68548. * @param taskName defines the name of the new task
  68549. * @param url defines the url of the file to load
  68550. * @param size defines the size you want for the cubemap (can be null)
  68551. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68552. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68553. * @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)
  68554. * @param reserved Internal use only
  68555. * @returns a new HDRCubeTextureAssetTask object
  68556. */
  68557. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68558. /**
  68559. *
  68560. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68561. * @param taskName defines the name of the new task
  68562. * @param url defines the url of the file to load
  68563. * @param size defines the size you want for the cubemap (can be null)
  68564. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68565. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68566. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68567. * @returns a new EquiRectangularCubeTextureAssetTask object
  68568. */
  68569. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68570. /**
  68571. * Remove a task from the assets manager.
  68572. * @param task the task to remove
  68573. */
  68574. removeTask(task: AbstractAssetTask): void;
  68575. private _decreaseWaitingTasksCount;
  68576. private _runTask;
  68577. /**
  68578. * Reset the AssetsManager and remove all tasks
  68579. * @return the current instance of the AssetsManager
  68580. */
  68581. reset(): AssetsManager;
  68582. /**
  68583. * Start the loading process
  68584. * @return the current instance of the AssetsManager
  68585. */
  68586. load(): AssetsManager;
  68587. /**
  68588. * Start the loading process as an async operation
  68589. * @return a promise returning the list of failed tasks
  68590. */
  68591. loadAsync(): Promise<void>;
  68592. }
  68593. }
  68594. declare module BABYLON {
  68595. /**
  68596. * Wrapper class for promise with external resolve and reject.
  68597. */
  68598. export class Deferred<T> {
  68599. /**
  68600. * The promise associated with this deferred object.
  68601. */
  68602. readonly promise: Promise<T>;
  68603. private _resolve;
  68604. private _reject;
  68605. /**
  68606. * The resolve method of the promise associated with this deferred object.
  68607. */
  68608. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68609. /**
  68610. * The reject method of the promise associated with this deferred object.
  68611. */
  68612. get reject(): (reason?: any) => void;
  68613. /**
  68614. * Constructor for this deferred object.
  68615. */
  68616. constructor();
  68617. }
  68618. }
  68619. declare module BABYLON {
  68620. /**
  68621. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68622. */
  68623. export class MeshExploder {
  68624. private _centerMesh;
  68625. private _meshes;
  68626. private _meshesOrigins;
  68627. private _toCenterVectors;
  68628. private _scaledDirection;
  68629. private _newPosition;
  68630. private _centerPosition;
  68631. /**
  68632. * Explodes meshes from a center mesh.
  68633. * @param meshes The meshes to explode.
  68634. * @param centerMesh The mesh to be center of explosion.
  68635. */
  68636. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68637. private _setCenterMesh;
  68638. /**
  68639. * Get class name
  68640. * @returns "MeshExploder"
  68641. */
  68642. getClassName(): string;
  68643. /**
  68644. * "Exploded meshes"
  68645. * @returns Array of meshes with the centerMesh at index 0.
  68646. */
  68647. getMeshes(): Array<Mesh>;
  68648. /**
  68649. * Explodes meshes giving a specific direction
  68650. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68651. */
  68652. explode(direction?: number): void;
  68653. }
  68654. }
  68655. declare module BABYLON {
  68656. /**
  68657. * Class used to help managing file picking and drag'n'drop
  68658. */
  68659. export class FilesInput {
  68660. /**
  68661. * List of files ready to be loaded
  68662. */
  68663. static get FilesToLoad(): {
  68664. [key: string]: File;
  68665. };
  68666. /**
  68667. * Callback called when a file is processed
  68668. */
  68669. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68670. private _engine;
  68671. private _currentScene;
  68672. private _sceneLoadedCallback;
  68673. private _progressCallback;
  68674. private _additionalRenderLoopLogicCallback;
  68675. private _textureLoadingCallback;
  68676. private _startingProcessingFilesCallback;
  68677. private _onReloadCallback;
  68678. private _errorCallback;
  68679. private _elementToMonitor;
  68680. private _sceneFileToLoad;
  68681. private _filesToLoad;
  68682. /**
  68683. * Creates a new FilesInput
  68684. * @param engine defines the rendering engine
  68685. * @param scene defines the hosting scene
  68686. * @param sceneLoadedCallback callback called when scene is loaded
  68687. * @param progressCallback callback called to track progress
  68688. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68689. * @param textureLoadingCallback callback called when a texture is loading
  68690. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68691. * @param onReloadCallback callback called when a reload is requested
  68692. * @param errorCallback callback call if an error occurs
  68693. */
  68694. 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);
  68695. private _dragEnterHandler;
  68696. private _dragOverHandler;
  68697. private _dropHandler;
  68698. /**
  68699. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68700. * @param elementToMonitor defines the DOM element to track
  68701. */
  68702. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68703. /**
  68704. * Release all associated resources
  68705. */
  68706. dispose(): void;
  68707. private renderFunction;
  68708. private drag;
  68709. private drop;
  68710. private _traverseFolder;
  68711. private _processFiles;
  68712. /**
  68713. * Load files from a drop event
  68714. * @param event defines the drop event to use as source
  68715. */
  68716. loadFiles(event: any): void;
  68717. private _processReload;
  68718. /**
  68719. * Reload the current scene from the loaded files
  68720. */
  68721. reload(): void;
  68722. }
  68723. }
  68724. declare module BABYLON {
  68725. /**
  68726. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68727. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68728. */
  68729. export class SceneOptimization {
  68730. /**
  68731. * Defines the priority of this optimization (0 by default which means first in the list)
  68732. */
  68733. priority: number;
  68734. /**
  68735. * Gets a string describing the action executed by the current optimization
  68736. * @returns description string
  68737. */
  68738. getDescription(): string;
  68739. /**
  68740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68741. * @param scene defines the current scene where to apply this optimization
  68742. * @param optimizer defines the current optimizer
  68743. * @returns true if everything that can be done was applied
  68744. */
  68745. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68746. /**
  68747. * Creates the SceneOptimization object
  68748. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68749. * @param desc defines the description associated with the optimization
  68750. */
  68751. constructor(
  68752. /**
  68753. * Defines the priority of this optimization (0 by default which means first in the list)
  68754. */
  68755. priority?: number);
  68756. }
  68757. /**
  68758. * Defines an optimization used to reduce the size of render target textures
  68759. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68760. */
  68761. export class TextureOptimization extends SceneOptimization {
  68762. /**
  68763. * Defines the priority of this optimization (0 by default which means first in the list)
  68764. */
  68765. priority: number;
  68766. /**
  68767. * 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
  68768. */
  68769. maximumSize: number;
  68770. /**
  68771. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68772. */
  68773. step: number;
  68774. /**
  68775. * Gets a string describing the action executed by the current optimization
  68776. * @returns description string
  68777. */
  68778. getDescription(): string;
  68779. /**
  68780. * Creates the TextureOptimization object
  68781. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68782. * @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
  68783. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68784. */
  68785. constructor(
  68786. /**
  68787. * Defines the priority of this optimization (0 by default which means first in the list)
  68788. */
  68789. priority?: number,
  68790. /**
  68791. * 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
  68792. */
  68793. maximumSize?: number,
  68794. /**
  68795. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68796. */
  68797. step?: number);
  68798. /**
  68799. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68800. * @param scene defines the current scene where to apply this optimization
  68801. * @param optimizer defines the current optimizer
  68802. * @returns true if everything that can be done was applied
  68803. */
  68804. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68805. }
  68806. /**
  68807. * Defines an optimization used to increase or decrease the rendering resolution
  68808. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68809. */
  68810. export class HardwareScalingOptimization extends SceneOptimization {
  68811. /**
  68812. * Defines the priority of this optimization (0 by default which means first in the list)
  68813. */
  68814. priority: number;
  68815. /**
  68816. * Defines the maximum scale to use (2 by default)
  68817. */
  68818. maximumScale: number;
  68819. /**
  68820. * Defines the step to use between two passes (0.5 by default)
  68821. */
  68822. step: number;
  68823. private _currentScale;
  68824. private _directionOffset;
  68825. /**
  68826. * Gets a string describing the action executed by the current optimization
  68827. * @return description string
  68828. */
  68829. getDescription(): string;
  68830. /**
  68831. * Creates the HardwareScalingOptimization object
  68832. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68833. * @param maximumScale defines the maximum scale to use (2 by default)
  68834. * @param step defines the step to use between two passes (0.5 by default)
  68835. */
  68836. constructor(
  68837. /**
  68838. * Defines the priority of this optimization (0 by default which means first in the list)
  68839. */
  68840. priority?: number,
  68841. /**
  68842. * Defines the maximum scale to use (2 by default)
  68843. */
  68844. maximumScale?: number,
  68845. /**
  68846. * Defines the step to use between two passes (0.5 by default)
  68847. */
  68848. step?: number);
  68849. /**
  68850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68851. * @param scene defines the current scene where to apply this optimization
  68852. * @param optimizer defines the current optimizer
  68853. * @returns true if everything that can be done was applied
  68854. */
  68855. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68856. }
  68857. /**
  68858. * Defines an optimization used to remove shadows
  68859. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68860. */
  68861. export class ShadowsOptimization extends SceneOptimization {
  68862. /**
  68863. * Gets a string describing the action executed by the current optimization
  68864. * @return description string
  68865. */
  68866. getDescription(): string;
  68867. /**
  68868. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68869. * @param scene defines the current scene where to apply this optimization
  68870. * @param optimizer defines the current optimizer
  68871. * @returns true if everything that can be done was applied
  68872. */
  68873. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68874. }
  68875. /**
  68876. * Defines an optimization used to turn post-processes off
  68877. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68878. */
  68879. export class PostProcessesOptimization extends SceneOptimization {
  68880. /**
  68881. * Gets a string describing the action executed by the current optimization
  68882. * @return description string
  68883. */
  68884. getDescription(): string;
  68885. /**
  68886. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68887. * @param scene defines the current scene where to apply this optimization
  68888. * @param optimizer defines the current optimizer
  68889. * @returns true if everything that can be done was applied
  68890. */
  68891. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68892. }
  68893. /**
  68894. * Defines an optimization used to turn lens flares off
  68895. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68896. */
  68897. export class LensFlaresOptimization extends SceneOptimization {
  68898. /**
  68899. * Gets a string describing the action executed by the current optimization
  68900. * @return description string
  68901. */
  68902. getDescription(): string;
  68903. /**
  68904. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68905. * @param scene defines the current scene where to apply this optimization
  68906. * @param optimizer defines the current optimizer
  68907. * @returns true if everything that can be done was applied
  68908. */
  68909. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68910. }
  68911. /**
  68912. * Defines an optimization based on user defined callback.
  68913. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68914. */
  68915. export class CustomOptimization extends SceneOptimization {
  68916. /**
  68917. * Callback called to apply the custom optimization.
  68918. */
  68919. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68920. /**
  68921. * Callback called to get custom description
  68922. */
  68923. onGetDescription: () => string;
  68924. /**
  68925. * Gets a string describing the action executed by the current optimization
  68926. * @returns description string
  68927. */
  68928. getDescription(): string;
  68929. /**
  68930. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68931. * @param scene defines the current scene where to apply this optimization
  68932. * @param optimizer defines the current optimizer
  68933. * @returns true if everything that can be done was applied
  68934. */
  68935. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68936. }
  68937. /**
  68938. * Defines an optimization used to turn particles off
  68939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68940. */
  68941. export class ParticlesOptimization extends SceneOptimization {
  68942. /**
  68943. * Gets a string describing the action executed by the current optimization
  68944. * @return description string
  68945. */
  68946. getDescription(): string;
  68947. /**
  68948. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68949. * @param scene defines the current scene where to apply this optimization
  68950. * @param optimizer defines the current optimizer
  68951. * @returns true if everything that can be done was applied
  68952. */
  68953. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68954. }
  68955. /**
  68956. * Defines an optimization used to turn render targets off
  68957. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68958. */
  68959. export class RenderTargetsOptimization extends SceneOptimization {
  68960. /**
  68961. * Gets a string describing the action executed by the current optimization
  68962. * @return description string
  68963. */
  68964. getDescription(): string;
  68965. /**
  68966. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68967. * @param scene defines the current scene where to apply this optimization
  68968. * @param optimizer defines the current optimizer
  68969. * @returns true if everything that can be done was applied
  68970. */
  68971. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68972. }
  68973. /**
  68974. * Defines an optimization used to merge meshes with compatible materials
  68975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68976. */
  68977. export class MergeMeshesOptimization extends SceneOptimization {
  68978. private static _UpdateSelectionTree;
  68979. /**
  68980. * Gets or sets a boolean which defines if optimization octree has to be updated
  68981. */
  68982. static get UpdateSelectionTree(): boolean;
  68983. /**
  68984. * Gets or sets a boolean which defines if optimization octree has to be updated
  68985. */
  68986. static set UpdateSelectionTree(value: boolean);
  68987. /**
  68988. * Gets a string describing the action executed by the current optimization
  68989. * @return description string
  68990. */
  68991. getDescription(): string;
  68992. private _canBeMerged;
  68993. /**
  68994. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68995. * @param scene defines the current scene where to apply this optimization
  68996. * @param optimizer defines the current optimizer
  68997. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68998. * @returns true if everything that can be done was applied
  68999. */
  69000. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69001. }
  69002. /**
  69003. * Defines a list of options used by SceneOptimizer
  69004. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69005. */
  69006. export class SceneOptimizerOptions {
  69007. /**
  69008. * Defines the target frame rate to reach (60 by default)
  69009. */
  69010. targetFrameRate: number;
  69011. /**
  69012. * Defines the interval between two checkes (2000ms by default)
  69013. */
  69014. trackerDuration: number;
  69015. /**
  69016. * Gets the list of optimizations to apply
  69017. */
  69018. optimizations: SceneOptimization[];
  69019. /**
  69020. * Creates a new list of options used by SceneOptimizer
  69021. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69022. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69023. */
  69024. constructor(
  69025. /**
  69026. * Defines the target frame rate to reach (60 by default)
  69027. */
  69028. targetFrameRate?: number,
  69029. /**
  69030. * Defines the interval between two checkes (2000ms by default)
  69031. */
  69032. trackerDuration?: number);
  69033. /**
  69034. * Add a new optimization
  69035. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69036. * @returns the current SceneOptimizerOptions
  69037. */
  69038. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69039. /**
  69040. * Add a new custom optimization
  69041. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69042. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69043. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69044. * @returns the current SceneOptimizerOptions
  69045. */
  69046. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69047. /**
  69048. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69049. * @param targetFrameRate defines the target frame rate (60 by default)
  69050. * @returns a SceneOptimizerOptions object
  69051. */
  69052. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69053. /**
  69054. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69055. * @param targetFrameRate defines the target frame rate (60 by default)
  69056. * @returns a SceneOptimizerOptions object
  69057. */
  69058. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69059. /**
  69060. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69061. * @param targetFrameRate defines the target frame rate (60 by default)
  69062. * @returns a SceneOptimizerOptions object
  69063. */
  69064. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69065. }
  69066. /**
  69067. * Class used to run optimizations in order to reach a target frame rate
  69068. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69069. */
  69070. export class SceneOptimizer implements IDisposable {
  69071. private _isRunning;
  69072. private _options;
  69073. private _scene;
  69074. private _currentPriorityLevel;
  69075. private _targetFrameRate;
  69076. private _trackerDuration;
  69077. private _currentFrameRate;
  69078. private _sceneDisposeObserver;
  69079. private _improvementMode;
  69080. /**
  69081. * Defines an observable called when the optimizer reaches the target frame rate
  69082. */
  69083. onSuccessObservable: Observable<SceneOptimizer>;
  69084. /**
  69085. * Defines an observable called when the optimizer enables an optimization
  69086. */
  69087. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69088. /**
  69089. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69090. */
  69091. onFailureObservable: Observable<SceneOptimizer>;
  69092. /**
  69093. * Gets a boolean indicating if the optimizer is in improvement mode
  69094. */
  69095. get isInImprovementMode(): boolean;
  69096. /**
  69097. * Gets the current priority level (0 at start)
  69098. */
  69099. get currentPriorityLevel(): number;
  69100. /**
  69101. * Gets the current frame rate checked by the SceneOptimizer
  69102. */
  69103. get currentFrameRate(): number;
  69104. /**
  69105. * Gets or sets the current target frame rate (60 by default)
  69106. */
  69107. get targetFrameRate(): number;
  69108. /**
  69109. * Gets or sets the current target frame rate (60 by default)
  69110. */
  69111. set targetFrameRate(value: number);
  69112. /**
  69113. * Gets or sets the current interval between two checks (every 2000ms by default)
  69114. */
  69115. get trackerDuration(): number;
  69116. /**
  69117. * Gets or sets the current interval between two checks (every 2000ms by default)
  69118. */
  69119. set trackerDuration(value: number);
  69120. /**
  69121. * Gets the list of active optimizations
  69122. */
  69123. get optimizations(): SceneOptimization[];
  69124. /**
  69125. * Creates a new SceneOptimizer
  69126. * @param scene defines the scene to work on
  69127. * @param options defines the options to use with the SceneOptimizer
  69128. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69129. * @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)
  69130. */
  69131. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69132. /**
  69133. * Stops the current optimizer
  69134. */
  69135. stop(): void;
  69136. /**
  69137. * Reset the optimizer to initial step (current priority level = 0)
  69138. */
  69139. reset(): void;
  69140. /**
  69141. * Start the optimizer. By default it will try to reach a specific framerate
  69142. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69143. */
  69144. start(): void;
  69145. private _checkCurrentState;
  69146. /**
  69147. * Release all resources
  69148. */
  69149. dispose(): void;
  69150. /**
  69151. * Helper function to create a SceneOptimizer with one single line of code
  69152. * @param scene defines the scene to work on
  69153. * @param options defines the options to use with the SceneOptimizer
  69154. * @param onSuccess defines a callback to call on success
  69155. * @param onFailure defines a callback to call on failure
  69156. * @returns the new SceneOptimizer object
  69157. */
  69158. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69159. }
  69160. }
  69161. declare module BABYLON {
  69162. /**
  69163. * Class used to serialize a scene into a string
  69164. */
  69165. export class SceneSerializer {
  69166. /**
  69167. * Clear cache used by a previous serialization
  69168. */
  69169. static ClearCache(): void;
  69170. /**
  69171. * Serialize a scene into a JSON compatible object
  69172. * @param scene defines the scene to serialize
  69173. * @returns a JSON compatible object
  69174. */
  69175. static Serialize(scene: Scene): any;
  69176. /**
  69177. * Serialize a mesh into a JSON compatible object
  69178. * @param toSerialize defines the mesh to serialize
  69179. * @param withParents defines if parents must be serialized as well
  69180. * @param withChildren defines if children must be serialized as well
  69181. * @returns a JSON compatible object
  69182. */
  69183. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69184. }
  69185. }
  69186. declare module BABYLON {
  69187. /**
  69188. * Class used to host texture specific utilities
  69189. */
  69190. export class TextureTools {
  69191. /**
  69192. * Uses the GPU to create a copy texture rescaled at a given size
  69193. * @param texture Texture to copy from
  69194. * @param width defines the desired width
  69195. * @param height defines the desired height
  69196. * @param useBilinearMode defines if bilinear mode has to be used
  69197. * @return the generated texture
  69198. */
  69199. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69200. }
  69201. }
  69202. declare module BABYLON {
  69203. /**
  69204. * This represents the different options available for the video capture.
  69205. */
  69206. export interface VideoRecorderOptions {
  69207. /** Defines the mime type of the video. */
  69208. mimeType: string;
  69209. /** Defines the FPS the video should be recorded at. */
  69210. fps: number;
  69211. /** Defines the chunk size for the recording data. */
  69212. recordChunckSize: number;
  69213. /** The audio tracks to attach to the recording. */
  69214. audioTracks?: MediaStreamTrack[];
  69215. }
  69216. /**
  69217. * This can help with recording videos from BabylonJS.
  69218. * This is based on the available WebRTC functionalities of the browser.
  69219. *
  69220. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69221. */
  69222. export class VideoRecorder {
  69223. private static readonly _defaultOptions;
  69224. /**
  69225. * Returns whether or not the VideoRecorder is available in your browser.
  69226. * @param engine Defines the Babylon Engine.
  69227. * @returns true if supported otherwise false.
  69228. */
  69229. static IsSupported(engine: Engine): boolean;
  69230. private readonly _options;
  69231. private _canvas;
  69232. private _mediaRecorder;
  69233. private _recordedChunks;
  69234. private _fileName;
  69235. private _resolve;
  69236. private _reject;
  69237. /**
  69238. * True when a recording is already in progress.
  69239. */
  69240. get isRecording(): boolean;
  69241. /**
  69242. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69243. * @param engine Defines the BabylonJS Engine you wish to record.
  69244. * @param options Defines options that can be used to customize the capture.
  69245. */
  69246. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69247. /**
  69248. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69249. */
  69250. stopRecording(): void;
  69251. /**
  69252. * Starts recording the canvas for a max duration specified in parameters.
  69253. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69254. * If null no automatic download will start and you can rely on the promise to get the data back.
  69255. * @param maxDuration Defines the maximum recording time in seconds.
  69256. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69257. * @return A promise callback at the end of the recording with the video data in Blob.
  69258. */
  69259. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69260. /**
  69261. * Releases internal resources used during the recording.
  69262. */
  69263. dispose(): void;
  69264. private _handleDataAvailable;
  69265. private _handleError;
  69266. private _handleStop;
  69267. }
  69268. }
  69269. declare module BABYLON {
  69270. /**
  69271. * Class containing a set of static utilities functions for screenshots
  69272. */
  69273. export class ScreenshotTools {
  69274. /**
  69275. * Captures a screenshot of the current rendering
  69276. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69277. * @param engine defines the rendering engine
  69278. * @param camera defines the source camera
  69279. * @param size This parameter can be set to a single number or to an object with the
  69280. * following (optional) properties: precision, width, height. If a single number is passed,
  69281. * it will be used for both width and height. If an object is passed, the screenshot size
  69282. * will be derived from the parameters. The precision property is a multiplier allowing
  69283. * rendering at a higher or lower resolution
  69284. * @param successCallback defines the callback receives a single parameter which contains the
  69285. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69286. * src parameter of an <img> to display it
  69287. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69288. * Check your browser for supported MIME types
  69289. */
  69290. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69291. /**
  69292. * Captures a screenshot of the current rendering
  69293. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69294. * @param engine defines the rendering engine
  69295. * @param camera defines the source camera
  69296. * @param size This parameter can be set to a single number or to an object with the
  69297. * following (optional) properties: precision, width, height. If a single number is passed,
  69298. * it will be used for both width and height. If an object is passed, the screenshot size
  69299. * will be derived from the parameters. The precision property is a multiplier allowing
  69300. * rendering at a higher or lower resolution
  69301. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69302. * Check your browser for supported MIME types
  69303. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69304. * to the src parameter of an <img> to display it
  69305. */
  69306. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69307. /**
  69308. * Generates an image screenshot from the specified camera.
  69309. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69310. * @param engine The engine to use for rendering
  69311. * @param camera The camera to use for rendering
  69312. * @param size This parameter can be set to a single number or to an object with the
  69313. * following (optional) properties: precision, width, height. If a single number is passed,
  69314. * it will be used for both width and height. If an object is passed, the screenshot size
  69315. * will be derived from the parameters. The precision property is a multiplier allowing
  69316. * rendering at a higher or lower resolution
  69317. * @param successCallback The callback receives a single parameter which contains the
  69318. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69319. * src parameter of an <img> to display it
  69320. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69321. * Check your browser for supported MIME types
  69322. * @param samples Texture samples (default: 1)
  69323. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69324. * @param fileName A name for for the downloaded file.
  69325. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69326. */
  69327. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69328. /**
  69329. * Generates an image screenshot from the specified camera.
  69330. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69331. * @param engine The engine to use for rendering
  69332. * @param camera The camera to use for rendering
  69333. * @param size This parameter can be set to a single number or to an object with the
  69334. * following (optional) properties: precision, width, height. If a single number is passed,
  69335. * it will be used for both width and height. If an object is passed, the screenshot size
  69336. * will be derived from the parameters. The precision property is a multiplier allowing
  69337. * rendering at a higher or lower resolution
  69338. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69339. * Check your browser for supported MIME types
  69340. * @param samples Texture samples (default: 1)
  69341. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69342. * @param fileName A name for for the downloaded file.
  69343. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69344. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69345. * to the src parameter of an <img> to display it
  69346. */
  69347. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69348. /**
  69349. * Gets height and width for screenshot size
  69350. * @private
  69351. */
  69352. private static _getScreenshotSize;
  69353. }
  69354. }
  69355. declare module BABYLON {
  69356. /**
  69357. * Interface for a data buffer
  69358. */
  69359. export interface IDataBuffer {
  69360. /**
  69361. * Reads bytes from the data buffer.
  69362. * @param byteOffset The byte offset to read
  69363. * @param byteLength The byte length to read
  69364. * @returns A promise that resolves when the bytes are read
  69365. */
  69366. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69367. /**
  69368. * The byte length of the buffer.
  69369. */
  69370. readonly byteLength: number;
  69371. }
  69372. /**
  69373. * Utility class for reading from a data buffer
  69374. */
  69375. export class DataReader {
  69376. /**
  69377. * The data buffer associated with this data reader.
  69378. */
  69379. readonly buffer: IDataBuffer;
  69380. /**
  69381. * The current byte offset from the beginning of the data buffer.
  69382. */
  69383. byteOffset: number;
  69384. private _dataView;
  69385. private _dataByteOffset;
  69386. /**
  69387. * Constructor
  69388. * @param buffer The buffer to read
  69389. */
  69390. constructor(buffer: IDataBuffer);
  69391. /**
  69392. * Loads the given byte length.
  69393. * @param byteLength The byte length to load
  69394. * @returns A promise that resolves when the load is complete
  69395. */
  69396. loadAsync(byteLength: number): Promise<void>;
  69397. /**
  69398. * Read a unsigned 32-bit integer from the currently loaded data range.
  69399. * @returns The 32-bit integer read
  69400. */
  69401. readUint32(): number;
  69402. /**
  69403. * Read a byte array from the currently loaded data range.
  69404. * @param byteLength The byte length to read
  69405. * @returns The byte array read
  69406. */
  69407. readUint8Array(byteLength: number): Uint8Array;
  69408. /**
  69409. * Read a string from the currently loaded data range.
  69410. * @param byteLength The byte length to read
  69411. * @returns The string read
  69412. */
  69413. readString(byteLength: number): string;
  69414. /**
  69415. * Skips the given byte length the currently loaded data range.
  69416. * @param byteLength The byte length to skip
  69417. */
  69418. skipBytes(byteLength: number): void;
  69419. }
  69420. }
  69421. declare module BABYLON {
  69422. /**
  69423. * Class for storing data to local storage if available or in-memory storage otherwise
  69424. */
  69425. export class DataStorage {
  69426. private static _Storage;
  69427. private static _GetStorage;
  69428. /**
  69429. * Reads a string from the data storage
  69430. * @param key The key to read
  69431. * @param defaultValue The value if the key doesn't exist
  69432. * @returns The string value
  69433. */
  69434. static ReadString(key: string, defaultValue: string): string;
  69435. /**
  69436. * Writes a string to the data storage
  69437. * @param key The key to write
  69438. * @param value The value to write
  69439. */
  69440. static WriteString(key: string, value: string): void;
  69441. /**
  69442. * Reads a boolean from the data storage
  69443. * @param key The key to read
  69444. * @param defaultValue The value if the key doesn't exist
  69445. * @returns The boolean value
  69446. */
  69447. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69448. /**
  69449. * Writes a boolean to the data storage
  69450. * @param key The key to write
  69451. * @param value The value to write
  69452. */
  69453. static WriteBoolean(key: string, value: boolean): void;
  69454. /**
  69455. * Reads a number from the data storage
  69456. * @param key The key to read
  69457. * @param defaultValue The value if the key doesn't exist
  69458. * @returns The number value
  69459. */
  69460. static ReadNumber(key: string, defaultValue: number): number;
  69461. /**
  69462. * Writes a number to the data storage
  69463. * @param key The key to write
  69464. * @param value The value to write
  69465. */
  69466. static WriteNumber(key: string, value: number): void;
  69467. }
  69468. }
  69469. declare module BABYLON {
  69470. /**
  69471. * Options used for hit testing
  69472. */
  69473. export interface IWebXRLegacyHitTestOptions {
  69474. /**
  69475. * Only test when user interacted with the scene. Default - hit test every frame
  69476. */
  69477. testOnPointerDownOnly?: boolean;
  69478. /**
  69479. * The node to use to transform the local results to world coordinates
  69480. */
  69481. worldParentNode?: TransformNode;
  69482. }
  69483. /**
  69484. * Interface defining the babylon result of raycasting/hit-test
  69485. */
  69486. export interface IWebXRLegacyHitResult {
  69487. /**
  69488. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69489. */
  69490. transformationMatrix: Matrix;
  69491. /**
  69492. * The native hit test result
  69493. */
  69494. xrHitResult: XRHitResult | XRHitTestResult;
  69495. }
  69496. /**
  69497. * The currently-working hit-test module.
  69498. * Hit test (or Ray-casting) is used to interact with the real world.
  69499. * For further information read here - https://github.com/immersive-web/hit-test
  69500. */
  69501. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69502. /**
  69503. * options to use when constructing this feature
  69504. */
  69505. readonly options: IWebXRLegacyHitTestOptions;
  69506. private _direction;
  69507. private _mat;
  69508. private _onSelectEnabled;
  69509. private _origin;
  69510. /**
  69511. * The module's name
  69512. */
  69513. static readonly Name: string;
  69514. /**
  69515. * The (Babylon) version of this module.
  69516. * This is an integer representing the implementation version.
  69517. * This number does not correspond to the WebXR specs version
  69518. */
  69519. static readonly Version: number;
  69520. /**
  69521. * Populated with the last native XR Hit Results
  69522. */
  69523. lastNativeXRHitResults: XRHitResult[];
  69524. /**
  69525. * Triggered when new babylon (transformed) hit test results are available
  69526. */
  69527. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69528. /**
  69529. * Creates a new instance of the (legacy version) hit test feature
  69530. * @param _xrSessionManager an instance of WebXRSessionManager
  69531. * @param options options to use when constructing this feature
  69532. */
  69533. constructor(_xrSessionManager: WebXRSessionManager,
  69534. /**
  69535. * options to use when constructing this feature
  69536. */
  69537. options?: IWebXRLegacyHitTestOptions);
  69538. /**
  69539. * execute a hit test with an XR Ray
  69540. *
  69541. * @param xrSession a native xrSession that will execute this hit test
  69542. * @param xrRay the ray (position and direction) to use for ray-casting
  69543. * @param referenceSpace native XR reference space to use for the hit-test
  69544. * @param filter filter function that will filter the results
  69545. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69546. */
  69547. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69548. /**
  69549. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69550. * @param event the (select) event to use to select with
  69551. * @param referenceSpace the reference space to use for this hit test
  69552. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69553. */
  69554. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69555. /**
  69556. * attach this feature
  69557. * Will usually be called by the features manager
  69558. *
  69559. * @returns true if successful.
  69560. */
  69561. attach(): boolean;
  69562. /**
  69563. * detach this feature.
  69564. * Will usually be called by the features manager
  69565. *
  69566. * @returns true if successful.
  69567. */
  69568. detach(): boolean;
  69569. /**
  69570. * Dispose this feature and all of the resources attached
  69571. */
  69572. dispose(): void;
  69573. protected _onXRFrame(frame: XRFrame): void;
  69574. private _onHitTestResults;
  69575. private _onSelect;
  69576. }
  69577. }
  69578. declare module BABYLON {
  69579. /**
  69580. * Options used in the plane detector module
  69581. */
  69582. export interface IWebXRPlaneDetectorOptions {
  69583. /**
  69584. * The node to use to transform the local results to world coordinates
  69585. */
  69586. worldParentNode?: TransformNode;
  69587. }
  69588. /**
  69589. * A babylon interface for a WebXR plane.
  69590. * A Plane is actually a polygon, built from N points in space
  69591. *
  69592. * Supported in chrome 79, not supported in canary 81 ATM
  69593. */
  69594. export interface IWebXRPlane {
  69595. /**
  69596. * a babylon-assigned ID for this polygon
  69597. */
  69598. id: number;
  69599. /**
  69600. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69601. */
  69602. polygonDefinition: Array<Vector3>;
  69603. /**
  69604. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69605. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69606. */
  69607. transformationMatrix: Matrix;
  69608. /**
  69609. * the native xr-plane object
  69610. */
  69611. xrPlane: XRPlane;
  69612. }
  69613. /**
  69614. * The plane detector is used to detect planes in the real world when in AR
  69615. * For more information see https://github.com/immersive-web/real-world-geometry/
  69616. */
  69617. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69618. private _options;
  69619. private _detectedPlanes;
  69620. private _enabled;
  69621. private _lastFrameDetected;
  69622. /**
  69623. * The module's name
  69624. */
  69625. static readonly Name: string;
  69626. /**
  69627. * The (Babylon) version of this module.
  69628. * This is an integer representing the implementation version.
  69629. * This number does not correspond to the WebXR specs version
  69630. */
  69631. static readonly Version: number;
  69632. /**
  69633. * Observers registered here will be executed when a new plane was added to the session
  69634. */
  69635. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69636. /**
  69637. * Observers registered here will be executed when a plane is no longer detected in the session
  69638. */
  69639. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69640. /**
  69641. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69642. * This can execute N times every frame
  69643. */
  69644. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69645. /**
  69646. * construct a new Plane Detector
  69647. * @param _xrSessionManager an instance of xr Session manager
  69648. * @param _options configuration to use when constructing this feature
  69649. */
  69650. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69651. /**
  69652. * Dispose this feature and all of the resources attached
  69653. */
  69654. dispose(): void;
  69655. protected _onXRFrame(frame: XRFrame): void;
  69656. private _init;
  69657. private _updatePlaneWithXRPlane;
  69658. /**
  69659. * avoiding using Array.find for global support.
  69660. * @param xrPlane the plane to find in the array
  69661. */
  69662. private findIndexInPlaneArray;
  69663. }
  69664. }
  69665. declare module BABYLON {
  69666. /**
  69667. * Configuration options of the anchor system
  69668. */
  69669. export interface IWebXRAnchorSystemOptions {
  69670. /**
  69671. * Should a new anchor be added every time a select event is triggered
  69672. */
  69673. addAnchorOnSelect?: boolean;
  69674. /**
  69675. * should the anchor system use plane detection.
  69676. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69677. */
  69678. usePlaneDetection?: boolean;
  69679. /**
  69680. * a node that will be used to convert local to world coordinates
  69681. */
  69682. worldParentNode?: TransformNode;
  69683. }
  69684. /**
  69685. * A babylon container for an XR Anchor
  69686. */
  69687. export interface IWebXRAnchor {
  69688. /**
  69689. * A babylon-assigned ID for this anchor
  69690. */
  69691. id: number;
  69692. /**
  69693. * Transformation matrix to apply to an object attached to this anchor
  69694. */
  69695. transformationMatrix: Matrix;
  69696. /**
  69697. * The native anchor object
  69698. */
  69699. xrAnchor: XRAnchor;
  69700. }
  69701. /**
  69702. * An implementation of the anchor system of WebXR.
  69703. * Note that the current documented implementation is not available in any browser. Future implementations
  69704. * will use the frame to create an anchor and not the session or a detected plane
  69705. * For further information see https://github.com/immersive-web/anchors/
  69706. */
  69707. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69708. private _options;
  69709. private _enabled;
  69710. private _hitTestModule;
  69711. private _lastFrameDetected;
  69712. private _onSelect;
  69713. private _planeDetector;
  69714. private _trackedAnchors;
  69715. /**
  69716. * The module's name
  69717. */
  69718. static readonly Name: string;
  69719. /**
  69720. * The (Babylon) version of this module.
  69721. * This is an integer representing the implementation version.
  69722. * This number does not correspond to the WebXR specs version
  69723. */
  69724. static readonly Version: number;
  69725. /**
  69726. * Observers registered here will be executed when a new anchor was added to the session
  69727. */
  69728. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69729. /**
  69730. * Observers registered here will be executed when an anchor was removed from the session
  69731. */
  69732. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69733. /**
  69734. * Observers registered here will be executed when an existing anchor updates
  69735. * This can execute N times every frame
  69736. */
  69737. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69738. /**
  69739. * constructs a new anchor system
  69740. * @param _xrSessionManager an instance of WebXRSessionManager
  69741. * @param _options configuration object for this feature
  69742. */
  69743. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69744. /**
  69745. * Add anchor at a specific XR point.
  69746. *
  69747. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69748. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69749. * @returns a promise the fulfills when the anchor was created
  69750. */
  69751. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69752. /**
  69753. * attach this feature
  69754. * Will usually be called by the features manager
  69755. *
  69756. * @returns true if successful.
  69757. */
  69758. attach(): boolean;
  69759. /**
  69760. * detach this feature.
  69761. * Will usually be called by the features manager
  69762. *
  69763. * @returns true if successful.
  69764. */
  69765. detach(): boolean;
  69766. /**
  69767. * Dispose this feature and all of the resources attached
  69768. */
  69769. dispose(): void;
  69770. /**
  69771. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69772. * @param hitTestModule the hit-test module to use.
  69773. */
  69774. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69775. /**
  69776. * set the plane detector to use in order to create anchors from frames
  69777. * @param planeDetector the plane-detector module to use
  69778. * @param enable enable plane-anchors. default is true
  69779. */
  69780. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69781. protected _onXRFrame(frame: XRFrame): void;
  69782. /**
  69783. * avoiding using Array.find for global support.
  69784. * @param xrAnchor the plane to find in the array
  69785. */
  69786. private _findIndexInAnchorArray;
  69787. private _updateAnchorWithXRFrame;
  69788. }
  69789. }
  69790. declare module BABYLON {
  69791. /**
  69792. * Options interface for the background remover plugin
  69793. */
  69794. export interface IWebXRBackgroundRemoverOptions {
  69795. /**
  69796. * Further background meshes to disable when entering AR
  69797. */
  69798. backgroundMeshes?: AbstractMesh[];
  69799. /**
  69800. * flags to configure the removal of the environment helper.
  69801. * If not set, the entire background will be removed. If set, flags should be set as well.
  69802. */
  69803. environmentHelperRemovalFlags?: {
  69804. /**
  69805. * Should the skybox be removed (default false)
  69806. */
  69807. skyBox?: boolean;
  69808. /**
  69809. * Should the ground be removed (default false)
  69810. */
  69811. ground?: boolean;
  69812. };
  69813. /**
  69814. * don't disable the environment helper
  69815. */
  69816. ignoreEnvironmentHelper?: boolean;
  69817. }
  69818. /**
  69819. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69820. */
  69821. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69822. /**
  69823. * read-only options to be used in this module
  69824. */
  69825. readonly options: IWebXRBackgroundRemoverOptions;
  69826. /**
  69827. * The module's name
  69828. */
  69829. static readonly Name: string;
  69830. /**
  69831. * The (Babylon) version of this module.
  69832. * This is an integer representing the implementation version.
  69833. * This number does not correspond to the WebXR specs version
  69834. */
  69835. static readonly Version: number;
  69836. /**
  69837. * registered observers will be triggered when the background state changes
  69838. */
  69839. onBackgroundStateChangedObservable: Observable<boolean>;
  69840. /**
  69841. * constructs a new background remover module
  69842. * @param _xrSessionManager the session manager for this module
  69843. * @param options read-only options to be used in this module
  69844. */
  69845. constructor(_xrSessionManager: WebXRSessionManager,
  69846. /**
  69847. * read-only options to be used in this module
  69848. */
  69849. options?: IWebXRBackgroundRemoverOptions);
  69850. /**
  69851. * attach this feature
  69852. * Will usually be called by the features manager
  69853. *
  69854. * @returns true if successful.
  69855. */
  69856. attach(): boolean;
  69857. /**
  69858. * detach this feature.
  69859. * Will usually be called by the features manager
  69860. *
  69861. * @returns true if successful.
  69862. */
  69863. detach(): boolean;
  69864. /**
  69865. * Dispose this feature and all of the resources attached
  69866. */
  69867. dispose(): void;
  69868. protected _onXRFrame(_xrFrame: XRFrame): void;
  69869. private _setBackgroundState;
  69870. }
  69871. }
  69872. declare module BABYLON {
  69873. /**
  69874. * Options for the controller physics feature
  69875. */
  69876. export class IWebXRControllerPhysicsOptions {
  69877. /**
  69878. * Should the headset get its own impostor
  69879. */
  69880. enableHeadsetImpostor?: boolean;
  69881. /**
  69882. * Optional parameters for the headset impostor
  69883. */
  69884. headsetImpostorParams?: {
  69885. /**
  69886. * The type of impostor to create. Default is sphere
  69887. */
  69888. impostorType: number;
  69889. /**
  69890. * the size of the impostor. Defaults to 10cm
  69891. */
  69892. impostorSize?: number | {
  69893. width: number;
  69894. height: number;
  69895. depth: number;
  69896. };
  69897. /**
  69898. * Friction definitions
  69899. */
  69900. friction?: number;
  69901. /**
  69902. * Restitution
  69903. */
  69904. restitution?: number;
  69905. };
  69906. /**
  69907. * The physics properties of the future impostors
  69908. */
  69909. physicsProperties?: {
  69910. /**
  69911. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69912. * Note that this requires a physics engine that supports mesh impostors!
  69913. */
  69914. useControllerMesh?: boolean;
  69915. /**
  69916. * The type of impostor to create. Default is sphere
  69917. */
  69918. impostorType?: number;
  69919. /**
  69920. * the size of the impostor. Defaults to 10cm
  69921. */
  69922. impostorSize?: number | {
  69923. width: number;
  69924. height: number;
  69925. depth: number;
  69926. };
  69927. /**
  69928. * Friction definitions
  69929. */
  69930. friction?: number;
  69931. /**
  69932. * Restitution
  69933. */
  69934. restitution?: number;
  69935. };
  69936. /**
  69937. * the xr input to use with this pointer selection
  69938. */
  69939. xrInput: WebXRInput;
  69940. }
  69941. /**
  69942. * Add physics impostor to your webxr controllers,
  69943. * including naive calculation of their linear and angular velocity
  69944. */
  69945. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69946. private readonly _options;
  69947. private _attachController;
  69948. private _controllers;
  69949. private _debugMode;
  69950. private _delta;
  69951. private _headsetImpostor?;
  69952. private _headsetMesh?;
  69953. private _lastTimestamp;
  69954. private _tmpQuaternion;
  69955. private _tmpVector;
  69956. /**
  69957. * The module's name
  69958. */
  69959. static readonly Name: string;
  69960. /**
  69961. * The (Babylon) version of this module.
  69962. * This is an integer representing the implementation version.
  69963. * This number does not correspond to the webxr specs version
  69964. */
  69965. static readonly Version: number;
  69966. /**
  69967. * Construct a new Controller Physics Feature
  69968. * @param _xrSessionManager the corresponding xr session manager
  69969. * @param _options options to create this feature with
  69970. */
  69971. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69972. /**
  69973. * @hidden
  69974. * enable debugging - will show console outputs and the impostor mesh
  69975. */
  69976. _enablePhysicsDebug(): void;
  69977. /**
  69978. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69979. * @param xrController the controller to add
  69980. */
  69981. addController(xrController: WebXRInputSource): void;
  69982. /**
  69983. * attach this feature
  69984. * Will usually be called by the features manager
  69985. *
  69986. * @returns true if successful.
  69987. */
  69988. attach(): boolean;
  69989. /**
  69990. * detach this feature.
  69991. * Will usually be called by the features manager
  69992. *
  69993. * @returns true if successful.
  69994. */
  69995. detach(): boolean;
  69996. /**
  69997. * Get the headset impostor, if enabled
  69998. * @returns the impostor
  69999. */
  70000. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70001. /**
  70002. * Get the physics impostor of a specific controller.
  70003. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70004. * @param controller the controller or the controller id of which to get the impostor
  70005. * @returns the impostor or null
  70006. */
  70007. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70008. /**
  70009. * Update the physics properties provided in the constructor
  70010. * @param newProperties the new properties object
  70011. */
  70012. setPhysicsProperties(newProperties: {
  70013. impostorType?: number;
  70014. impostorSize?: number | {
  70015. width: number;
  70016. height: number;
  70017. depth: number;
  70018. };
  70019. friction?: number;
  70020. restitution?: number;
  70021. }): void;
  70022. protected _onXRFrame(_xrFrame: any): void;
  70023. private _detachController;
  70024. }
  70025. }
  70026. declare module BABYLON {
  70027. /**
  70028. * Options used for hit testing (version 2)
  70029. */
  70030. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70031. /**
  70032. * Do not create a permanent hit test. Will usually be used when only
  70033. * transient inputs are needed.
  70034. */
  70035. disablePermanentHitTest?: boolean;
  70036. /**
  70037. * Enable transient (for example touch-based) hit test inspections
  70038. */
  70039. enableTransientHitTest?: boolean;
  70040. /**
  70041. * Offset ray for the permanent hit test
  70042. */
  70043. offsetRay?: Vector3;
  70044. /**
  70045. * Offset ray for the transient hit test
  70046. */
  70047. transientOffsetRay?: Vector3;
  70048. /**
  70049. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70050. */
  70051. useReferenceSpace?: boolean;
  70052. }
  70053. /**
  70054. * Interface defining the babylon result of hit-test
  70055. */
  70056. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70057. /**
  70058. * The input source that generated this hit test (if transient)
  70059. */
  70060. inputSource?: XRInputSource;
  70061. /**
  70062. * Is this a transient hit test
  70063. */
  70064. isTransient?: boolean;
  70065. /**
  70066. * Position of the hit test result
  70067. */
  70068. position: Vector3;
  70069. /**
  70070. * Rotation of the hit test result
  70071. */
  70072. rotationQuaternion: Quaternion;
  70073. }
  70074. /**
  70075. * The currently-working hit-test module.
  70076. * Hit test (or Ray-casting) is used to interact with the real world.
  70077. * For further information read here - https://github.com/immersive-web/hit-test
  70078. *
  70079. * Tested on chrome (mobile) 80.
  70080. */
  70081. export class WebXRHitTest extends WebXRAbstractFeature {
  70082. /**
  70083. * options to use when constructing this feature
  70084. */
  70085. readonly options: IWebXRHitTestOptions;
  70086. private _tmpMat;
  70087. private _tmpPos;
  70088. private _tmpQuat;
  70089. private _transientXrHitTestSource;
  70090. private _xrHitTestSource;
  70091. private initHitTestSource;
  70092. /**
  70093. * The module's name
  70094. */
  70095. static readonly Name: string;
  70096. /**
  70097. * The (Babylon) version of this module.
  70098. * This is an integer representing the implementation version.
  70099. * This number does not correspond to the WebXR specs version
  70100. */
  70101. static readonly Version: number;
  70102. /**
  70103. * When set to true, each hit test will have its own position/rotation objects
  70104. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70105. * the developers will clone them or copy them as they see fit.
  70106. */
  70107. autoCloneTransformation: boolean;
  70108. /**
  70109. * Populated with the last native XR Hit Results
  70110. */
  70111. lastNativeXRHitResults: XRHitResult[];
  70112. /**
  70113. * Triggered when new babylon (transformed) hit test results are available
  70114. */
  70115. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70116. /**
  70117. * Use this to temporarily pause hit test checks.
  70118. */
  70119. paused: boolean;
  70120. /**
  70121. * Creates a new instance of the hit test feature
  70122. * @param _xrSessionManager an instance of WebXRSessionManager
  70123. * @param options options to use when constructing this feature
  70124. */
  70125. constructor(_xrSessionManager: WebXRSessionManager,
  70126. /**
  70127. * options to use when constructing this feature
  70128. */
  70129. options?: IWebXRHitTestOptions);
  70130. /**
  70131. * attach this feature
  70132. * Will usually be called by the features manager
  70133. *
  70134. * @returns true if successful.
  70135. */
  70136. attach(): boolean;
  70137. /**
  70138. * detach this feature.
  70139. * Will usually be called by the features manager
  70140. *
  70141. * @returns true if successful.
  70142. */
  70143. detach(): boolean;
  70144. /**
  70145. * Dispose this feature and all of the resources attached
  70146. */
  70147. dispose(): void;
  70148. protected _onXRFrame(frame: XRFrame): void;
  70149. private _processWebXRHitTestResult;
  70150. }
  70151. }
  70152. declare module BABYLON {
  70153. /**
  70154. * The motion controller class for all microsoft mixed reality controllers
  70155. */
  70156. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70157. protected readonly _mapping: {
  70158. defaultButton: {
  70159. valueNodeName: string;
  70160. unpressedNodeName: string;
  70161. pressedNodeName: string;
  70162. };
  70163. defaultAxis: {
  70164. valueNodeName: string;
  70165. minNodeName: string;
  70166. maxNodeName: string;
  70167. };
  70168. buttons: {
  70169. "xr-standard-trigger": {
  70170. rootNodeName: string;
  70171. componentProperty: string;
  70172. states: string[];
  70173. };
  70174. "xr-standard-squeeze": {
  70175. rootNodeName: string;
  70176. componentProperty: string;
  70177. states: string[];
  70178. };
  70179. "xr-standard-touchpad": {
  70180. rootNodeName: string;
  70181. labelAnchorNodeName: string;
  70182. touchPointNodeName: string;
  70183. };
  70184. "xr-standard-thumbstick": {
  70185. rootNodeName: string;
  70186. componentProperty: string;
  70187. states: string[];
  70188. };
  70189. };
  70190. axes: {
  70191. "xr-standard-touchpad": {
  70192. "x-axis": {
  70193. rootNodeName: string;
  70194. };
  70195. "y-axis": {
  70196. rootNodeName: string;
  70197. };
  70198. };
  70199. "xr-standard-thumbstick": {
  70200. "x-axis": {
  70201. rootNodeName: string;
  70202. };
  70203. "y-axis": {
  70204. rootNodeName: string;
  70205. };
  70206. };
  70207. };
  70208. };
  70209. /**
  70210. * The base url used to load the left and right controller models
  70211. */
  70212. static MODEL_BASE_URL: string;
  70213. /**
  70214. * The name of the left controller model file
  70215. */
  70216. static MODEL_LEFT_FILENAME: string;
  70217. /**
  70218. * The name of the right controller model file
  70219. */
  70220. static MODEL_RIGHT_FILENAME: string;
  70221. profileId: string;
  70222. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70223. protected _getFilenameAndPath(): {
  70224. filename: string;
  70225. path: string;
  70226. };
  70227. protected _getModelLoadingConstraints(): boolean;
  70228. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70229. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70230. protected _updateModel(): void;
  70231. }
  70232. }
  70233. declare module BABYLON {
  70234. /**
  70235. * The motion controller class for oculus touch (quest, rift).
  70236. * This class supports legacy mapping as well the standard xr mapping
  70237. */
  70238. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70239. private _forceLegacyControllers;
  70240. private _modelRootNode;
  70241. /**
  70242. * The base url used to load the left and right controller models
  70243. */
  70244. static MODEL_BASE_URL: string;
  70245. /**
  70246. * The name of the left controller model file
  70247. */
  70248. static MODEL_LEFT_FILENAME: string;
  70249. /**
  70250. * The name of the right controller model file
  70251. */
  70252. static MODEL_RIGHT_FILENAME: string;
  70253. /**
  70254. * Base Url for the Quest controller model.
  70255. */
  70256. static QUEST_MODEL_BASE_URL: string;
  70257. profileId: string;
  70258. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70259. protected _getFilenameAndPath(): {
  70260. filename: string;
  70261. path: string;
  70262. };
  70263. protected _getModelLoadingConstraints(): boolean;
  70264. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70265. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70266. protected _updateModel(): void;
  70267. /**
  70268. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70269. * between the touch and touch 2.
  70270. */
  70271. private _isQuest;
  70272. }
  70273. }
  70274. declare module BABYLON {
  70275. /**
  70276. * The motion controller class for the standard HTC-Vive controllers
  70277. */
  70278. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70279. private _modelRootNode;
  70280. /**
  70281. * The base url used to load the left and right controller models
  70282. */
  70283. static MODEL_BASE_URL: string;
  70284. /**
  70285. * File name for the controller model.
  70286. */
  70287. static MODEL_FILENAME: string;
  70288. profileId: string;
  70289. /**
  70290. * Create a new Vive motion controller object
  70291. * @param scene the scene to use to create this controller
  70292. * @param gamepadObject the corresponding gamepad object
  70293. * @param handness the handness of the controller
  70294. */
  70295. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70296. protected _getFilenameAndPath(): {
  70297. filename: string;
  70298. path: string;
  70299. };
  70300. protected _getModelLoadingConstraints(): boolean;
  70301. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70302. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70303. protected _updateModel(): void;
  70304. }
  70305. }
  70306. declare module BABYLON {
  70307. /**
  70308. * A cursor which tracks a point on a path
  70309. */
  70310. export class PathCursor {
  70311. private path;
  70312. /**
  70313. * Stores path cursor callbacks for when an onchange event is triggered
  70314. */
  70315. private _onchange;
  70316. /**
  70317. * The value of the path cursor
  70318. */
  70319. value: number;
  70320. /**
  70321. * The animation array of the path cursor
  70322. */
  70323. animations: Animation[];
  70324. /**
  70325. * Initializes the path cursor
  70326. * @param path The path to track
  70327. */
  70328. constructor(path: Path2);
  70329. /**
  70330. * Gets the cursor point on the path
  70331. * @returns A point on the path cursor at the cursor location
  70332. */
  70333. getPoint(): Vector3;
  70334. /**
  70335. * Moves the cursor ahead by the step amount
  70336. * @param step The amount to move the cursor forward
  70337. * @returns This path cursor
  70338. */
  70339. moveAhead(step?: number): PathCursor;
  70340. /**
  70341. * Moves the cursor behind by the step amount
  70342. * @param step The amount to move the cursor back
  70343. * @returns This path cursor
  70344. */
  70345. moveBack(step?: number): PathCursor;
  70346. /**
  70347. * Moves the cursor by the step amount
  70348. * If the step amount is greater than one, an exception is thrown
  70349. * @param step The amount to move the cursor
  70350. * @returns This path cursor
  70351. */
  70352. move(step: number): PathCursor;
  70353. /**
  70354. * Ensures that the value is limited between zero and one
  70355. * @returns This path cursor
  70356. */
  70357. private ensureLimits;
  70358. /**
  70359. * Runs onchange callbacks on change (used by the animation engine)
  70360. * @returns This path cursor
  70361. */
  70362. private raiseOnChange;
  70363. /**
  70364. * Executes a function on change
  70365. * @param f A path cursor onchange callback
  70366. * @returns This path cursor
  70367. */
  70368. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70369. }
  70370. }
  70371. declare module BABYLON {
  70372. /** @hidden */
  70373. export var blurPixelShader: {
  70374. name: string;
  70375. shader: string;
  70376. };
  70377. }
  70378. declare module BABYLON {
  70379. /** @hidden */
  70380. export var pointCloudVertexDeclaration: {
  70381. name: string;
  70382. shader: string;
  70383. };
  70384. }
  70385. // Mixins
  70386. interface Window {
  70387. mozIndexedDB: IDBFactory;
  70388. webkitIndexedDB: IDBFactory;
  70389. msIndexedDB: IDBFactory;
  70390. webkitURL: typeof URL;
  70391. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70392. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70393. WebGLRenderingContext: WebGLRenderingContext;
  70394. MSGesture: MSGesture;
  70395. CANNON: any;
  70396. AudioContext: AudioContext;
  70397. webkitAudioContext: AudioContext;
  70398. PointerEvent: any;
  70399. Math: Math;
  70400. Uint8Array: Uint8ArrayConstructor;
  70401. Float32Array: Float32ArrayConstructor;
  70402. mozURL: typeof URL;
  70403. msURL: typeof URL;
  70404. VRFrameData: any; // WebVR, from specs 1.1
  70405. DracoDecoderModule: any;
  70406. setImmediate(handler: (...args: any[]) => void): number;
  70407. }
  70408. interface HTMLCanvasElement {
  70409. requestPointerLock(): void;
  70410. msRequestPointerLock?(): void;
  70411. mozRequestPointerLock?(): void;
  70412. webkitRequestPointerLock?(): void;
  70413. /** Track wether a record is in progress */
  70414. isRecording: boolean;
  70415. /** Capture Stream method defined by some browsers */
  70416. captureStream(fps?: number): MediaStream;
  70417. }
  70418. interface CanvasRenderingContext2D {
  70419. msImageSmoothingEnabled: boolean;
  70420. }
  70421. interface MouseEvent {
  70422. mozMovementX: number;
  70423. mozMovementY: number;
  70424. webkitMovementX: number;
  70425. webkitMovementY: number;
  70426. msMovementX: number;
  70427. msMovementY: number;
  70428. }
  70429. interface Navigator {
  70430. mozGetVRDevices: (any: any) => any;
  70431. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70432. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70433. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70434. webkitGetGamepads(): Gamepad[];
  70435. msGetGamepads(): Gamepad[];
  70436. webkitGamepads(): Gamepad[];
  70437. }
  70438. interface HTMLVideoElement {
  70439. mozSrcObject: any;
  70440. }
  70441. interface Math {
  70442. fround(x: number): number;
  70443. imul(a: number, b: number): number;
  70444. }
  70445. interface WebGLRenderingContext {
  70446. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70447. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70448. vertexAttribDivisor(index: number, divisor: number): void;
  70449. createVertexArray(): any;
  70450. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70451. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70452. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70453. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70454. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70455. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70456. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70457. // Queries
  70458. createQuery(): WebGLQuery;
  70459. deleteQuery(query: WebGLQuery): void;
  70460. beginQuery(target: number, query: WebGLQuery): void;
  70461. endQuery(target: number): void;
  70462. getQueryParameter(query: WebGLQuery, pname: number): any;
  70463. getQuery(target: number, pname: number): any;
  70464. MAX_SAMPLES: number;
  70465. RGBA8: number;
  70466. READ_FRAMEBUFFER: number;
  70467. DRAW_FRAMEBUFFER: number;
  70468. UNIFORM_BUFFER: number;
  70469. HALF_FLOAT_OES: number;
  70470. RGBA16F: number;
  70471. RGBA32F: number;
  70472. R32F: number;
  70473. RG32F: number;
  70474. RGB32F: number;
  70475. R16F: number;
  70476. RG16F: number;
  70477. RGB16F: number;
  70478. RED: number;
  70479. RG: number;
  70480. R8: number;
  70481. RG8: number;
  70482. UNSIGNED_INT_24_8: number;
  70483. DEPTH24_STENCIL8: number;
  70484. MIN: number;
  70485. MAX: number;
  70486. /* Multiple Render Targets */
  70487. drawBuffers(buffers: number[]): void;
  70488. readBuffer(src: number): void;
  70489. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70490. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70491. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70492. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70493. // Occlusion Query
  70494. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70495. ANY_SAMPLES_PASSED: number;
  70496. QUERY_RESULT_AVAILABLE: number;
  70497. QUERY_RESULT: number;
  70498. }
  70499. interface WebGLProgram {
  70500. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70501. }
  70502. interface EXT_disjoint_timer_query {
  70503. QUERY_COUNTER_BITS_EXT: number;
  70504. TIME_ELAPSED_EXT: number;
  70505. TIMESTAMP_EXT: number;
  70506. GPU_DISJOINT_EXT: number;
  70507. QUERY_RESULT_EXT: number;
  70508. QUERY_RESULT_AVAILABLE_EXT: number;
  70509. queryCounterEXT(query: WebGLQuery, target: number): void;
  70510. createQueryEXT(): WebGLQuery;
  70511. beginQueryEXT(target: number, query: WebGLQuery): void;
  70512. endQueryEXT(target: number): void;
  70513. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70514. deleteQueryEXT(query: WebGLQuery): void;
  70515. }
  70516. interface WebGLUniformLocation {
  70517. _currentState: any;
  70518. }
  70519. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70520. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70521. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70522. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70523. interface WebGLRenderingContext {
  70524. readonly RASTERIZER_DISCARD: number;
  70525. readonly DEPTH_COMPONENT24: number;
  70526. readonly TEXTURE_3D: number;
  70527. readonly TEXTURE_2D_ARRAY: number;
  70528. readonly TEXTURE_COMPARE_FUNC: number;
  70529. readonly TEXTURE_COMPARE_MODE: number;
  70530. readonly COMPARE_REF_TO_TEXTURE: number;
  70531. readonly TEXTURE_WRAP_R: number;
  70532. readonly HALF_FLOAT: number;
  70533. readonly RGB8: number;
  70534. readonly RED_INTEGER: number;
  70535. readonly RG_INTEGER: number;
  70536. readonly RGB_INTEGER: number;
  70537. readonly RGBA_INTEGER: number;
  70538. readonly R8_SNORM: number;
  70539. readonly RG8_SNORM: number;
  70540. readonly RGB8_SNORM: number;
  70541. readonly RGBA8_SNORM: number;
  70542. readonly R8I: number;
  70543. readonly RG8I: number;
  70544. readonly RGB8I: number;
  70545. readonly RGBA8I: number;
  70546. readonly R8UI: number;
  70547. readonly RG8UI: number;
  70548. readonly RGB8UI: number;
  70549. readonly RGBA8UI: number;
  70550. readonly R16I: number;
  70551. readonly RG16I: number;
  70552. readonly RGB16I: number;
  70553. readonly RGBA16I: number;
  70554. readonly R16UI: number;
  70555. readonly RG16UI: number;
  70556. readonly RGB16UI: number;
  70557. readonly RGBA16UI: number;
  70558. readonly R32I: number;
  70559. readonly RG32I: number;
  70560. readonly RGB32I: number;
  70561. readonly RGBA32I: number;
  70562. readonly R32UI: number;
  70563. readonly RG32UI: number;
  70564. readonly RGB32UI: number;
  70565. readonly RGBA32UI: number;
  70566. readonly RGB10_A2UI: number;
  70567. readonly R11F_G11F_B10F: number;
  70568. readonly RGB9_E5: number;
  70569. readonly RGB10_A2: number;
  70570. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70571. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70572. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70573. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70574. readonly DEPTH_COMPONENT32F: number;
  70575. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70576. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70577. 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;
  70578. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70579. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70580. readonly TRANSFORM_FEEDBACK: number;
  70581. readonly INTERLEAVED_ATTRIBS: number;
  70582. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70583. createTransformFeedback(): WebGLTransformFeedback;
  70584. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70585. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70586. beginTransformFeedback(primitiveMode: number): void;
  70587. endTransformFeedback(): void;
  70588. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70589. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70590. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70591. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70592. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70593. }
  70594. interface ImageBitmap {
  70595. readonly width: number;
  70596. readonly height: number;
  70597. close(): void;
  70598. }
  70599. interface WebGLQuery extends WebGLObject {
  70600. }
  70601. declare var WebGLQuery: {
  70602. prototype: WebGLQuery;
  70603. new(): WebGLQuery;
  70604. };
  70605. interface WebGLSampler extends WebGLObject {
  70606. }
  70607. declare var WebGLSampler: {
  70608. prototype: WebGLSampler;
  70609. new(): WebGLSampler;
  70610. };
  70611. interface WebGLSync extends WebGLObject {
  70612. }
  70613. declare var WebGLSync: {
  70614. prototype: WebGLSync;
  70615. new(): WebGLSync;
  70616. };
  70617. interface WebGLTransformFeedback extends WebGLObject {
  70618. }
  70619. declare var WebGLTransformFeedback: {
  70620. prototype: WebGLTransformFeedback;
  70621. new(): WebGLTransformFeedback;
  70622. };
  70623. interface WebGLVertexArrayObject extends WebGLObject {
  70624. }
  70625. declare var WebGLVertexArrayObject: {
  70626. prototype: WebGLVertexArrayObject;
  70627. new(): WebGLVertexArrayObject;
  70628. };
  70629. // Type definitions for WebVR API
  70630. // Project: https://w3c.github.io/webvr/
  70631. // Definitions by: six a <https://github.com/lostfictions>
  70632. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70633. interface VRDisplay extends EventTarget {
  70634. /**
  70635. * Dictionary of capabilities describing the VRDisplay.
  70636. */
  70637. readonly capabilities: VRDisplayCapabilities;
  70638. /**
  70639. * z-depth defining the far plane of the eye view frustum
  70640. * enables mapping of values in the render target depth
  70641. * attachment to scene coordinates. Initially set to 10000.0.
  70642. */
  70643. depthFar: number;
  70644. /**
  70645. * z-depth defining the near plane of the eye view frustum
  70646. * enables mapping of values in the render target depth
  70647. * attachment to scene coordinates. Initially set to 0.01.
  70648. */
  70649. depthNear: number;
  70650. /**
  70651. * An identifier for this distinct VRDisplay. Used as an
  70652. * association point in the Gamepad API.
  70653. */
  70654. readonly displayId: number;
  70655. /**
  70656. * A display name, a user-readable name identifying it.
  70657. */
  70658. readonly displayName: string;
  70659. readonly isConnected: boolean;
  70660. readonly isPresenting: boolean;
  70661. /**
  70662. * If this VRDisplay supports room-scale experiences, the optional
  70663. * stage attribute contains details on the room-scale parameters.
  70664. */
  70665. readonly stageParameters: VRStageParameters | null;
  70666. /**
  70667. * Passing the value returned by `requestAnimationFrame` to
  70668. * `cancelAnimationFrame` will unregister the callback.
  70669. * @param handle Define the hanle of the request to cancel
  70670. */
  70671. cancelAnimationFrame(handle: number): void;
  70672. /**
  70673. * Stops presenting to the VRDisplay.
  70674. * @returns a promise to know when it stopped
  70675. */
  70676. exitPresent(): Promise<void>;
  70677. /**
  70678. * Return the current VREyeParameters for the given eye.
  70679. * @param whichEye Define the eye we want the parameter for
  70680. * @returns the eye parameters
  70681. */
  70682. getEyeParameters(whichEye: string): VREyeParameters;
  70683. /**
  70684. * Populates the passed VRFrameData with the information required to render
  70685. * the current frame.
  70686. * @param frameData Define the data structure to populate
  70687. * @returns true if ok otherwise false
  70688. */
  70689. getFrameData(frameData: VRFrameData): boolean;
  70690. /**
  70691. * Get the layers currently being presented.
  70692. * @returns the list of VR layers
  70693. */
  70694. getLayers(): VRLayer[];
  70695. /**
  70696. * Return a VRPose containing the future predicted pose of the VRDisplay
  70697. * when the current frame will be presented. The value returned will not
  70698. * change until JavaScript has returned control to the browser.
  70699. *
  70700. * The VRPose will contain the position, orientation, velocity,
  70701. * and acceleration of each of these properties.
  70702. * @returns the pose object
  70703. */
  70704. getPose(): VRPose;
  70705. /**
  70706. * Return the current instantaneous pose of the VRDisplay, with no
  70707. * prediction applied.
  70708. * @returns the current instantaneous pose
  70709. */
  70710. getImmediatePose(): VRPose;
  70711. /**
  70712. * The callback passed to `requestAnimationFrame` will be called
  70713. * any time a new frame should be rendered. When the VRDisplay is
  70714. * presenting the callback will be called at the native refresh
  70715. * rate of the HMD. When not presenting this function acts
  70716. * identically to how window.requestAnimationFrame acts. Content should
  70717. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70718. * asynchronously from other displays and at differing refresh rates.
  70719. * @param callback Define the eaction to run next frame
  70720. * @returns the request handle it
  70721. */
  70722. requestAnimationFrame(callback: FrameRequestCallback): number;
  70723. /**
  70724. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70725. * Repeat calls while already presenting will update the VRLayers being displayed.
  70726. * @param layers Define the list of layer to present
  70727. * @returns a promise to know when the request has been fulfilled
  70728. */
  70729. requestPresent(layers: VRLayer[]): Promise<void>;
  70730. /**
  70731. * Reset the pose for this display, treating its current position and
  70732. * orientation as the "origin/zero" values. VRPose.position,
  70733. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70734. * updated when calling resetPose(). This should be called in only
  70735. * sitting-space experiences.
  70736. */
  70737. resetPose(): void;
  70738. /**
  70739. * The VRLayer provided to the VRDisplay will be captured and presented
  70740. * in the HMD. Calling this function has the same effect on the source
  70741. * canvas as any other operation that uses its source image, and canvases
  70742. * created without preserveDrawingBuffer set to true will be cleared.
  70743. * @param pose Define the pose to submit
  70744. */
  70745. submitFrame(pose?: VRPose): void;
  70746. }
  70747. declare var VRDisplay: {
  70748. prototype: VRDisplay;
  70749. new(): VRDisplay;
  70750. };
  70751. interface VRLayer {
  70752. leftBounds?: number[] | Float32Array | null;
  70753. rightBounds?: number[] | Float32Array | null;
  70754. source?: HTMLCanvasElement | null;
  70755. }
  70756. interface VRDisplayCapabilities {
  70757. readonly canPresent: boolean;
  70758. readonly hasExternalDisplay: boolean;
  70759. readonly hasOrientation: boolean;
  70760. readonly hasPosition: boolean;
  70761. readonly maxLayers: number;
  70762. }
  70763. interface VREyeParameters {
  70764. /** @deprecated */
  70765. readonly fieldOfView: VRFieldOfView;
  70766. readonly offset: Float32Array;
  70767. readonly renderHeight: number;
  70768. readonly renderWidth: number;
  70769. }
  70770. interface VRFieldOfView {
  70771. readonly downDegrees: number;
  70772. readonly leftDegrees: number;
  70773. readonly rightDegrees: number;
  70774. readonly upDegrees: number;
  70775. }
  70776. interface VRFrameData {
  70777. readonly leftProjectionMatrix: Float32Array;
  70778. readonly leftViewMatrix: Float32Array;
  70779. readonly pose: VRPose;
  70780. readonly rightProjectionMatrix: Float32Array;
  70781. readonly rightViewMatrix: Float32Array;
  70782. readonly timestamp: number;
  70783. }
  70784. interface VRPose {
  70785. readonly angularAcceleration: Float32Array | null;
  70786. readonly angularVelocity: Float32Array | null;
  70787. readonly linearAcceleration: Float32Array | null;
  70788. readonly linearVelocity: Float32Array | null;
  70789. readonly orientation: Float32Array | null;
  70790. readonly position: Float32Array | null;
  70791. readonly timestamp: number;
  70792. }
  70793. interface VRStageParameters {
  70794. sittingToStandingTransform?: Float32Array;
  70795. sizeX?: number;
  70796. sizeY?: number;
  70797. }
  70798. interface Navigator {
  70799. getVRDisplays(): Promise<VRDisplay[]>;
  70800. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70801. }
  70802. interface Window {
  70803. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70804. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70805. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70806. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70807. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70808. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70809. }
  70810. interface Gamepad {
  70811. readonly displayId: number;
  70812. }
  70813. type XRSessionMode =
  70814. | "inline"
  70815. | "immersive-vr"
  70816. | "immersive-ar";
  70817. type XRReferenceSpaceType =
  70818. | "viewer"
  70819. | "local"
  70820. | "local-floor"
  70821. | "bounded-floor"
  70822. | "unbounded";
  70823. type XREnvironmentBlendMode =
  70824. | "opaque"
  70825. | "additive"
  70826. | "alpha-blend";
  70827. type XRVisibilityState =
  70828. | "visible"
  70829. | "visible-blurred"
  70830. | "hidden";
  70831. type XRHandedness =
  70832. | "none"
  70833. | "left"
  70834. | "right";
  70835. type XRTargetRayMode =
  70836. | "gaze"
  70837. | "tracked-pointer"
  70838. | "screen";
  70839. type XREye =
  70840. | "none"
  70841. | "left"
  70842. | "right";
  70843. interface XRSpace extends EventTarget {
  70844. }
  70845. interface XRRenderState {
  70846. depthNear?: number;
  70847. depthFar?: number;
  70848. inlineVerticalFieldOfView?: number;
  70849. baseLayer?: XRWebGLLayer;
  70850. }
  70851. interface XRInputSource {
  70852. handedness: XRHandedness;
  70853. targetRayMode: XRTargetRayMode;
  70854. targetRaySpace: XRSpace;
  70855. gripSpace: XRSpace | undefined;
  70856. gamepad: Gamepad | undefined;
  70857. profiles: Array<string>;
  70858. }
  70859. interface XRSessionInit {
  70860. optionalFeatures?: XRReferenceSpaceType[];
  70861. requiredFeatures?: XRReferenceSpaceType[];
  70862. }
  70863. interface XRSession extends XRAnchorCreator {
  70864. addEventListener: Function;
  70865. removeEventListener: Function;
  70866. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70867. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70868. requestAnimationFrame: Function;
  70869. end(): Promise<void>;
  70870. renderState: XRRenderState;
  70871. inputSources: Array<XRInputSource>;
  70872. // hit test
  70873. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  70874. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  70875. // legacy AR hit test
  70876. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70877. // legacy plane detection
  70878. updateWorldTrackingState(options: {
  70879. planeDetectionState?: { enabled: boolean; }
  70880. }): void;
  70881. }
  70882. interface XRReferenceSpace extends XRSpace {
  70883. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70884. onreset: any;
  70885. }
  70886. type XRPlaneSet = Set<XRPlane>;
  70887. type XRAnchorSet = Set<XRAnchor>;
  70888. interface XRFrame {
  70889. session: XRSession;
  70890. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70891. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70892. // AR
  70893. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  70894. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  70895. // Anchors
  70896. trackedAnchors?: XRAnchorSet;
  70897. // Planes
  70898. worldInformation: {
  70899. detectedPlanes?: XRPlaneSet;
  70900. };
  70901. }
  70902. interface XRViewerPose extends XRPose {
  70903. views: Array<XRView>;
  70904. }
  70905. interface XRPose {
  70906. transform: XRRigidTransform;
  70907. emulatedPosition: boolean;
  70908. }
  70909. interface XRWebGLLayerOptions {
  70910. antialias?: boolean;
  70911. depth?: boolean;
  70912. stencil?: boolean;
  70913. alpha?: boolean;
  70914. multiview?: boolean;
  70915. framebufferScaleFactor?: number;
  70916. }
  70917. declare var XRWebGLLayer: {
  70918. prototype: XRWebGLLayer;
  70919. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70920. };
  70921. interface XRWebGLLayer {
  70922. framebuffer: WebGLFramebuffer;
  70923. framebufferWidth: number;
  70924. framebufferHeight: number;
  70925. getViewport: Function;
  70926. }
  70927. declare class XRRigidTransform {
  70928. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70929. position: DOMPointReadOnly;
  70930. orientation: DOMPointReadOnly;
  70931. matrix: Float32Array;
  70932. inverse: XRRigidTransform;
  70933. }
  70934. interface XRView {
  70935. eye: XREye;
  70936. projectionMatrix: Float32Array;
  70937. transform: XRRigidTransform;
  70938. }
  70939. interface XRInputSourceChangeEvent {
  70940. session: XRSession;
  70941. removed: Array<XRInputSource>;
  70942. added: Array<XRInputSource>;
  70943. }
  70944. interface XRInputSourceEvent extends Event {
  70945. readonly frame: XRFrame;
  70946. readonly inputSource: XRInputSource;
  70947. }
  70948. // Experimental(er) features
  70949. declare class XRRay {
  70950. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70951. origin: DOMPointReadOnly;
  70952. direction: DOMPointReadOnly;
  70953. matrix: Float32Array;
  70954. }
  70955. declare enum XRHitTestTrackableType {
  70956. "point",
  70957. "plane"
  70958. }
  70959. interface XRHitResult {
  70960. hitMatrix: Float32Array;
  70961. }
  70962. interface XRTransientInputHitTestResult {
  70963. readonly inputSource: XRInputSource;
  70964. readonly results: Array<XRHitTestResult>;
  70965. }
  70966. interface XRHitTestResult {
  70967. getPose(baseSpace: XRSpace): XRPose | undefined;
  70968. }
  70969. interface XRHitTestSource {
  70970. cancel(): void;
  70971. }
  70972. interface XRTransientInputHitTestSource {
  70973. cancel(): void;
  70974. }
  70975. interface XRHitTestOptionsInit {
  70976. space: XRSpace;
  70977. entityTypes?: Array<XRHitTestTrackableType>;
  70978. offsetRay?: XRRay;
  70979. }
  70980. interface XRTransientInputHitTestOptionsInit {
  70981. profile: string;
  70982. entityTypes?: Array<XRHitTestTrackableType>;
  70983. offsetRay?: XRRay;
  70984. }
  70985. interface XRAnchor {
  70986. // remove?
  70987. id?: string;
  70988. anchorSpace: XRSpace;
  70989. lastChangedTime: number;
  70990. detach(): void;
  70991. }
  70992. interface XRPlane extends XRAnchorCreator {
  70993. orientation: "Horizontal" | "Vertical";
  70994. planeSpace: XRSpace;
  70995. polygon: Array<DOMPointReadOnly>;
  70996. lastChangedTime: number;
  70997. }
  70998. interface XRAnchorCreator {
  70999. // AR Anchors
  71000. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71001. }
  71002. /**
  71003. * @ignore
  71004. */
  71005. declare module BABYLON.GLTF2.Exporter {
  71006. }
  71007. /**
  71008. * @ignore
  71009. */
  71010. declare module BABYLON.GLTF1 {
  71011. }
  71012. declare module BABYLON.GUI {
  71013. /**
  71014. * Class used to specific a value and its associated unit
  71015. */
  71016. export class ValueAndUnit {
  71017. /** defines the unit to store */
  71018. unit: number;
  71019. /** defines a boolean indicating if the value can be negative */
  71020. negativeValueAllowed: boolean;
  71021. private _value;
  71022. private _originalUnit;
  71023. /**
  71024. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71025. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71026. */
  71027. ignoreAdaptiveScaling: boolean;
  71028. /**
  71029. * Creates a new ValueAndUnit
  71030. * @param value defines the value to store
  71031. * @param unit defines the unit to store
  71032. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71033. */
  71034. constructor(value: number,
  71035. /** defines the unit to store */
  71036. unit?: number,
  71037. /** defines a boolean indicating if the value can be negative */
  71038. negativeValueAllowed?: boolean);
  71039. /** Gets a boolean indicating if the value is a percentage */
  71040. get isPercentage(): boolean;
  71041. /** Gets a boolean indicating if the value is store as pixel */
  71042. get isPixel(): boolean;
  71043. /** Gets direct internal value */
  71044. get internalValue(): number;
  71045. /**
  71046. * Gets value as pixel
  71047. * @param host defines the root host
  71048. * @param refValue defines the reference value for percentages
  71049. * @returns the value as pixel
  71050. */
  71051. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71052. /**
  71053. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71054. * @param value defines the value to store
  71055. * @param unit defines the unit to store
  71056. * @returns the current ValueAndUnit
  71057. */
  71058. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71059. /**
  71060. * Gets the value accordingly to its unit
  71061. * @param host defines the root host
  71062. * @returns the value
  71063. */
  71064. getValue(host: AdvancedDynamicTexture): number;
  71065. /**
  71066. * Gets a string representation of the value
  71067. * @param host defines the root host
  71068. * @param decimals defines an optional number of decimals to display
  71069. * @returns a string
  71070. */
  71071. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71072. /**
  71073. * Store a value parsed from a string
  71074. * @param source defines the source string
  71075. * @returns true if the value was successfully parsed
  71076. */
  71077. fromString(source: string | number): boolean;
  71078. private static _Regex;
  71079. private static _UNITMODE_PERCENTAGE;
  71080. private static _UNITMODE_PIXEL;
  71081. /** UNITMODE_PERCENTAGE */
  71082. static get UNITMODE_PERCENTAGE(): number;
  71083. /** UNITMODE_PIXEL */
  71084. static get UNITMODE_PIXEL(): number;
  71085. }
  71086. }
  71087. declare module BABYLON.GUI {
  71088. /**
  71089. * Define a style used by control to automatically setup properties based on a template.
  71090. * Only support font related properties so far
  71091. */
  71092. export class Style implements BABYLON.IDisposable {
  71093. private _fontFamily;
  71094. private _fontStyle;
  71095. private _fontWeight;
  71096. /** @hidden */
  71097. _host: AdvancedDynamicTexture;
  71098. /** @hidden */
  71099. _fontSize: ValueAndUnit;
  71100. /**
  71101. * BABYLON.Observable raised when the style values are changed
  71102. */
  71103. onChangedObservable: BABYLON.Observable<Style>;
  71104. /**
  71105. * Creates a new style object
  71106. * @param host defines the AdvancedDynamicTexture which hosts this style
  71107. */
  71108. constructor(host: AdvancedDynamicTexture);
  71109. /**
  71110. * Gets or sets the font size
  71111. */
  71112. get fontSize(): string | number;
  71113. set fontSize(value: string | number);
  71114. /**
  71115. * Gets or sets the font family
  71116. */
  71117. get fontFamily(): string;
  71118. set fontFamily(value: string);
  71119. /**
  71120. * Gets or sets the font style
  71121. */
  71122. get fontStyle(): string;
  71123. set fontStyle(value: string);
  71124. /** Gets or sets font weight */
  71125. get fontWeight(): string;
  71126. set fontWeight(value: string);
  71127. /** Dispose all associated resources */
  71128. dispose(): void;
  71129. }
  71130. }
  71131. declare module BABYLON.GUI {
  71132. /**
  71133. * Class used to transport BABYLON.Vector2 information for pointer events
  71134. */
  71135. export class Vector2WithInfo extends BABYLON.Vector2 {
  71136. /** defines the current mouse button index */
  71137. buttonIndex: number;
  71138. /**
  71139. * Creates a new Vector2WithInfo
  71140. * @param source defines the vector2 data to transport
  71141. * @param buttonIndex defines the current mouse button index
  71142. */
  71143. constructor(source: BABYLON.Vector2,
  71144. /** defines the current mouse button index */
  71145. buttonIndex?: number);
  71146. }
  71147. /** Class used to provide 2D matrix features */
  71148. export class Matrix2D {
  71149. /** Gets the internal array of 6 floats used to store matrix data */
  71150. m: Float32Array;
  71151. /**
  71152. * Creates a new matrix
  71153. * @param m00 defines value for (0, 0)
  71154. * @param m01 defines value for (0, 1)
  71155. * @param m10 defines value for (1, 0)
  71156. * @param m11 defines value for (1, 1)
  71157. * @param m20 defines value for (2, 0)
  71158. * @param m21 defines value for (2, 1)
  71159. */
  71160. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71161. /**
  71162. * Fills the matrix from direct values
  71163. * @param m00 defines value for (0, 0)
  71164. * @param m01 defines value for (0, 1)
  71165. * @param m10 defines value for (1, 0)
  71166. * @param m11 defines value for (1, 1)
  71167. * @param m20 defines value for (2, 0)
  71168. * @param m21 defines value for (2, 1)
  71169. * @returns the current modified matrix
  71170. */
  71171. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71172. /**
  71173. * Gets matrix determinant
  71174. * @returns the determinant
  71175. */
  71176. determinant(): number;
  71177. /**
  71178. * Inverses the matrix and stores it in a target matrix
  71179. * @param result defines the target matrix
  71180. * @returns the current matrix
  71181. */
  71182. invertToRef(result: Matrix2D): Matrix2D;
  71183. /**
  71184. * Multiplies the current matrix with another one
  71185. * @param other defines the second operand
  71186. * @param result defines the target matrix
  71187. * @returns the current matrix
  71188. */
  71189. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71190. /**
  71191. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71192. * @param x defines the x coordinate to transform
  71193. * @param y defines the x coordinate to transform
  71194. * @param result defines the target vector2
  71195. * @returns the current matrix
  71196. */
  71197. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71198. /**
  71199. * Creates an identity matrix
  71200. * @returns a new matrix
  71201. */
  71202. static Identity(): Matrix2D;
  71203. /**
  71204. * Creates a translation matrix and stores it in a target matrix
  71205. * @param x defines the x coordinate of the translation
  71206. * @param y defines the y coordinate of the translation
  71207. * @param result defines the target matrix
  71208. */
  71209. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71210. /**
  71211. * Creates a scaling matrix and stores it in a target matrix
  71212. * @param x defines the x coordinate of the scaling
  71213. * @param y defines the y coordinate of the scaling
  71214. * @param result defines the target matrix
  71215. */
  71216. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71217. /**
  71218. * Creates a rotation matrix and stores it in a target matrix
  71219. * @param angle defines the rotation angle
  71220. * @param result defines the target matrix
  71221. */
  71222. static RotationToRef(angle: number, result: Matrix2D): void;
  71223. private static _TempPreTranslationMatrix;
  71224. private static _TempPostTranslationMatrix;
  71225. private static _TempRotationMatrix;
  71226. private static _TempScalingMatrix;
  71227. private static _TempCompose0;
  71228. private static _TempCompose1;
  71229. private static _TempCompose2;
  71230. /**
  71231. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71232. * @param tx defines the x coordinate of the translation
  71233. * @param ty defines the y coordinate of the translation
  71234. * @param angle defines the rotation angle
  71235. * @param scaleX defines the x coordinate of the scaling
  71236. * @param scaleY defines the y coordinate of the scaling
  71237. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71238. * @param result defines the target matrix
  71239. */
  71240. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71241. }
  71242. }
  71243. declare module BABYLON.GUI {
  71244. /**
  71245. * Class used to store 2D control sizes
  71246. */
  71247. export class Measure {
  71248. /** defines left coordinate */
  71249. left: number;
  71250. /** defines top coordinate */
  71251. top: number;
  71252. /** defines width dimension */
  71253. width: number;
  71254. /** defines height dimension */
  71255. height: number;
  71256. /**
  71257. * Creates a new measure
  71258. * @param left defines left coordinate
  71259. * @param top defines top coordinate
  71260. * @param width defines width dimension
  71261. * @param height defines height dimension
  71262. */
  71263. constructor(
  71264. /** defines left coordinate */
  71265. left: number,
  71266. /** defines top coordinate */
  71267. top: number,
  71268. /** defines width dimension */
  71269. width: number,
  71270. /** defines height dimension */
  71271. height: number);
  71272. /**
  71273. * Copy from another measure
  71274. * @param other defines the other measure to copy from
  71275. */
  71276. copyFrom(other: Measure): void;
  71277. /**
  71278. * Copy from a group of 4 floats
  71279. * @param left defines left coordinate
  71280. * @param top defines top coordinate
  71281. * @param width defines width dimension
  71282. * @param height defines height dimension
  71283. */
  71284. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71285. /**
  71286. * Computes the axis aligned bounding box measure for two given measures
  71287. * @param a Input measure
  71288. * @param b Input measure
  71289. * @param result the resulting bounding measure
  71290. */
  71291. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71292. /**
  71293. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71294. * @param transform the matrix to transform the measure before computing the AABB
  71295. * @param result the resulting AABB
  71296. */
  71297. transformToRef(transform: Matrix2D, result: Measure): void;
  71298. /**
  71299. * Check equality between this measure and another one
  71300. * @param other defines the other measures
  71301. * @returns true if both measures are equals
  71302. */
  71303. isEqualsTo(other: Measure): boolean;
  71304. /**
  71305. * Creates an empty measure
  71306. * @returns a new measure
  71307. */
  71308. static Empty(): Measure;
  71309. }
  71310. }
  71311. declare module BABYLON.GUI {
  71312. /**
  71313. * Interface used to define a control that can receive focus
  71314. */
  71315. export interface IFocusableControl {
  71316. /**
  71317. * Function called when the control receives the focus
  71318. */
  71319. onFocus(): void;
  71320. /**
  71321. * Function called when the control loses the focus
  71322. */
  71323. onBlur(): void;
  71324. /**
  71325. * Function called to let the control handle keyboard events
  71326. * @param evt defines the current keyboard event
  71327. */
  71328. processKeyboard(evt: KeyboardEvent): void;
  71329. /**
  71330. * Function called to get the list of controls that should not steal the focus from this control
  71331. * @returns an array of controls
  71332. */
  71333. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71334. }
  71335. /**
  71336. * Class used to create texture to support 2D GUI elements
  71337. * @see http://doc.babylonjs.com/how_to/gui
  71338. */
  71339. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71340. private _isDirty;
  71341. private _renderObserver;
  71342. private _resizeObserver;
  71343. private _preKeyboardObserver;
  71344. private _pointerMoveObserver;
  71345. private _pointerObserver;
  71346. private _canvasPointerOutObserver;
  71347. private _background;
  71348. /** @hidden */
  71349. _rootContainer: Container;
  71350. /** @hidden */
  71351. _lastPickedControl: Control;
  71352. /** @hidden */
  71353. _lastControlOver: {
  71354. [pointerId: number]: Control;
  71355. };
  71356. /** @hidden */
  71357. _lastControlDown: {
  71358. [pointerId: number]: Control;
  71359. };
  71360. /** @hidden */
  71361. _capturingControl: {
  71362. [pointerId: number]: Control;
  71363. };
  71364. /** @hidden */
  71365. _shouldBlockPointer: boolean;
  71366. /** @hidden */
  71367. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71368. /** @hidden */
  71369. _linkedControls: Control[];
  71370. private _isFullscreen;
  71371. private _fullscreenViewport;
  71372. private _idealWidth;
  71373. private _idealHeight;
  71374. private _useSmallestIdeal;
  71375. private _renderAtIdealSize;
  71376. private _focusedControl;
  71377. private _blockNextFocusCheck;
  71378. private _renderScale;
  71379. private _rootElement;
  71380. private _cursorChanged;
  71381. private _defaultMousePointerId;
  71382. /** @hidden */
  71383. _numLayoutCalls: number;
  71384. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71385. get numLayoutCalls(): number;
  71386. /** @hidden */
  71387. _numRenderCalls: number;
  71388. /** Gets the number of render calls made the last time the ADT has been rendered */
  71389. get numRenderCalls(): number;
  71390. /**
  71391. * Define type to string to ensure compatibility across browsers
  71392. * Safari doesn't support DataTransfer constructor
  71393. */
  71394. private _clipboardData;
  71395. /**
  71396. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71397. */
  71398. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71399. /**
  71400. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71401. */
  71402. onControlPickedObservable: BABYLON.Observable<Control>;
  71403. /**
  71404. * BABYLON.Observable event triggered before layout is evaluated
  71405. */
  71406. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71407. /**
  71408. * BABYLON.Observable event triggered after the layout was evaluated
  71409. */
  71410. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71411. /**
  71412. * BABYLON.Observable event triggered before the texture is rendered
  71413. */
  71414. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71415. /**
  71416. * BABYLON.Observable event triggered after the texture was rendered
  71417. */
  71418. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71419. /**
  71420. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71421. */
  71422. premulAlpha: boolean;
  71423. /**
  71424. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71425. * Useful when you want more antialiasing
  71426. */
  71427. get renderScale(): number;
  71428. set renderScale(value: number);
  71429. /** Gets or sets the background color */
  71430. get background(): string;
  71431. set background(value: string);
  71432. /**
  71433. * Gets or sets the ideal width used to design controls.
  71434. * The GUI will then rescale everything accordingly
  71435. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71436. */
  71437. get idealWidth(): number;
  71438. set idealWidth(value: number);
  71439. /**
  71440. * Gets or sets the ideal height used to design controls.
  71441. * The GUI will then rescale everything accordingly
  71442. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71443. */
  71444. get idealHeight(): number;
  71445. set idealHeight(value: number);
  71446. /**
  71447. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71448. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71449. */
  71450. get useSmallestIdeal(): boolean;
  71451. set useSmallestIdeal(value: boolean);
  71452. /**
  71453. * Gets or sets a boolean indicating if adaptive scaling must be used
  71454. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71455. */
  71456. get renderAtIdealSize(): boolean;
  71457. set renderAtIdealSize(value: boolean);
  71458. /**
  71459. * Gets the ratio used when in "ideal mode"
  71460. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71461. * */
  71462. get idealRatio(): number;
  71463. /**
  71464. * Gets the underlying layer used to render the texture when in fullscreen mode
  71465. */
  71466. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71467. /**
  71468. * Gets the root container control
  71469. */
  71470. get rootContainer(): Container;
  71471. /**
  71472. * Returns an array containing the root container.
  71473. * This is mostly used to let the Inspector introspects the ADT
  71474. * @returns an array containing the rootContainer
  71475. */
  71476. getChildren(): Array<Container>;
  71477. /**
  71478. * Will return all controls that are inside this texture
  71479. * @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
  71480. * @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
  71481. * @return all child controls
  71482. */
  71483. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71484. /**
  71485. * Gets or sets the current focused control
  71486. */
  71487. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71488. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71489. /**
  71490. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71491. */
  71492. get isForeground(): boolean;
  71493. set isForeground(value: boolean);
  71494. /**
  71495. * Gets or set information about clipboardData
  71496. */
  71497. get clipboardData(): string;
  71498. set clipboardData(value: string);
  71499. /**
  71500. * Creates a new AdvancedDynamicTexture
  71501. * @param name defines the name of the texture
  71502. * @param width defines the width of the texture
  71503. * @param height defines the height of the texture
  71504. * @param scene defines the hosting scene
  71505. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71506. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71507. */
  71508. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71509. /**
  71510. * Get the current class name of the texture useful for serialization or dynamic coding.
  71511. * @returns "AdvancedDynamicTexture"
  71512. */
  71513. getClassName(): string;
  71514. /**
  71515. * Function used to execute a function on all controls
  71516. * @param func defines the function to execute
  71517. * @param container defines the container where controls belong. If null the root container will be used
  71518. */
  71519. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71520. private _useInvalidateRectOptimization;
  71521. /**
  71522. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71523. */
  71524. get useInvalidateRectOptimization(): boolean;
  71525. set useInvalidateRectOptimization(value: boolean);
  71526. private _invalidatedRectangle;
  71527. /**
  71528. * Invalidates a rectangle area on the gui texture
  71529. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71530. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71531. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71532. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71533. */
  71534. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71535. /**
  71536. * Marks the texture as dirty forcing a complete update
  71537. */
  71538. markAsDirty(): void;
  71539. /**
  71540. * Helper function used to create a new style
  71541. * @returns a new style
  71542. * @see http://doc.babylonjs.com/how_to/gui#styles
  71543. */
  71544. createStyle(): Style;
  71545. /**
  71546. * Adds a new control to the root container
  71547. * @param control defines the control to add
  71548. * @returns the current texture
  71549. */
  71550. addControl(control: Control): AdvancedDynamicTexture;
  71551. /**
  71552. * Removes a control from the root container
  71553. * @param control defines the control to remove
  71554. * @returns the current texture
  71555. */
  71556. removeControl(control: Control): AdvancedDynamicTexture;
  71557. /**
  71558. * Release all resources
  71559. */
  71560. dispose(): void;
  71561. private _onResize;
  71562. /** @hidden */
  71563. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71564. /**
  71565. * Get screen coordinates for a vector3
  71566. * @param position defines the position to project
  71567. * @param worldMatrix defines the world matrix to use
  71568. * @returns the projected position
  71569. */
  71570. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71571. private _checkUpdate;
  71572. private _clearMeasure;
  71573. private _render;
  71574. /** @hidden */
  71575. _changeCursor(cursor: string): void;
  71576. /** @hidden */
  71577. _registerLastControlDown(control: Control, pointerId: number): void;
  71578. private _doPicking;
  71579. /** @hidden */
  71580. _cleanControlAfterRemovalFromList(list: {
  71581. [pointerId: number]: Control;
  71582. }, control: Control): void;
  71583. /** @hidden */
  71584. _cleanControlAfterRemoval(control: Control): void;
  71585. /** Attach to all scene events required to support pointer events */
  71586. attach(): void;
  71587. /** @hidden */
  71588. private onClipboardCopy;
  71589. /** @hidden */
  71590. private onClipboardCut;
  71591. /** @hidden */
  71592. private onClipboardPaste;
  71593. /**
  71594. * Register the clipboard Events onto the canvas
  71595. */
  71596. registerClipboardEvents(): void;
  71597. /**
  71598. * Unregister the clipboard Events from the canvas
  71599. */
  71600. unRegisterClipboardEvents(): void;
  71601. /**
  71602. * Connect the texture to a hosting mesh to enable interactions
  71603. * @param mesh defines the mesh to attach to
  71604. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71605. */
  71606. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71607. /**
  71608. * Move the focus to a specific control
  71609. * @param control defines the control which will receive the focus
  71610. */
  71611. moveFocusToControl(control: IFocusableControl): void;
  71612. private _manageFocus;
  71613. private _attachToOnPointerOut;
  71614. /**
  71615. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71616. * @param mesh defines the mesh which will receive the texture
  71617. * @param width defines the texture width (1024 by default)
  71618. * @param height defines the texture height (1024 by default)
  71619. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71620. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71621. * @returns a new AdvancedDynamicTexture
  71622. */
  71623. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71624. /**
  71625. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71626. * In this mode the texture will rely on a layer for its rendering.
  71627. * This allows it to be treated like any other layer.
  71628. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71629. * LayerMask is set through advancedTexture.layer.layerMask
  71630. * @param name defines name for the texture
  71631. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71632. * @param scene defines the hsoting scene
  71633. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71634. * @returns a new AdvancedDynamicTexture
  71635. */
  71636. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71637. }
  71638. }
  71639. declare module BABYLON.GUI {
  71640. /**
  71641. * Root class used for all 2D controls
  71642. * @see http://doc.babylonjs.com/how_to/gui#controls
  71643. */
  71644. export class Control {
  71645. /** defines the name of the control */
  71646. name?: string | undefined;
  71647. /**
  71648. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71649. */
  71650. static AllowAlphaInheritance: boolean;
  71651. private _alpha;
  71652. private _alphaSet;
  71653. private _zIndex;
  71654. /** @hidden */
  71655. _host: AdvancedDynamicTexture;
  71656. /** Gets or sets the control parent */
  71657. parent: BABYLON.Nullable<Container>;
  71658. /** @hidden */
  71659. _currentMeasure: Measure;
  71660. private _fontFamily;
  71661. private _fontStyle;
  71662. private _fontWeight;
  71663. private _fontSize;
  71664. private _font;
  71665. /** @hidden */
  71666. _width: ValueAndUnit;
  71667. /** @hidden */
  71668. _height: ValueAndUnit;
  71669. /** @hidden */
  71670. protected _fontOffset: {
  71671. ascent: number;
  71672. height: number;
  71673. descent: number;
  71674. };
  71675. private _color;
  71676. private _style;
  71677. private _styleObserver;
  71678. /** @hidden */
  71679. protected _horizontalAlignment: number;
  71680. /** @hidden */
  71681. protected _verticalAlignment: number;
  71682. /** @hidden */
  71683. protected _isDirty: boolean;
  71684. /** @hidden */
  71685. protected _wasDirty: boolean;
  71686. /** @hidden */
  71687. _tempParentMeasure: Measure;
  71688. /** @hidden */
  71689. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71690. /** @hidden */
  71691. protected _cachedParentMeasure: Measure;
  71692. private _paddingLeft;
  71693. private _paddingRight;
  71694. private _paddingTop;
  71695. private _paddingBottom;
  71696. /** @hidden */
  71697. _left: ValueAndUnit;
  71698. /** @hidden */
  71699. _top: ValueAndUnit;
  71700. private _scaleX;
  71701. private _scaleY;
  71702. private _rotation;
  71703. private _transformCenterX;
  71704. private _transformCenterY;
  71705. /** @hidden */
  71706. _transformMatrix: Matrix2D;
  71707. /** @hidden */
  71708. protected _invertTransformMatrix: Matrix2D;
  71709. /** @hidden */
  71710. protected _transformedPosition: BABYLON.Vector2;
  71711. private _isMatrixDirty;
  71712. private _cachedOffsetX;
  71713. private _cachedOffsetY;
  71714. private _isVisible;
  71715. private _isHighlighted;
  71716. /** @hidden */
  71717. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71718. private _fontSet;
  71719. private _dummyVector2;
  71720. private _downCount;
  71721. private _enterCount;
  71722. private _doNotRender;
  71723. private _downPointerIds;
  71724. protected _isEnabled: boolean;
  71725. protected _disabledColor: string;
  71726. protected _disabledColorItem: string;
  71727. /** @hidden */
  71728. protected _rebuildLayout: boolean;
  71729. /** @hidden */
  71730. _customData: any;
  71731. /** @hidden */
  71732. _isClipped: boolean;
  71733. /** @hidden */
  71734. _automaticSize: boolean;
  71735. /** @hidden */
  71736. _tag: any;
  71737. /**
  71738. * 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
  71739. */
  71740. uniqueId: number;
  71741. /**
  71742. * Gets or sets an object used to store user defined information for the node
  71743. */
  71744. metadata: any;
  71745. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71746. isHitTestVisible: boolean;
  71747. /** Gets or sets a boolean indicating if the control can block pointer events */
  71748. isPointerBlocker: boolean;
  71749. /** Gets or sets a boolean indicating if the control can be focusable */
  71750. isFocusInvisible: boolean;
  71751. /**
  71752. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71753. * 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
  71754. */
  71755. clipChildren: boolean;
  71756. /**
  71757. * Gets or sets a boolean indicating that control content must be clipped
  71758. * 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
  71759. */
  71760. clipContent: boolean;
  71761. /**
  71762. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71763. */
  71764. useBitmapCache: boolean;
  71765. private _cacheData;
  71766. private _shadowOffsetX;
  71767. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71768. get shadowOffsetX(): number;
  71769. set shadowOffsetX(value: number);
  71770. private _shadowOffsetY;
  71771. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71772. get shadowOffsetY(): number;
  71773. set shadowOffsetY(value: number);
  71774. private _shadowBlur;
  71775. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71776. get shadowBlur(): number;
  71777. set shadowBlur(value: number);
  71778. private _shadowColor;
  71779. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71780. get shadowColor(): string;
  71781. set shadowColor(value: string);
  71782. /** Gets or sets the cursor to use when the control is hovered */
  71783. hoverCursor: string;
  71784. /** @hidden */
  71785. protected _linkOffsetX: ValueAndUnit;
  71786. /** @hidden */
  71787. protected _linkOffsetY: ValueAndUnit;
  71788. /** Gets the control type name */
  71789. get typeName(): string;
  71790. /**
  71791. * Get the current class name of the control.
  71792. * @returns current class name
  71793. */
  71794. getClassName(): string;
  71795. /**
  71796. * An event triggered when pointer wheel is scrolled
  71797. */
  71798. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71799. /**
  71800. * An event triggered when the pointer move over the control.
  71801. */
  71802. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71803. /**
  71804. * An event triggered when the pointer move out of the control.
  71805. */
  71806. onPointerOutObservable: BABYLON.Observable<Control>;
  71807. /**
  71808. * An event triggered when the pointer taps the control
  71809. */
  71810. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71811. /**
  71812. * An event triggered when pointer up
  71813. */
  71814. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71815. /**
  71816. * An event triggered when a control is clicked on
  71817. */
  71818. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71819. /**
  71820. * An event triggered when pointer enters the control
  71821. */
  71822. onPointerEnterObservable: BABYLON.Observable<Control>;
  71823. /**
  71824. * An event triggered when the control is marked as dirty
  71825. */
  71826. onDirtyObservable: BABYLON.Observable<Control>;
  71827. /**
  71828. * An event triggered before drawing the control
  71829. */
  71830. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71831. /**
  71832. * An event triggered after the control was drawn
  71833. */
  71834. onAfterDrawObservable: BABYLON.Observable<Control>;
  71835. /**
  71836. * Get the hosting AdvancedDynamicTexture
  71837. */
  71838. get host(): AdvancedDynamicTexture;
  71839. /** Gets or set information about font offsets (used to render and align text) */
  71840. get fontOffset(): {
  71841. ascent: number;
  71842. height: number;
  71843. descent: number;
  71844. };
  71845. set fontOffset(offset: {
  71846. ascent: number;
  71847. height: number;
  71848. descent: number;
  71849. });
  71850. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71851. get alpha(): number;
  71852. set alpha(value: number);
  71853. /**
  71854. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71855. */
  71856. get isHighlighted(): boolean;
  71857. set isHighlighted(value: boolean);
  71858. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71859. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71860. */
  71861. get scaleX(): number;
  71862. set scaleX(value: number);
  71863. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71864. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71865. */
  71866. get scaleY(): number;
  71867. set scaleY(value: number);
  71868. /** Gets or sets the rotation angle (0 by default)
  71869. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71870. */
  71871. get rotation(): number;
  71872. set rotation(value: number);
  71873. /** Gets or sets the transformation center on Y axis (0 by default)
  71874. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71875. */
  71876. get transformCenterY(): number;
  71877. set transformCenterY(value: number);
  71878. /** Gets or sets the transformation center on X axis (0 by default)
  71879. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71880. */
  71881. get transformCenterX(): number;
  71882. set transformCenterX(value: number);
  71883. /**
  71884. * Gets or sets the horizontal alignment
  71885. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71886. */
  71887. get horizontalAlignment(): number;
  71888. set horizontalAlignment(value: number);
  71889. /**
  71890. * Gets or sets the vertical alignment
  71891. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71892. */
  71893. get verticalAlignment(): number;
  71894. set verticalAlignment(value: number);
  71895. /**
  71896. * Gets or sets control width
  71897. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71898. */
  71899. get width(): string | number;
  71900. set width(value: string | number);
  71901. /**
  71902. * Gets or sets the control width in pixel
  71903. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71904. */
  71905. get widthInPixels(): number;
  71906. set widthInPixels(value: number);
  71907. /**
  71908. * Gets or sets control height
  71909. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71910. */
  71911. get height(): string | number;
  71912. set height(value: string | number);
  71913. /**
  71914. * Gets or sets control height in pixel
  71915. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71916. */
  71917. get heightInPixels(): number;
  71918. set heightInPixels(value: number);
  71919. /** Gets or set font family */
  71920. get fontFamily(): string;
  71921. set fontFamily(value: string);
  71922. /** Gets or sets font style */
  71923. get fontStyle(): string;
  71924. set fontStyle(value: string);
  71925. /** Gets or sets font weight */
  71926. get fontWeight(): string;
  71927. set fontWeight(value: string);
  71928. /**
  71929. * Gets or sets style
  71930. * @see http://doc.babylonjs.com/how_to/gui#styles
  71931. */
  71932. get style(): BABYLON.Nullable<Style>;
  71933. set style(value: BABYLON.Nullable<Style>);
  71934. /** @hidden */
  71935. get _isFontSizeInPercentage(): boolean;
  71936. /** Gets or sets font size in pixels */
  71937. get fontSizeInPixels(): number;
  71938. set fontSizeInPixels(value: number);
  71939. /** Gets or sets font size */
  71940. get fontSize(): string | number;
  71941. set fontSize(value: string | number);
  71942. /** Gets or sets foreground color */
  71943. get color(): string;
  71944. set color(value: string);
  71945. /** Gets or sets z index which is used to reorder controls on the z axis */
  71946. get zIndex(): number;
  71947. set zIndex(value: number);
  71948. /** Gets or sets a boolean indicating if the control can be rendered */
  71949. get notRenderable(): boolean;
  71950. set notRenderable(value: boolean);
  71951. /** Gets or sets a boolean indicating if the control is visible */
  71952. get isVisible(): boolean;
  71953. set isVisible(value: boolean);
  71954. /** Gets a boolean indicating that the control needs to update its rendering */
  71955. get isDirty(): boolean;
  71956. /**
  71957. * Gets the current linked mesh (or null if none)
  71958. */
  71959. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71960. /**
  71961. * Gets or sets a value indicating the padding to use on the left of the control
  71962. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71963. */
  71964. get paddingLeft(): string | number;
  71965. set paddingLeft(value: string | number);
  71966. /**
  71967. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71968. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71969. */
  71970. get paddingLeftInPixels(): number;
  71971. set paddingLeftInPixels(value: number);
  71972. /**
  71973. * Gets or sets a value indicating the padding to use on the right of the control
  71974. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71975. */
  71976. get paddingRight(): string | number;
  71977. set paddingRight(value: string | number);
  71978. /**
  71979. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71980. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71981. */
  71982. get paddingRightInPixels(): number;
  71983. set paddingRightInPixels(value: number);
  71984. /**
  71985. * Gets or sets a value indicating the padding to use on the top of the control
  71986. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71987. */
  71988. get paddingTop(): string | number;
  71989. set paddingTop(value: string | number);
  71990. /**
  71991. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71992. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71993. */
  71994. get paddingTopInPixels(): number;
  71995. set paddingTopInPixels(value: number);
  71996. /**
  71997. * Gets or sets a value indicating the padding to use on the bottom of the control
  71998. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71999. */
  72000. get paddingBottom(): string | number;
  72001. set paddingBottom(value: string | number);
  72002. /**
  72003. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72004. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72005. */
  72006. get paddingBottomInPixels(): number;
  72007. set paddingBottomInPixels(value: number);
  72008. /**
  72009. * Gets or sets a value indicating the left coordinate of the control
  72010. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72011. */
  72012. get left(): string | number;
  72013. set left(value: string | number);
  72014. /**
  72015. * Gets or sets a value indicating the left coordinate in pixels of the control
  72016. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72017. */
  72018. get leftInPixels(): number;
  72019. set leftInPixels(value: number);
  72020. /**
  72021. * Gets or sets a value indicating the top coordinate of the control
  72022. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72023. */
  72024. get top(): string | number;
  72025. set top(value: string | number);
  72026. /**
  72027. * Gets or sets a value indicating the top coordinate in pixels of the control
  72028. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72029. */
  72030. get topInPixels(): number;
  72031. set topInPixels(value: number);
  72032. /**
  72033. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72034. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72035. */
  72036. get linkOffsetX(): string | number;
  72037. set linkOffsetX(value: string | number);
  72038. /**
  72039. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72040. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72041. */
  72042. get linkOffsetXInPixels(): number;
  72043. set linkOffsetXInPixels(value: number);
  72044. /**
  72045. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72046. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72047. */
  72048. get linkOffsetY(): string | number;
  72049. set linkOffsetY(value: string | number);
  72050. /**
  72051. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72052. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72053. */
  72054. get linkOffsetYInPixels(): number;
  72055. set linkOffsetYInPixels(value: number);
  72056. /** Gets the center coordinate on X axis */
  72057. get centerX(): number;
  72058. /** Gets the center coordinate on Y axis */
  72059. get centerY(): number;
  72060. /** Gets or sets if control is Enabled*/
  72061. get isEnabled(): boolean;
  72062. set isEnabled(value: boolean);
  72063. /** Gets or sets background color of control if it's disabled*/
  72064. get disabledColor(): string;
  72065. set disabledColor(value: string);
  72066. /** Gets or sets front color of control if it's disabled*/
  72067. get disabledColorItem(): string;
  72068. set disabledColorItem(value: string);
  72069. /**
  72070. * Creates a new control
  72071. * @param name defines the name of the control
  72072. */
  72073. constructor(
  72074. /** defines the name of the control */
  72075. name?: string | undefined);
  72076. /** @hidden */
  72077. protected _getTypeName(): string;
  72078. /**
  72079. * Gets the first ascendant in the hierarchy of the given type
  72080. * @param className defines the required type
  72081. * @returns the ascendant or null if not found
  72082. */
  72083. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72084. /** @hidden */
  72085. _resetFontCache(): void;
  72086. /**
  72087. * Determines if a container is an ascendant of the current control
  72088. * @param container defines the container to look for
  72089. * @returns true if the container is one of the ascendant of the control
  72090. */
  72091. isAscendant(container: Control): boolean;
  72092. /**
  72093. * Gets coordinates in local control space
  72094. * @param globalCoordinates defines the coordinates to transform
  72095. * @returns the new coordinates in local space
  72096. */
  72097. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72098. /**
  72099. * Gets coordinates in local control space
  72100. * @param globalCoordinates defines the coordinates to transform
  72101. * @param result defines the target vector2 where to store the result
  72102. * @returns the current control
  72103. */
  72104. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72105. /**
  72106. * Gets coordinates in parent local control space
  72107. * @param globalCoordinates defines the coordinates to transform
  72108. * @returns the new coordinates in parent local space
  72109. */
  72110. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72111. /**
  72112. * Move the current control to a vector3 position projected onto the screen.
  72113. * @param position defines the target position
  72114. * @param scene defines the hosting scene
  72115. */
  72116. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72117. /**
  72118. * Will store all controls that have this control as ascendant in a given array
  72119. * @param results defines the array where to store the descendants
  72120. * @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
  72121. * @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
  72122. */
  72123. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72124. /**
  72125. * Will return all controls that have this control as ascendant
  72126. * @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
  72127. * @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
  72128. * @return all child controls
  72129. */
  72130. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72131. /**
  72132. * Link current control with a target mesh
  72133. * @param mesh defines the mesh to link with
  72134. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72135. */
  72136. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72137. /** @hidden */
  72138. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72139. /** @hidden */
  72140. _offsetLeft(offset: number): void;
  72141. /** @hidden */
  72142. _offsetTop(offset: number): void;
  72143. /** @hidden */
  72144. _markMatrixAsDirty(): void;
  72145. /** @hidden */
  72146. _flagDescendantsAsMatrixDirty(): void;
  72147. /** @hidden */
  72148. _intersectsRect(rect: Measure): boolean;
  72149. /** @hidden */
  72150. protected invalidateRect(): void;
  72151. /** @hidden */
  72152. _markAsDirty(force?: boolean): void;
  72153. /** @hidden */
  72154. _markAllAsDirty(): void;
  72155. /** @hidden */
  72156. _link(host: AdvancedDynamicTexture): void;
  72157. /** @hidden */
  72158. protected _transform(context?: CanvasRenderingContext2D): void;
  72159. /** @hidden */
  72160. _renderHighlight(context: CanvasRenderingContext2D): void;
  72161. /** @hidden */
  72162. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72163. /** @hidden */
  72164. protected _applyStates(context: CanvasRenderingContext2D): void;
  72165. /** @hidden */
  72166. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72167. /** @hidden */
  72168. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72169. protected _evaluateClippingState(parentMeasure: Measure): void;
  72170. /** @hidden */
  72171. _measure(): void;
  72172. /** @hidden */
  72173. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72174. /** @hidden */
  72175. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72176. /** @hidden */
  72177. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72178. /** @hidden */
  72179. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72180. private static _ClipMeasure;
  72181. private _tmpMeasureA;
  72182. private _clip;
  72183. /** @hidden */
  72184. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72185. /** @hidden */
  72186. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72187. /**
  72188. * Tests if a given coordinates belong to the current control
  72189. * @param x defines x coordinate to test
  72190. * @param y defines y coordinate to test
  72191. * @returns true if the coordinates are inside the control
  72192. */
  72193. contains(x: number, y: number): boolean;
  72194. /** @hidden */
  72195. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72196. /** @hidden */
  72197. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72198. /** @hidden */
  72199. _onPointerEnter(target: Control): boolean;
  72200. /** @hidden */
  72201. _onPointerOut(target: Control, force?: boolean): void;
  72202. /** @hidden */
  72203. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72204. /** @hidden */
  72205. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72206. /** @hidden */
  72207. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72208. /** @hidden */
  72209. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72210. /** @hidden */
  72211. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72212. private _prepareFont;
  72213. /** Releases associated resources */
  72214. dispose(): void;
  72215. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72216. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72217. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72218. private static _VERTICAL_ALIGNMENT_TOP;
  72219. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72220. private static _VERTICAL_ALIGNMENT_CENTER;
  72221. /** HORIZONTAL_ALIGNMENT_LEFT */
  72222. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72223. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72224. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72225. /** HORIZONTAL_ALIGNMENT_CENTER */
  72226. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72227. /** VERTICAL_ALIGNMENT_TOP */
  72228. static get VERTICAL_ALIGNMENT_TOP(): number;
  72229. /** VERTICAL_ALIGNMENT_BOTTOM */
  72230. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72231. /** VERTICAL_ALIGNMENT_CENTER */
  72232. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72233. private static _FontHeightSizes;
  72234. /** @hidden */
  72235. static _GetFontOffset(font: string): {
  72236. ascent: number;
  72237. height: number;
  72238. descent: number;
  72239. };
  72240. /**
  72241. * Creates a stack panel that can be used to render headers
  72242. * @param control defines the control to associate with the header
  72243. * @param text defines the text of the header
  72244. * @param size defines the size of the header
  72245. * @param options defines options used to configure the header
  72246. * @returns a new StackPanel
  72247. * @ignore
  72248. * @hidden
  72249. */
  72250. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72251. isHorizontal: boolean;
  72252. controlFirst: boolean;
  72253. }) => any;
  72254. /** @hidden */
  72255. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72256. }
  72257. }
  72258. declare module BABYLON.GUI {
  72259. /**
  72260. * Root class for 2D containers
  72261. * @see http://doc.babylonjs.com/how_to/gui#containers
  72262. */
  72263. export class Container extends Control {
  72264. name?: string | undefined;
  72265. /** @hidden */
  72266. _children: Control[];
  72267. /** @hidden */
  72268. protected _measureForChildren: Measure;
  72269. /** @hidden */
  72270. protected _background: string;
  72271. /** @hidden */
  72272. protected _adaptWidthToChildren: boolean;
  72273. /** @hidden */
  72274. protected _adaptHeightToChildren: boolean;
  72275. /**
  72276. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72277. */
  72278. logLayoutCycleErrors: boolean;
  72279. /**
  72280. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72281. */
  72282. maxLayoutCycle: number;
  72283. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72284. get adaptHeightToChildren(): boolean;
  72285. set adaptHeightToChildren(value: boolean);
  72286. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72287. get adaptWidthToChildren(): boolean;
  72288. set adaptWidthToChildren(value: boolean);
  72289. /** Gets or sets background color */
  72290. get background(): string;
  72291. set background(value: string);
  72292. /** Gets the list of children */
  72293. get children(): Control[];
  72294. /**
  72295. * Creates a new Container
  72296. * @param name defines the name of the container
  72297. */
  72298. constructor(name?: string | undefined);
  72299. protected _getTypeName(): string;
  72300. _flagDescendantsAsMatrixDirty(): void;
  72301. /**
  72302. * Gets a child using its name
  72303. * @param name defines the child name to look for
  72304. * @returns the child control if found
  72305. */
  72306. getChildByName(name: string): BABYLON.Nullable<Control>;
  72307. /**
  72308. * Gets a child using its type and its name
  72309. * @param name defines the child name to look for
  72310. * @param type defines the child type to look for
  72311. * @returns the child control if found
  72312. */
  72313. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72314. /**
  72315. * Search for a specific control in children
  72316. * @param control defines the control to look for
  72317. * @returns true if the control is in child list
  72318. */
  72319. containsControl(control: Control): boolean;
  72320. /**
  72321. * Adds a new control to the current container
  72322. * @param control defines the control to add
  72323. * @returns the current container
  72324. */
  72325. addControl(control: BABYLON.Nullable<Control>): Container;
  72326. /**
  72327. * Removes all controls from the current container
  72328. * @returns the current container
  72329. */
  72330. clearControls(): Container;
  72331. /**
  72332. * Removes a control from the current container
  72333. * @param control defines the control to remove
  72334. * @returns the current container
  72335. */
  72336. removeControl(control: Control): Container;
  72337. /** @hidden */
  72338. _reOrderControl(control: Control): void;
  72339. /** @hidden */
  72340. _offsetLeft(offset: number): void;
  72341. /** @hidden */
  72342. _offsetTop(offset: number): void;
  72343. /** @hidden */
  72344. _markAllAsDirty(): void;
  72345. /** @hidden */
  72346. protected _localDraw(context: CanvasRenderingContext2D): void;
  72347. /** @hidden */
  72348. _link(host: AdvancedDynamicTexture): void;
  72349. /** @hidden */
  72350. protected _beforeLayout(): void;
  72351. /** @hidden */
  72352. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72353. /** @hidden */
  72354. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72355. protected _postMeasure(): void;
  72356. /** @hidden */
  72357. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72358. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72359. /** @hidden */
  72360. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72361. /** @hidden */
  72362. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72363. /** Releases associated resources */
  72364. dispose(): void;
  72365. }
  72366. }
  72367. declare module BABYLON.GUI {
  72368. /** Class used to create rectangle container */
  72369. export class Rectangle extends Container {
  72370. name?: string | undefined;
  72371. private _thickness;
  72372. private _cornerRadius;
  72373. /** Gets or sets border thickness */
  72374. get thickness(): number;
  72375. set thickness(value: number);
  72376. /** Gets or sets the corner radius angle */
  72377. get cornerRadius(): number;
  72378. set cornerRadius(value: number);
  72379. /**
  72380. * Creates a new Rectangle
  72381. * @param name defines the control name
  72382. */
  72383. constructor(name?: string | undefined);
  72384. protected _getTypeName(): string;
  72385. protected _localDraw(context: CanvasRenderingContext2D): void;
  72386. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72387. private _drawRoundedRect;
  72388. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72389. }
  72390. }
  72391. declare module BABYLON.GUI {
  72392. /**
  72393. * Enum that determines the text-wrapping mode to use.
  72394. */
  72395. export enum TextWrapping {
  72396. /**
  72397. * Clip the text when it's larger than Control.width; this is the default mode.
  72398. */
  72399. Clip = 0,
  72400. /**
  72401. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72402. */
  72403. WordWrap = 1,
  72404. /**
  72405. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72406. */
  72407. Ellipsis = 2
  72408. }
  72409. /**
  72410. * Class used to create text block control
  72411. */
  72412. export class TextBlock extends Control {
  72413. /**
  72414. * Defines the name of the control
  72415. */
  72416. name?: string | undefined;
  72417. private _text;
  72418. private _textWrapping;
  72419. private _textHorizontalAlignment;
  72420. private _textVerticalAlignment;
  72421. private _lines;
  72422. private _resizeToFit;
  72423. private _lineSpacing;
  72424. private _outlineWidth;
  72425. private _outlineColor;
  72426. /**
  72427. * An event triggered after the text is changed
  72428. */
  72429. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72430. /**
  72431. * An event triggered after the text was broken up into lines
  72432. */
  72433. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72434. /**
  72435. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72436. */
  72437. get lines(): any[];
  72438. /**
  72439. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72440. */
  72441. get resizeToFit(): boolean;
  72442. /**
  72443. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72444. */
  72445. set resizeToFit(value: boolean);
  72446. /**
  72447. * Gets or sets a boolean indicating if text must be wrapped
  72448. */
  72449. get textWrapping(): TextWrapping | boolean;
  72450. /**
  72451. * Gets or sets a boolean indicating if text must be wrapped
  72452. */
  72453. set textWrapping(value: TextWrapping | boolean);
  72454. /**
  72455. * Gets or sets text to display
  72456. */
  72457. get text(): string;
  72458. /**
  72459. * Gets or sets text to display
  72460. */
  72461. set text(value: string);
  72462. /**
  72463. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72464. */
  72465. get textHorizontalAlignment(): number;
  72466. /**
  72467. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72468. */
  72469. set textHorizontalAlignment(value: number);
  72470. /**
  72471. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72472. */
  72473. get textVerticalAlignment(): number;
  72474. /**
  72475. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72476. */
  72477. set textVerticalAlignment(value: number);
  72478. /**
  72479. * Gets or sets line spacing value
  72480. */
  72481. set lineSpacing(value: string | number);
  72482. /**
  72483. * Gets or sets line spacing value
  72484. */
  72485. get lineSpacing(): string | number;
  72486. /**
  72487. * Gets or sets outlineWidth of the text to display
  72488. */
  72489. get outlineWidth(): number;
  72490. /**
  72491. * Gets or sets outlineWidth of the text to display
  72492. */
  72493. set outlineWidth(value: number);
  72494. /**
  72495. * Gets or sets outlineColor of the text to display
  72496. */
  72497. get outlineColor(): string;
  72498. /**
  72499. * Gets or sets outlineColor of the text to display
  72500. */
  72501. set outlineColor(value: string);
  72502. /**
  72503. * Creates a new TextBlock object
  72504. * @param name defines the name of the control
  72505. * @param text defines the text to display (emptry string by default)
  72506. */
  72507. constructor(
  72508. /**
  72509. * Defines the name of the control
  72510. */
  72511. name?: string | undefined, text?: string);
  72512. protected _getTypeName(): string;
  72513. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72514. private _drawText;
  72515. /** @hidden */
  72516. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72517. protected _applyStates(context: CanvasRenderingContext2D): void;
  72518. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72519. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72520. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72521. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72522. protected _renderLines(context: CanvasRenderingContext2D): void;
  72523. /**
  72524. * Given a width constraint applied on the text block, find the expected height
  72525. * @returns expected height
  72526. */
  72527. computeExpectedHeight(): number;
  72528. dispose(): void;
  72529. }
  72530. }
  72531. declare module BABYLON.GUI {
  72532. /**
  72533. * Class used to create 2D images
  72534. */
  72535. export class Image extends Control {
  72536. name?: string | undefined;
  72537. private _workingCanvas;
  72538. private _domImage;
  72539. private _imageWidth;
  72540. private _imageHeight;
  72541. private _loaded;
  72542. private _stretch;
  72543. private _source;
  72544. private _autoScale;
  72545. private _sourceLeft;
  72546. private _sourceTop;
  72547. private _sourceWidth;
  72548. private _sourceHeight;
  72549. private _svgAttributesComputationCompleted;
  72550. private _isSVG;
  72551. private _cellWidth;
  72552. private _cellHeight;
  72553. private _cellId;
  72554. private _populateNinePatchSlicesFromImage;
  72555. private _sliceLeft;
  72556. private _sliceRight;
  72557. private _sliceTop;
  72558. private _sliceBottom;
  72559. private _detectPointerOnOpaqueOnly;
  72560. /**
  72561. * BABYLON.Observable notified when the content is loaded
  72562. */
  72563. onImageLoadedObservable: BABYLON.Observable<Image>;
  72564. /**
  72565. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72566. */
  72567. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72568. /**
  72569. * Gets a boolean indicating that the content is loaded
  72570. */
  72571. get isLoaded(): boolean;
  72572. /**
  72573. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72574. */
  72575. get populateNinePatchSlicesFromImage(): boolean;
  72576. set populateNinePatchSlicesFromImage(value: boolean);
  72577. /**
  72578. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72579. * Beware using this as this will comsume more memory as the image has to be stored twice
  72580. */
  72581. get detectPointerOnOpaqueOnly(): boolean;
  72582. set detectPointerOnOpaqueOnly(value: boolean);
  72583. /**
  72584. * Gets or sets the left value for slicing (9-patch)
  72585. */
  72586. get sliceLeft(): number;
  72587. set sliceLeft(value: number);
  72588. /**
  72589. * Gets or sets the right value for slicing (9-patch)
  72590. */
  72591. get sliceRight(): number;
  72592. set sliceRight(value: number);
  72593. /**
  72594. * Gets or sets the top value for slicing (9-patch)
  72595. */
  72596. get sliceTop(): number;
  72597. set sliceTop(value: number);
  72598. /**
  72599. * Gets or sets the bottom value for slicing (9-patch)
  72600. */
  72601. get sliceBottom(): number;
  72602. set sliceBottom(value: number);
  72603. /**
  72604. * Gets or sets the left coordinate in the source image
  72605. */
  72606. get sourceLeft(): number;
  72607. set sourceLeft(value: number);
  72608. /**
  72609. * Gets or sets the top coordinate in the source image
  72610. */
  72611. get sourceTop(): number;
  72612. set sourceTop(value: number);
  72613. /**
  72614. * Gets or sets the width to capture in the source image
  72615. */
  72616. get sourceWidth(): number;
  72617. set sourceWidth(value: number);
  72618. /**
  72619. * Gets or sets the height to capture in the source image
  72620. */
  72621. get sourceHeight(): number;
  72622. set sourceHeight(value: number);
  72623. /** Indicates if the format of the image is SVG */
  72624. get isSVG(): boolean;
  72625. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72626. get svgAttributesComputationCompleted(): boolean;
  72627. /**
  72628. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72629. * @see http://doc.babylonjs.com/how_to/gui#image
  72630. */
  72631. get autoScale(): boolean;
  72632. set autoScale(value: boolean);
  72633. /** Gets or sets the streching mode used by the image */
  72634. get stretch(): number;
  72635. set stretch(value: number);
  72636. /** @hidden */
  72637. _rotate90(n: number, preserveProperties?: boolean): Image;
  72638. private _handleRotationForSVGImage;
  72639. private _rotate90SourceProperties;
  72640. /**
  72641. * Gets or sets the internal DOM image used to render the control
  72642. */
  72643. set domImage(value: HTMLImageElement);
  72644. get domImage(): HTMLImageElement;
  72645. private _onImageLoaded;
  72646. private _extractNinePatchSliceDataFromImage;
  72647. /**
  72648. * Gets or sets image source url
  72649. */
  72650. set source(value: BABYLON.Nullable<string>);
  72651. /**
  72652. * Checks for svg document with icon id present
  72653. */
  72654. private _svgCheck;
  72655. /**
  72656. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72657. * given external svg file and icon id
  72658. */
  72659. private _getSVGAttribs;
  72660. /**
  72661. * Gets or sets the cell width to use when animation sheet is enabled
  72662. * @see http://doc.babylonjs.com/how_to/gui#image
  72663. */
  72664. get cellWidth(): number;
  72665. set cellWidth(value: number);
  72666. /**
  72667. * Gets or sets the cell height to use when animation sheet is enabled
  72668. * @see http://doc.babylonjs.com/how_to/gui#image
  72669. */
  72670. get cellHeight(): number;
  72671. set cellHeight(value: number);
  72672. /**
  72673. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72674. * @see http://doc.babylonjs.com/how_to/gui#image
  72675. */
  72676. get cellId(): number;
  72677. set cellId(value: number);
  72678. /**
  72679. * Creates a new Image
  72680. * @param name defines the control name
  72681. * @param url defines the image url
  72682. */
  72683. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72684. /**
  72685. * Tests if a given coordinates belong to the current control
  72686. * @param x defines x coordinate to test
  72687. * @param y defines y coordinate to test
  72688. * @returns true if the coordinates are inside the control
  72689. */
  72690. contains(x: number, y: number): boolean;
  72691. protected _getTypeName(): string;
  72692. /** Force the control to synchronize with its content */
  72693. synchronizeSizeWithContent(): void;
  72694. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72695. private _prepareWorkingCanvasForOpaqueDetection;
  72696. private _drawImage;
  72697. _draw(context: CanvasRenderingContext2D): void;
  72698. private _renderCornerPatch;
  72699. private _renderNinePatch;
  72700. dispose(): void;
  72701. /** STRETCH_NONE */
  72702. static readonly STRETCH_NONE: number;
  72703. /** STRETCH_FILL */
  72704. static readonly STRETCH_FILL: number;
  72705. /** STRETCH_UNIFORM */
  72706. static readonly STRETCH_UNIFORM: number;
  72707. /** STRETCH_EXTEND */
  72708. static readonly STRETCH_EXTEND: number;
  72709. /** NINE_PATCH */
  72710. static readonly STRETCH_NINE_PATCH: number;
  72711. }
  72712. }
  72713. declare module BABYLON.GUI {
  72714. /**
  72715. * Class used to create 2D buttons
  72716. */
  72717. export class Button extends Rectangle {
  72718. name?: string | undefined;
  72719. /**
  72720. * Function called to generate a pointer enter animation
  72721. */
  72722. pointerEnterAnimation: () => void;
  72723. /**
  72724. * Function called to generate a pointer out animation
  72725. */
  72726. pointerOutAnimation: () => void;
  72727. /**
  72728. * Function called to generate a pointer down animation
  72729. */
  72730. pointerDownAnimation: () => void;
  72731. /**
  72732. * Function called to generate a pointer up animation
  72733. */
  72734. pointerUpAnimation: () => void;
  72735. /**
  72736. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72737. */
  72738. delegatePickingToChildren: boolean;
  72739. private _image;
  72740. /**
  72741. * Returns the image part of the button (if any)
  72742. */
  72743. get image(): BABYLON.Nullable<Image>;
  72744. private _textBlock;
  72745. /**
  72746. * Returns the image part of the button (if any)
  72747. */
  72748. get textBlock(): BABYLON.Nullable<TextBlock>;
  72749. /**
  72750. * Creates a new Button
  72751. * @param name defines the name of the button
  72752. */
  72753. constructor(name?: string | undefined);
  72754. protected _getTypeName(): string;
  72755. /** @hidden */
  72756. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72757. /** @hidden */
  72758. _onPointerEnter(target: Control): boolean;
  72759. /** @hidden */
  72760. _onPointerOut(target: Control, force?: boolean): void;
  72761. /** @hidden */
  72762. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72763. /** @hidden */
  72764. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72765. /**
  72766. * Creates a new button made with an image and a text
  72767. * @param name defines the name of the button
  72768. * @param text defines the text of the button
  72769. * @param imageUrl defines the url of the image
  72770. * @returns a new Button
  72771. */
  72772. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72773. /**
  72774. * Creates a new button made with an image
  72775. * @param name defines the name of the button
  72776. * @param imageUrl defines the url of the image
  72777. * @returns a new Button
  72778. */
  72779. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72780. /**
  72781. * Creates a new button made with a text
  72782. * @param name defines the name of the button
  72783. * @param text defines the text of the button
  72784. * @returns a new Button
  72785. */
  72786. static CreateSimpleButton(name: string, text: string): Button;
  72787. /**
  72788. * Creates a new button made with an image and a centered text
  72789. * @param name defines the name of the button
  72790. * @param text defines the text of the button
  72791. * @param imageUrl defines the url of the image
  72792. * @returns a new Button
  72793. */
  72794. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72795. }
  72796. }
  72797. declare module BABYLON.GUI {
  72798. /**
  72799. * Class used to create a 2D stack panel container
  72800. */
  72801. export class StackPanel extends Container {
  72802. name?: string | undefined;
  72803. private _isVertical;
  72804. private _manualWidth;
  72805. private _manualHeight;
  72806. private _doNotTrackManualChanges;
  72807. /**
  72808. * Gets or sets a boolean indicating that layou warnings should be ignored
  72809. */
  72810. ignoreLayoutWarnings: boolean;
  72811. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72812. get isVertical(): boolean;
  72813. set isVertical(value: boolean);
  72814. /**
  72815. * Gets or sets panel width.
  72816. * This value should not be set when in horizontal mode as it will be computed automatically
  72817. */
  72818. set width(value: string | number);
  72819. get width(): string | number;
  72820. /**
  72821. * Gets or sets panel height.
  72822. * This value should not be set when in vertical mode as it will be computed automatically
  72823. */
  72824. set height(value: string | number);
  72825. get height(): string | number;
  72826. /**
  72827. * Creates a new StackPanel
  72828. * @param name defines control name
  72829. */
  72830. constructor(name?: string | undefined);
  72831. protected _getTypeName(): string;
  72832. /** @hidden */
  72833. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72834. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72835. protected _postMeasure(): void;
  72836. }
  72837. }
  72838. declare module BABYLON.GUI {
  72839. /**
  72840. * Class used to represent a 2D checkbox
  72841. */
  72842. export class Checkbox extends Control {
  72843. name?: string | undefined;
  72844. private _isChecked;
  72845. private _background;
  72846. private _checkSizeRatio;
  72847. private _thickness;
  72848. /** Gets or sets border thickness */
  72849. get thickness(): number;
  72850. set thickness(value: number);
  72851. /**
  72852. * BABYLON.Observable raised when isChecked property changes
  72853. */
  72854. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72855. /** Gets or sets a value indicating the ratio between overall size and check size */
  72856. get checkSizeRatio(): number;
  72857. set checkSizeRatio(value: number);
  72858. /** Gets or sets background color */
  72859. get background(): string;
  72860. set background(value: string);
  72861. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72862. get isChecked(): boolean;
  72863. set isChecked(value: boolean);
  72864. /**
  72865. * Creates a new CheckBox
  72866. * @param name defines the control name
  72867. */
  72868. constructor(name?: string | undefined);
  72869. protected _getTypeName(): string;
  72870. /** @hidden */
  72871. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72872. /** @hidden */
  72873. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72874. /**
  72875. * Utility function to easily create a checkbox with a header
  72876. * @param title defines the label to use for the header
  72877. * @param onValueChanged defines the callback to call when value changes
  72878. * @returns a StackPanel containing the checkbox and a textBlock
  72879. */
  72880. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72881. }
  72882. }
  72883. declare module BABYLON.GUI {
  72884. /**
  72885. * Class used to store key control properties
  72886. */
  72887. export class KeyPropertySet {
  72888. /** Width */
  72889. width?: string;
  72890. /** Height */
  72891. height?: string;
  72892. /** Left padding */
  72893. paddingLeft?: string;
  72894. /** Right padding */
  72895. paddingRight?: string;
  72896. /** Top padding */
  72897. paddingTop?: string;
  72898. /** Bottom padding */
  72899. paddingBottom?: string;
  72900. /** Foreground color */
  72901. color?: string;
  72902. /** Background color */
  72903. background?: string;
  72904. }
  72905. /**
  72906. * Class used to create virtual keyboard
  72907. */
  72908. export class VirtualKeyboard extends StackPanel {
  72909. /** BABYLON.Observable raised when a key is pressed */
  72910. onKeyPressObservable: BABYLON.Observable<string>;
  72911. /** Gets or sets default key button width */
  72912. defaultButtonWidth: string;
  72913. /** Gets or sets default key button height */
  72914. defaultButtonHeight: string;
  72915. /** Gets or sets default key button left padding */
  72916. defaultButtonPaddingLeft: string;
  72917. /** Gets or sets default key button right padding */
  72918. defaultButtonPaddingRight: string;
  72919. /** Gets or sets default key button top padding */
  72920. defaultButtonPaddingTop: string;
  72921. /** Gets or sets default key button bottom padding */
  72922. defaultButtonPaddingBottom: string;
  72923. /** Gets or sets default key button foreground color */
  72924. defaultButtonColor: string;
  72925. /** Gets or sets default key button background color */
  72926. defaultButtonBackground: string;
  72927. /** Gets or sets shift button foreground color */
  72928. shiftButtonColor: string;
  72929. /** Gets or sets shift button thickness*/
  72930. selectedShiftThickness: number;
  72931. /** Gets shift key state */
  72932. shiftState: number;
  72933. protected _getTypeName(): string;
  72934. private _createKey;
  72935. /**
  72936. * Adds a new row of keys
  72937. * @param keys defines the list of keys to add
  72938. * @param propertySets defines the associated property sets
  72939. */
  72940. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72941. /**
  72942. * Set the shift key to a specific state
  72943. * @param shiftState defines the new shift state
  72944. */
  72945. applyShiftState(shiftState: number): void;
  72946. private _currentlyConnectedInputText;
  72947. private _connectedInputTexts;
  72948. private _onKeyPressObserver;
  72949. /** Gets the input text control currently attached to the keyboard */
  72950. get connectedInputText(): BABYLON.Nullable<InputText>;
  72951. /**
  72952. * Connects the keyboard with an input text control
  72953. *
  72954. * @param input defines the target control
  72955. */
  72956. connect(input: InputText): void;
  72957. /**
  72958. * Disconnects the keyboard from connected InputText controls
  72959. *
  72960. * @param input optionally defines a target control, otherwise all are disconnected
  72961. */
  72962. disconnect(input?: InputText): void;
  72963. private _removeConnectedInputObservables;
  72964. /**
  72965. * Release all resources
  72966. */
  72967. dispose(): void;
  72968. /**
  72969. * Creates a new keyboard using a default layout
  72970. *
  72971. * @param name defines control name
  72972. * @returns a new VirtualKeyboard
  72973. */
  72974. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72975. }
  72976. }
  72977. declare module BABYLON.GUI {
  72978. /**
  72979. * Class used to create input text control
  72980. */
  72981. export class InputText extends Control implements IFocusableControl {
  72982. name?: string | undefined;
  72983. private _text;
  72984. private _placeholderText;
  72985. private _background;
  72986. private _focusedBackground;
  72987. private _focusedColor;
  72988. private _placeholderColor;
  72989. private _thickness;
  72990. private _margin;
  72991. private _autoStretchWidth;
  72992. private _maxWidth;
  72993. private _isFocused;
  72994. private _blinkTimeout;
  72995. private _blinkIsEven;
  72996. private _cursorOffset;
  72997. private _scrollLeft;
  72998. private _textWidth;
  72999. private _clickedCoordinate;
  73000. private _deadKey;
  73001. private _addKey;
  73002. private _currentKey;
  73003. private _isTextHighlightOn;
  73004. private _textHighlightColor;
  73005. private _highligherOpacity;
  73006. private _highlightedText;
  73007. private _startHighlightIndex;
  73008. private _endHighlightIndex;
  73009. private _cursorIndex;
  73010. private _onFocusSelectAll;
  73011. private _isPointerDown;
  73012. private _onClipboardObserver;
  73013. private _onPointerDblTapObserver;
  73014. /** @hidden */
  73015. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73016. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73017. promptMessage: string;
  73018. /** Force disable prompt on mobile device */
  73019. disableMobilePrompt: boolean;
  73020. /** BABYLON.Observable raised when the text changes */
  73021. onTextChangedObservable: BABYLON.Observable<InputText>;
  73022. /** BABYLON.Observable raised just before an entered character is to be added */
  73023. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73024. /** BABYLON.Observable raised when the control gets the focus */
  73025. onFocusObservable: BABYLON.Observable<InputText>;
  73026. /** BABYLON.Observable raised when the control loses the focus */
  73027. onBlurObservable: BABYLON.Observable<InputText>;
  73028. /**Observable raised when the text is highlighted */
  73029. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73030. /**Observable raised when copy event is triggered */
  73031. onTextCopyObservable: BABYLON.Observable<InputText>;
  73032. /** BABYLON.Observable raised when cut event is triggered */
  73033. onTextCutObservable: BABYLON.Observable<InputText>;
  73034. /** BABYLON.Observable raised when paste event is triggered */
  73035. onTextPasteObservable: BABYLON.Observable<InputText>;
  73036. /** BABYLON.Observable raised when a key event was processed */
  73037. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73038. /** Gets or sets the maximum width allowed by the control */
  73039. get maxWidth(): string | number;
  73040. /** Gets the maximum width allowed by the control in pixels */
  73041. get maxWidthInPixels(): number;
  73042. set maxWidth(value: string | number);
  73043. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73044. get highligherOpacity(): number;
  73045. set highligherOpacity(value: number);
  73046. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73047. get onFocusSelectAll(): boolean;
  73048. set onFocusSelectAll(value: boolean);
  73049. /** Gets or sets the text hightlight color */
  73050. get textHighlightColor(): string;
  73051. set textHighlightColor(value: string);
  73052. /** Gets or sets control margin */
  73053. get margin(): string;
  73054. /** Gets control margin in pixels */
  73055. get marginInPixels(): number;
  73056. set margin(value: string);
  73057. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73058. get autoStretchWidth(): boolean;
  73059. set autoStretchWidth(value: boolean);
  73060. /** Gets or sets border thickness */
  73061. get thickness(): number;
  73062. set thickness(value: number);
  73063. /** Gets or sets the background color when focused */
  73064. get focusedBackground(): string;
  73065. set focusedBackground(value: string);
  73066. /** Gets or sets the background color when focused */
  73067. get focusedColor(): string;
  73068. set focusedColor(value: string);
  73069. /** Gets or sets the background color */
  73070. get background(): string;
  73071. set background(value: string);
  73072. /** Gets or sets the placeholder color */
  73073. get placeholderColor(): string;
  73074. set placeholderColor(value: string);
  73075. /** Gets or sets the text displayed when the control is empty */
  73076. get placeholderText(): string;
  73077. set placeholderText(value: string);
  73078. /** Gets or sets the dead key flag */
  73079. get deadKey(): boolean;
  73080. set deadKey(flag: boolean);
  73081. /** Gets or sets the highlight text */
  73082. get highlightedText(): string;
  73083. set highlightedText(text: string);
  73084. /** Gets or sets if the current key should be added */
  73085. get addKey(): boolean;
  73086. set addKey(flag: boolean);
  73087. /** Gets or sets the value of the current key being entered */
  73088. get currentKey(): string;
  73089. set currentKey(key: string);
  73090. /** Gets or sets the text displayed in the control */
  73091. get text(): string;
  73092. set text(value: string);
  73093. /** Gets or sets control width */
  73094. get width(): string | number;
  73095. set width(value: string | number);
  73096. /**
  73097. * Creates a new InputText
  73098. * @param name defines the control name
  73099. * @param text defines the text of the control
  73100. */
  73101. constructor(name?: string | undefined, text?: string);
  73102. /** @hidden */
  73103. onBlur(): void;
  73104. /** @hidden */
  73105. onFocus(): void;
  73106. protected _getTypeName(): string;
  73107. /**
  73108. * Function called to get the list of controls that should not steal the focus from this control
  73109. * @returns an array of controls
  73110. */
  73111. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73112. /** @hidden */
  73113. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73114. /** @hidden */
  73115. private _updateValueFromCursorIndex;
  73116. /** @hidden */
  73117. private _processDblClick;
  73118. /** @hidden */
  73119. private _selectAllText;
  73120. /**
  73121. * Handles the keyboard event
  73122. * @param evt Defines the KeyboardEvent
  73123. */
  73124. processKeyboard(evt: KeyboardEvent): void;
  73125. /** @hidden */
  73126. private _onCopyText;
  73127. /** @hidden */
  73128. private _onCutText;
  73129. /** @hidden */
  73130. private _onPasteText;
  73131. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73132. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73133. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73134. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73135. protected _beforeRenderText(text: string): string;
  73136. dispose(): void;
  73137. }
  73138. }
  73139. declare module BABYLON.GUI {
  73140. /**
  73141. * Class used to create a 2D grid container
  73142. */
  73143. export class Grid extends Container {
  73144. name?: string | undefined;
  73145. private _rowDefinitions;
  73146. private _columnDefinitions;
  73147. private _cells;
  73148. private _childControls;
  73149. /**
  73150. * Gets the number of columns
  73151. */
  73152. get columnCount(): number;
  73153. /**
  73154. * Gets the number of rows
  73155. */
  73156. get rowCount(): number;
  73157. /** Gets the list of children */
  73158. get children(): Control[];
  73159. /** Gets the list of cells (e.g. the containers) */
  73160. get cells(): {
  73161. [key: string]: Container;
  73162. };
  73163. /**
  73164. * Gets the definition of a specific row
  73165. * @param index defines the index of the row
  73166. * @returns the row definition
  73167. */
  73168. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73169. /**
  73170. * Gets the definition of a specific column
  73171. * @param index defines the index of the column
  73172. * @returns the column definition
  73173. */
  73174. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73175. /**
  73176. * Adds a new row to the grid
  73177. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73178. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73179. * @returns the current grid
  73180. */
  73181. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73182. /**
  73183. * Adds a new column to the grid
  73184. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73185. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73186. * @returns the current grid
  73187. */
  73188. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73189. /**
  73190. * Update a row definition
  73191. * @param index defines the index of the row to update
  73192. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73193. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73194. * @returns the current grid
  73195. */
  73196. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73197. /**
  73198. * Update a column definition
  73199. * @param index defines the index of the column to update
  73200. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73201. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73202. * @returns the current grid
  73203. */
  73204. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73205. /**
  73206. * Gets the list of children stored in a specific cell
  73207. * @param row defines the row to check
  73208. * @param column defines the column to check
  73209. * @returns the list of controls
  73210. */
  73211. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73212. /**
  73213. * Gets a string representing the child cell info (row x column)
  73214. * @param child defines the control to get info from
  73215. * @returns a string containing the child cell info (row x column)
  73216. */
  73217. getChildCellInfo(child: Control): string;
  73218. private _removeCell;
  73219. private _offsetCell;
  73220. /**
  73221. * Remove a column definition at specified index
  73222. * @param index defines the index of the column to remove
  73223. * @returns the current grid
  73224. */
  73225. removeColumnDefinition(index: number): Grid;
  73226. /**
  73227. * Remove a row definition at specified index
  73228. * @param index defines the index of the row to remove
  73229. * @returns the current grid
  73230. */
  73231. removeRowDefinition(index: number): Grid;
  73232. /**
  73233. * Adds a new control to the current grid
  73234. * @param control defines the control to add
  73235. * @param row defines the row where to add the control (0 by default)
  73236. * @param column defines the column where to add the control (0 by default)
  73237. * @returns the current grid
  73238. */
  73239. addControl(control: Control, row?: number, column?: number): Grid;
  73240. /**
  73241. * Removes a control from the current container
  73242. * @param control defines the control to remove
  73243. * @returns the current container
  73244. */
  73245. removeControl(control: Control): Container;
  73246. /**
  73247. * Creates a new Grid
  73248. * @param name defines control name
  73249. */
  73250. constructor(name?: string | undefined);
  73251. protected _getTypeName(): string;
  73252. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73253. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73254. _flagDescendantsAsMatrixDirty(): void;
  73255. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73256. /** Releases associated resources */
  73257. dispose(): void;
  73258. }
  73259. }
  73260. declare module BABYLON.GUI {
  73261. /** Class used to create color pickers */
  73262. export class ColorPicker extends Control {
  73263. name?: string | undefined;
  73264. private static _Epsilon;
  73265. private _colorWheelCanvas;
  73266. private _value;
  73267. private _tmpColor;
  73268. private _pointerStartedOnSquare;
  73269. private _pointerStartedOnWheel;
  73270. private _squareLeft;
  73271. private _squareTop;
  73272. private _squareSize;
  73273. private _h;
  73274. private _s;
  73275. private _v;
  73276. private _lastPointerDownID;
  73277. /**
  73278. * BABYLON.Observable raised when the value changes
  73279. */
  73280. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73281. /** Gets or sets the color of the color picker */
  73282. get value(): BABYLON.Color3;
  73283. set value(value: BABYLON.Color3);
  73284. /**
  73285. * Gets or sets control width
  73286. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73287. */
  73288. get width(): string | number;
  73289. set width(value: string | number);
  73290. /**
  73291. * Gets or sets control height
  73292. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73293. */
  73294. get height(): string | number;
  73295. /** Gets or sets control height */
  73296. set height(value: string | number);
  73297. /** Gets or sets control size */
  73298. get size(): string | number;
  73299. set size(value: string | number);
  73300. /**
  73301. * Creates a new ColorPicker
  73302. * @param name defines the control name
  73303. */
  73304. constructor(name?: string | undefined);
  73305. protected _getTypeName(): string;
  73306. /** @hidden */
  73307. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73308. private _updateSquareProps;
  73309. private _drawGradientSquare;
  73310. private _drawCircle;
  73311. private _createColorWheelCanvas;
  73312. /** @hidden */
  73313. _draw(context: CanvasRenderingContext2D): void;
  73314. private _pointerIsDown;
  73315. private _updateValueFromPointer;
  73316. private _isPointOnSquare;
  73317. private _isPointOnWheel;
  73318. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73319. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73320. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73321. /**
  73322. * This function expands the color picker by creating a color picker dialog with manual
  73323. * color value input and the ability to save colors into an array to be used later in
  73324. * subsequent launches of the dialogue.
  73325. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73326. * @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.
  73327. * @returns picked color as a hex string and the saved colors array as hex strings.
  73328. */
  73329. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73330. pickerWidth?: string;
  73331. pickerHeight?: string;
  73332. headerHeight?: string;
  73333. lastColor?: string;
  73334. swatchLimit?: number;
  73335. numSwatchesPerLine?: number;
  73336. savedColors?: Array<string>;
  73337. }): Promise<{
  73338. savedColors?: string[];
  73339. pickedColor: string;
  73340. }>;
  73341. }
  73342. }
  73343. declare module BABYLON.GUI {
  73344. /** Class used to create 2D ellipse containers */
  73345. export class Ellipse extends Container {
  73346. name?: string | undefined;
  73347. private _thickness;
  73348. /** Gets or sets border thickness */
  73349. get thickness(): number;
  73350. set thickness(value: number);
  73351. /**
  73352. * Creates a new Ellipse
  73353. * @param name defines the control name
  73354. */
  73355. constructor(name?: string | undefined);
  73356. protected _getTypeName(): string;
  73357. protected _localDraw(context: CanvasRenderingContext2D): void;
  73358. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73359. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73360. }
  73361. }
  73362. declare module BABYLON.GUI {
  73363. /**
  73364. * Class used to create a password control
  73365. */
  73366. export class InputPassword extends InputText {
  73367. protected _beforeRenderText(text: string): string;
  73368. }
  73369. }
  73370. declare module BABYLON.GUI {
  73371. /** Class used to render 2D lines */
  73372. export class Line extends Control {
  73373. name?: string | undefined;
  73374. private _lineWidth;
  73375. private _x1;
  73376. private _y1;
  73377. private _x2;
  73378. private _y2;
  73379. private _dash;
  73380. private _connectedControl;
  73381. private _connectedControlDirtyObserver;
  73382. /** Gets or sets the dash pattern */
  73383. get dash(): Array<number>;
  73384. set dash(value: Array<number>);
  73385. /** Gets or sets the control connected with the line end */
  73386. get connectedControl(): Control;
  73387. set connectedControl(value: Control);
  73388. /** Gets or sets start coordinates on X axis */
  73389. get x1(): string | number;
  73390. set x1(value: string | number);
  73391. /** Gets or sets start coordinates on Y axis */
  73392. get y1(): string | number;
  73393. set y1(value: string | number);
  73394. /** Gets or sets end coordinates on X axis */
  73395. get x2(): string | number;
  73396. set x2(value: string | number);
  73397. /** Gets or sets end coordinates on Y axis */
  73398. get y2(): string | number;
  73399. set y2(value: string | number);
  73400. /** Gets or sets line width */
  73401. get lineWidth(): number;
  73402. set lineWidth(value: number);
  73403. /** Gets or sets horizontal alignment */
  73404. set horizontalAlignment(value: number);
  73405. /** Gets or sets vertical alignment */
  73406. set verticalAlignment(value: number);
  73407. private get _effectiveX2();
  73408. private get _effectiveY2();
  73409. /**
  73410. * Creates a new Line
  73411. * @param name defines the control name
  73412. */
  73413. constructor(name?: string | undefined);
  73414. protected _getTypeName(): string;
  73415. _draw(context: CanvasRenderingContext2D): void;
  73416. _measure(): void;
  73417. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73418. /**
  73419. * Move one end of the line given 3D cartesian coordinates.
  73420. * @param position Targeted world position
  73421. * @param scene BABYLON.Scene
  73422. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73423. */
  73424. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73425. /**
  73426. * Move one end of the line to a position in screen absolute space.
  73427. * @param projectedPosition Position in screen absolute space (X, Y)
  73428. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73429. */
  73430. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73431. }
  73432. }
  73433. declare module BABYLON.GUI {
  73434. /**
  73435. * Class used to store a point for a MultiLine object.
  73436. * The point can be pure 2D coordinates, a mesh or a control
  73437. */
  73438. export class MultiLinePoint {
  73439. private _multiLine;
  73440. private _x;
  73441. private _y;
  73442. private _control;
  73443. private _mesh;
  73444. private _controlObserver;
  73445. private _meshObserver;
  73446. /** @hidden */
  73447. _point: BABYLON.Vector2;
  73448. /**
  73449. * Creates a new MultiLinePoint
  73450. * @param multiLine defines the source MultiLine object
  73451. */
  73452. constructor(multiLine: MultiLine);
  73453. /** Gets or sets x coordinate */
  73454. get x(): string | number;
  73455. set x(value: string | number);
  73456. /** Gets or sets y coordinate */
  73457. get y(): string | number;
  73458. set y(value: string | number);
  73459. /** Gets or sets the control associated with this point */
  73460. get control(): BABYLON.Nullable<Control>;
  73461. set control(value: BABYLON.Nullable<Control>);
  73462. /** Gets or sets the mesh associated with this point */
  73463. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73464. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73465. /** Resets links */
  73466. resetLinks(): void;
  73467. /**
  73468. * Gets a translation vector
  73469. * @returns the translation vector
  73470. */
  73471. translate(): BABYLON.Vector2;
  73472. private _translatePoint;
  73473. /** Release associated resources */
  73474. dispose(): void;
  73475. }
  73476. }
  73477. declare module BABYLON.GUI {
  73478. /**
  73479. * Class used to create multi line control
  73480. */
  73481. export class MultiLine extends Control {
  73482. name?: string | undefined;
  73483. private _lineWidth;
  73484. private _dash;
  73485. private _points;
  73486. private _minX;
  73487. private _minY;
  73488. private _maxX;
  73489. private _maxY;
  73490. /**
  73491. * Creates a new MultiLine
  73492. * @param name defines the control name
  73493. */
  73494. constructor(name?: string | undefined);
  73495. /** Gets or sets dash pattern */
  73496. get dash(): Array<number>;
  73497. set dash(value: Array<number>);
  73498. /**
  73499. * Gets point stored at specified index
  73500. * @param index defines the index to look for
  73501. * @returns the requested point if found
  73502. */
  73503. getAt(index: number): MultiLinePoint;
  73504. /** Function called when a point is updated */
  73505. onPointUpdate: () => void;
  73506. /**
  73507. * Adds new points to the point collection
  73508. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73509. * @returns the list of created MultiLinePoint
  73510. */
  73511. add(...items: (AbstractMesh | Control | {
  73512. x: string | number;
  73513. y: string | number;
  73514. })[]): MultiLinePoint[];
  73515. /**
  73516. * Adds a new point to the point collection
  73517. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73518. * @returns the created MultiLinePoint
  73519. */
  73520. push(item?: (AbstractMesh | Control | {
  73521. x: string | number;
  73522. y: string | number;
  73523. })): MultiLinePoint;
  73524. /**
  73525. * Remove a specific value or point from the active point collection
  73526. * @param value defines the value or point to remove
  73527. */
  73528. remove(value: number | MultiLinePoint): void;
  73529. /**
  73530. * Resets this object to initial state (no point)
  73531. */
  73532. reset(): void;
  73533. /**
  73534. * Resets all links
  73535. */
  73536. resetLinks(): void;
  73537. /** Gets or sets line width */
  73538. get lineWidth(): number;
  73539. set lineWidth(value: number);
  73540. set horizontalAlignment(value: number);
  73541. set verticalAlignment(value: number);
  73542. protected _getTypeName(): string;
  73543. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73544. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73545. _measure(): void;
  73546. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73547. dispose(): void;
  73548. }
  73549. }
  73550. declare module BABYLON.GUI {
  73551. /**
  73552. * Class used to create radio button controls
  73553. */
  73554. export class RadioButton extends Control {
  73555. name?: string | undefined;
  73556. private _isChecked;
  73557. private _background;
  73558. private _checkSizeRatio;
  73559. private _thickness;
  73560. /** Gets or sets border thickness */
  73561. get thickness(): number;
  73562. set thickness(value: number);
  73563. /** Gets or sets group name */
  73564. group: string;
  73565. /** BABYLON.Observable raised when isChecked is changed */
  73566. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73567. /** Gets or sets a value indicating the ratio between overall size and check size */
  73568. get checkSizeRatio(): number;
  73569. set checkSizeRatio(value: number);
  73570. /** Gets or sets background color */
  73571. get background(): string;
  73572. set background(value: string);
  73573. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73574. get isChecked(): boolean;
  73575. set isChecked(value: boolean);
  73576. /**
  73577. * Creates a new RadioButton
  73578. * @param name defines the control name
  73579. */
  73580. constructor(name?: string | undefined);
  73581. protected _getTypeName(): string;
  73582. _draw(context: CanvasRenderingContext2D): void;
  73583. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73584. /**
  73585. * Utility function to easily create a radio button with a header
  73586. * @param title defines the label to use for the header
  73587. * @param group defines the group to use for the radio button
  73588. * @param isChecked defines the initial state of the radio button
  73589. * @param onValueChanged defines the callback to call when value changes
  73590. * @returns a StackPanel containing the radio button and a textBlock
  73591. */
  73592. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73593. }
  73594. }
  73595. declare module BABYLON.GUI {
  73596. /**
  73597. * Class used to create slider controls
  73598. */
  73599. export class BaseSlider extends Control {
  73600. name?: string | undefined;
  73601. protected _thumbWidth: ValueAndUnit;
  73602. private _minimum;
  73603. private _maximum;
  73604. private _value;
  73605. private _isVertical;
  73606. protected _barOffset: ValueAndUnit;
  73607. private _isThumbClamped;
  73608. protected _displayThumb: boolean;
  73609. private _step;
  73610. private _lastPointerDownID;
  73611. protected _effectiveBarOffset: number;
  73612. protected _renderLeft: number;
  73613. protected _renderTop: number;
  73614. protected _renderWidth: number;
  73615. protected _renderHeight: number;
  73616. protected _backgroundBoxLength: number;
  73617. protected _backgroundBoxThickness: number;
  73618. protected _effectiveThumbThickness: number;
  73619. /** BABYLON.Observable raised when the sldier value changes */
  73620. onValueChangedObservable: BABYLON.Observable<number>;
  73621. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73622. get displayThumb(): boolean;
  73623. set displayThumb(value: boolean);
  73624. /** Gets or sets a step to apply to values (0 by default) */
  73625. get step(): number;
  73626. set step(value: number);
  73627. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73628. get barOffset(): string | number;
  73629. /** Gets main bar offset in pixels*/
  73630. get barOffsetInPixels(): number;
  73631. set barOffset(value: string | number);
  73632. /** Gets or sets thumb width */
  73633. get thumbWidth(): string | number;
  73634. /** Gets thumb width in pixels */
  73635. get thumbWidthInPixels(): number;
  73636. set thumbWidth(value: string | number);
  73637. /** Gets or sets minimum value */
  73638. get minimum(): number;
  73639. set minimum(value: number);
  73640. /** Gets or sets maximum value */
  73641. get maximum(): number;
  73642. set maximum(value: number);
  73643. /** Gets or sets current value */
  73644. get value(): number;
  73645. set value(value: number);
  73646. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73647. get isVertical(): boolean;
  73648. set isVertical(value: boolean);
  73649. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73650. get isThumbClamped(): boolean;
  73651. set isThumbClamped(value: boolean);
  73652. /**
  73653. * Creates a new BaseSlider
  73654. * @param name defines the control name
  73655. */
  73656. constructor(name?: string | undefined);
  73657. protected _getTypeName(): string;
  73658. protected _getThumbPosition(): number;
  73659. protected _getThumbThickness(type: string): number;
  73660. protected _prepareRenderingData(type: string): void;
  73661. private _pointerIsDown;
  73662. /** @hidden */
  73663. protected _updateValueFromPointer(x: number, y: number): void;
  73664. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73665. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73666. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73667. }
  73668. }
  73669. declare module BABYLON.GUI {
  73670. /**
  73671. * Class used to create slider controls
  73672. */
  73673. export class Slider extends BaseSlider {
  73674. name?: string | undefined;
  73675. private _background;
  73676. private _borderColor;
  73677. private _isThumbCircle;
  73678. protected _displayValueBar: boolean;
  73679. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73680. get displayValueBar(): boolean;
  73681. set displayValueBar(value: boolean);
  73682. /** Gets or sets border color */
  73683. get borderColor(): string;
  73684. set borderColor(value: string);
  73685. /** Gets or sets background color */
  73686. get background(): string;
  73687. set background(value: string);
  73688. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73689. get isThumbCircle(): boolean;
  73690. set isThumbCircle(value: boolean);
  73691. /**
  73692. * Creates a new Slider
  73693. * @param name defines the control name
  73694. */
  73695. constructor(name?: string | undefined);
  73696. protected _getTypeName(): string;
  73697. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73698. }
  73699. }
  73700. declare module BABYLON.GUI {
  73701. /** Class used to create a RadioGroup
  73702. * which contains groups of radio buttons
  73703. */
  73704. export class SelectorGroup {
  73705. /** name of SelectorGroup */
  73706. name: string;
  73707. private _groupPanel;
  73708. private _selectors;
  73709. private _groupHeader;
  73710. /**
  73711. * Creates a new SelectorGroup
  73712. * @param name of group, used as a group heading
  73713. */
  73714. constructor(
  73715. /** name of SelectorGroup */
  73716. name: string);
  73717. /** Gets the groupPanel of the SelectorGroup */
  73718. get groupPanel(): StackPanel;
  73719. /** Gets the selectors array */
  73720. get selectors(): StackPanel[];
  73721. /** Gets and sets the group header */
  73722. get header(): string;
  73723. set header(label: string);
  73724. /** @hidden */
  73725. private _addGroupHeader;
  73726. /** @hidden*/
  73727. _getSelector(selectorNb: number): StackPanel | undefined;
  73728. /** Removes the selector at the given position
  73729. * @param selectorNb the position of the selector within the group
  73730. */
  73731. removeSelector(selectorNb: number): void;
  73732. }
  73733. /** Class used to create a CheckboxGroup
  73734. * which contains groups of checkbox buttons
  73735. */
  73736. export class CheckboxGroup extends SelectorGroup {
  73737. /** Adds a checkbox as a control
  73738. * @param text is the label for the selector
  73739. * @param func is the function called when the Selector is checked
  73740. * @param checked is true when Selector is checked
  73741. */
  73742. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73743. /** @hidden */
  73744. _setSelectorLabel(selectorNb: number, label: string): void;
  73745. /** @hidden */
  73746. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73747. /** @hidden */
  73748. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73749. /** @hidden */
  73750. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73751. }
  73752. /** Class used to create a RadioGroup
  73753. * which contains groups of radio buttons
  73754. */
  73755. export class RadioGroup extends SelectorGroup {
  73756. private _selectNb;
  73757. /** Adds a radio button as a control
  73758. * @param label 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. addRadio(label: string, func?: (n: number) => 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 SliderGroup
  73773. * which contains groups of slider buttons
  73774. */
  73775. export class SliderGroup extends SelectorGroup {
  73776. /**
  73777. * Adds a slider to the SelectorGroup
  73778. * @param label is the label for the SliderBar
  73779. * @param func is the function called when the Slider moves
  73780. * @param unit is a string describing the units used, eg degrees or metres
  73781. * @param min is the minimum value for the Slider
  73782. * @param max is the maximum value for the Slider
  73783. * @param value is the start value for the Slider between min and max
  73784. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73785. */
  73786. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73787. /** @hidden */
  73788. _setSelectorLabel(selectorNb: number, label: string): void;
  73789. /** @hidden */
  73790. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73791. /** @hidden */
  73792. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73793. /** @hidden */
  73794. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73795. }
  73796. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73797. * @see http://doc.babylonjs.com/how_to/selector
  73798. */
  73799. export class SelectionPanel extends Rectangle {
  73800. /** name of SelectionPanel */
  73801. name: string;
  73802. /** an array of SelectionGroups */
  73803. groups: SelectorGroup[];
  73804. private _panel;
  73805. private _buttonColor;
  73806. private _buttonBackground;
  73807. private _headerColor;
  73808. private _barColor;
  73809. private _barHeight;
  73810. private _spacerHeight;
  73811. private _labelColor;
  73812. private _groups;
  73813. private _bars;
  73814. /**
  73815. * Creates a new SelectionPanel
  73816. * @param name of SelectionPanel
  73817. * @param groups is an array of SelectionGroups
  73818. */
  73819. constructor(
  73820. /** name of SelectionPanel */
  73821. name: string,
  73822. /** an array of SelectionGroups */
  73823. groups?: SelectorGroup[]);
  73824. protected _getTypeName(): string;
  73825. /** Gets or sets the headerColor */
  73826. get headerColor(): string;
  73827. set headerColor(color: string);
  73828. private _setHeaderColor;
  73829. /** Gets or sets the button color */
  73830. get buttonColor(): string;
  73831. set buttonColor(color: string);
  73832. private _setbuttonColor;
  73833. /** Gets or sets the label color */
  73834. get labelColor(): string;
  73835. set labelColor(color: string);
  73836. private _setLabelColor;
  73837. /** Gets or sets the button background */
  73838. get buttonBackground(): string;
  73839. set buttonBackground(color: string);
  73840. private _setButtonBackground;
  73841. /** Gets or sets the color of separator bar */
  73842. get barColor(): string;
  73843. set barColor(color: string);
  73844. private _setBarColor;
  73845. /** Gets or sets the height of separator bar */
  73846. get barHeight(): string;
  73847. set barHeight(value: string);
  73848. private _setBarHeight;
  73849. /** Gets or sets the height of spacers*/
  73850. get spacerHeight(): string;
  73851. set spacerHeight(value: string);
  73852. private _setSpacerHeight;
  73853. /** Adds a bar between groups */
  73854. private _addSpacer;
  73855. /** Add a group to the selection panel
  73856. * @param group is the selector group to add
  73857. */
  73858. addGroup(group: SelectorGroup): void;
  73859. /** Remove the group from the given position
  73860. * @param groupNb is the position of the group in the list
  73861. */
  73862. removeGroup(groupNb: number): void;
  73863. /** Change a group header label
  73864. * @param label is the new group header label
  73865. * @param groupNb is the number of the group to relabel
  73866. * */
  73867. setHeaderName(label: string, groupNb: number): void;
  73868. /** Change selector label to the one given
  73869. * @param label is the new selector label
  73870. * @param groupNb is the number of the groupcontaining the selector
  73871. * @param selectorNb is the number of the selector within a group to relabel
  73872. * */
  73873. relabel(label: string, groupNb: number, selectorNb: number): void;
  73874. /** For a given group position remove the selector at the given position
  73875. * @param groupNb is the number of the group to remove the selector from
  73876. * @param selectorNb is the number of the selector within the group
  73877. */
  73878. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73879. /** For a given group position of correct type add a checkbox button
  73880. * @param groupNb is the number of the group to remove the selector from
  73881. * @param label is the label for the selector
  73882. * @param func is the function called when the Selector is checked
  73883. * @param checked is true when Selector is checked
  73884. */
  73885. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73886. /** For a given group position of correct type add a radio button
  73887. * @param groupNb is the number of the group to remove the selector from
  73888. * @param label is the label for the selector
  73889. * @param func is the function called when the Selector is checked
  73890. * @param checked is true when Selector is checked
  73891. */
  73892. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73893. /**
  73894. * For a given slider group add a slider
  73895. * @param groupNb is the number of the group to add the slider to
  73896. * @param label is the label for the Slider
  73897. * @param func is the function called when the Slider moves
  73898. * @param unit is a string describing the units used, eg degrees or metres
  73899. * @param min is the minimum value for the Slider
  73900. * @param max is the maximum value for the Slider
  73901. * @param value is the start value for the Slider between min and max
  73902. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73903. */
  73904. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73905. }
  73906. }
  73907. declare module BABYLON.GUI {
  73908. /**
  73909. * Class used to hold a the container for ScrollViewer
  73910. * @hidden
  73911. */
  73912. export class _ScrollViewerWindow extends Container {
  73913. parentClientWidth: number;
  73914. parentClientHeight: number;
  73915. private _freezeControls;
  73916. private _parentMeasure;
  73917. private _oldLeft;
  73918. private _oldTop;
  73919. get freezeControls(): boolean;
  73920. set freezeControls(value: boolean);
  73921. private _bucketWidth;
  73922. private _bucketHeight;
  73923. private _buckets;
  73924. private _bucketLen;
  73925. get bucketWidth(): number;
  73926. get bucketHeight(): number;
  73927. setBucketSizes(width: number, height: number): void;
  73928. private _useBuckets;
  73929. private _makeBuckets;
  73930. private _dispatchInBuckets;
  73931. private _updateMeasures;
  73932. private _updateChildrenMeasures;
  73933. private _restoreMeasures;
  73934. /**
  73935. * Creates a new ScrollViewerWindow
  73936. * @param name of ScrollViewerWindow
  73937. */
  73938. constructor(name?: string);
  73939. protected _getTypeName(): string;
  73940. /** @hidden */
  73941. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73942. /** @hidden */
  73943. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73944. private _scrollChildren;
  73945. private _scrollChildrenWithBuckets;
  73946. /** @hidden */
  73947. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73948. protected _postMeasure(): void;
  73949. }
  73950. }
  73951. declare module BABYLON.GUI {
  73952. /**
  73953. * Class used to create slider controls
  73954. */
  73955. export class ScrollBar extends BaseSlider {
  73956. name?: string | undefined;
  73957. private _background;
  73958. private _borderColor;
  73959. private _tempMeasure;
  73960. /** Gets or sets border color */
  73961. get borderColor(): string;
  73962. set borderColor(value: string);
  73963. /** Gets or sets background color */
  73964. get background(): string;
  73965. set background(value: string);
  73966. /**
  73967. * Creates a new Slider
  73968. * @param name defines the control name
  73969. */
  73970. constructor(name?: string | undefined);
  73971. protected _getTypeName(): string;
  73972. protected _getThumbThickness(): number;
  73973. _draw(context: CanvasRenderingContext2D): void;
  73974. private _first;
  73975. private _originX;
  73976. private _originY;
  73977. /** @hidden */
  73978. protected _updateValueFromPointer(x: number, y: number): void;
  73979. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73980. }
  73981. }
  73982. declare module BABYLON.GUI {
  73983. /**
  73984. * Class used to create slider controls
  73985. */
  73986. export class ImageScrollBar extends BaseSlider {
  73987. name?: string | undefined;
  73988. private _backgroundBaseImage;
  73989. private _backgroundImage;
  73990. private _thumbImage;
  73991. private _thumbBaseImage;
  73992. private _thumbLength;
  73993. private _thumbHeight;
  73994. private _barImageHeight;
  73995. private _tempMeasure;
  73996. /** Number of 90° rotation to apply on the images when in vertical mode */
  73997. num90RotationInVerticalMode: number;
  73998. /**
  73999. * Gets or sets the image used to render the background for horizontal bar
  74000. */
  74001. get backgroundImage(): Image;
  74002. set backgroundImage(value: Image);
  74003. /**
  74004. * Gets or sets the image used to render the thumb
  74005. */
  74006. get thumbImage(): Image;
  74007. set thumbImage(value: Image);
  74008. /**
  74009. * Gets or sets the length of the thumb
  74010. */
  74011. get thumbLength(): number;
  74012. set thumbLength(value: number);
  74013. /**
  74014. * Gets or sets the height of the thumb
  74015. */
  74016. get thumbHeight(): number;
  74017. set thumbHeight(value: number);
  74018. /**
  74019. * Gets or sets the height of the bar image
  74020. */
  74021. get barImageHeight(): number;
  74022. set barImageHeight(value: number);
  74023. /**
  74024. * Creates a new ImageScrollBar
  74025. * @param name defines the control name
  74026. */
  74027. constructor(name?: string | undefined);
  74028. protected _getTypeName(): string;
  74029. protected _getThumbThickness(): number;
  74030. _draw(context: CanvasRenderingContext2D): void;
  74031. private _first;
  74032. private _originX;
  74033. private _originY;
  74034. /** @hidden */
  74035. protected _updateValueFromPointer(x: number, y: number): void;
  74036. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74037. }
  74038. }
  74039. declare module BABYLON.GUI {
  74040. /**
  74041. * Class used to hold a viewer window and sliders in a grid
  74042. */
  74043. export class ScrollViewer extends Rectangle {
  74044. private _grid;
  74045. private _horizontalBarSpace;
  74046. private _verticalBarSpace;
  74047. private _dragSpace;
  74048. private _horizontalBar;
  74049. private _verticalBar;
  74050. private _barColor;
  74051. private _barBackground;
  74052. private _barImage;
  74053. private _horizontalBarImage;
  74054. private _verticalBarImage;
  74055. private _barBackgroundImage;
  74056. private _horizontalBarBackgroundImage;
  74057. private _verticalBarBackgroundImage;
  74058. private _barSize;
  74059. private _window;
  74060. private _pointerIsOver;
  74061. private _wheelPrecision;
  74062. private _onWheelObserver;
  74063. private _clientWidth;
  74064. private _clientHeight;
  74065. private _useImageBar;
  74066. private _thumbLength;
  74067. private _thumbHeight;
  74068. private _barImageHeight;
  74069. private _horizontalBarImageHeight;
  74070. private _verticalBarImageHeight;
  74071. /**
  74072. * Gets the horizontal scrollbar
  74073. */
  74074. get horizontalBar(): ScrollBar | ImageScrollBar;
  74075. /**
  74076. * Gets the vertical scrollbar
  74077. */
  74078. get verticalBar(): ScrollBar | ImageScrollBar;
  74079. /**
  74080. * Adds a new control to the current container
  74081. * @param control defines the control to add
  74082. * @returns the current container
  74083. */
  74084. addControl(control: BABYLON.Nullable<Control>): Container;
  74085. /**
  74086. * Removes a control from the current container
  74087. * @param control defines the control to remove
  74088. * @returns the current container
  74089. */
  74090. removeControl(control: Control): Container;
  74091. /** Gets the list of children */
  74092. get children(): Control[];
  74093. _flagDescendantsAsMatrixDirty(): void;
  74094. /**
  74095. * Freezes or unfreezes the controls in the window.
  74096. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74097. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74098. */
  74099. get freezeControls(): boolean;
  74100. set freezeControls(value: boolean);
  74101. /** Gets the bucket width */
  74102. get bucketWidth(): number;
  74103. /** Gets the bucket height */
  74104. get bucketHeight(): number;
  74105. /**
  74106. * Sets the bucket sizes.
  74107. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74108. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74109. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74110. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74111. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74112. * used), that's why it is not enabled by default.
  74113. * @param width width of the bucket
  74114. * @param height height of the bucket
  74115. */
  74116. setBucketSizes(width: number, height: number): void;
  74117. private _forceHorizontalBar;
  74118. private _forceVerticalBar;
  74119. /**
  74120. * Forces the horizontal scroll bar to be displayed
  74121. */
  74122. get forceHorizontalBar(): boolean;
  74123. set forceHorizontalBar(value: boolean);
  74124. /**
  74125. * Forces the vertical scroll bar to be displayed
  74126. */
  74127. get forceVerticalBar(): boolean;
  74128. set forceVerticalBar(value: boolean);
  74129. /**
  74130. * Creates a new ScrollViewer
  74131. * @param name of ScrollViewer
  74132. */
  74133. constructor(name?: string, isImageBased?: boolean);
  74134. /** Reset the scroll viewer window to initial size */
  74135. resetWindow(): void;
  74136. protected _getTypeName(): string;
  74137. private _buildClientSizes;
  74138. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74139. protected _postMeasure(): void;
  74140. /**
  74141. * Gets or sets the mouse wheel precision
  74142. * from 0 to 1 with a default value of 0.05
  74143. * */
  74144. get wheelPrecision(): number;
  74145. set wheelPrecision(value: number);
  74146. /** Gets or sets the scroll bar container background color */
  74147. get scrollBackground(): string;
  74148. set scrollBackground(color: string);
  74149. /** Gets or sets the bar color */
  74150. get barColor(): string;
  74151. set barColor(color: string);
  74152. /** Gets or sets the bar image */
  74153. get thumbImage(): Image;
  74154. set thumbImage(value: Image);
  74155. /** Gets or sets the horizontal bar image */
  74156. get horizontalThumbImage(): Image;
  74157. set horizontalThumbImage(value: Image);
  74158. /** Gets or sets the vertical bar image */
  74159. get verticalThumbImage(): Image;
  74160. set verticalThumbImage(value: Image);
  74161. /** Gets or sets the size of the bar */
  74162. get barSize(): number;
  74163. set barSize(value: number);
  74164. /** Gets or sets the length of the thumb */
  74165. get thumbLength(): number;
  74166. set thumbLength(value: number);
  74167. /** Gets or sets the height of the thumb */
  74168. get thumbHeight(): number;
  74169. set thumbHeight(value: number);
  74170. /** Gets or sets the height of the bar image */
  74171. get barImageHeight(): number;
  74172. set barImageHeight(value: number);
  74173. /** Gets or sets the height of the horizontal bar image */
  74174. get horizontalBarImageHeight(): number;
  74175. set horizontalBarImageHeight(value: number);
  74176. /** Gets or sets the height of the vertical bar image */
  74177. get verticalBarImageHeight(): number;
  74178. set verticalBarImageHeight(value: number);
  74179. /** Gets or sets the bar background */
  74180. get barBackground(): string;
  74181. set barBackground(color: string);
  74182. /** Gets or sets the bar background image */
  74183. get barImage(): Image;
  74184. set barImage(value: Image);
  74185. /** Gets or sets the horizontal bar background image */
  74186. get horizontalBarImage(): Image;
  74187. set horizontalBarImage(value: Image);
  74188. /** Gets or sets the vertical bar background image */
  74189. get verticalBarImage(): Image;
  74190. set verticalBarImage(value: Image);
  74191. private _setWindowPosition;
  74192. /** @hidden */
  74193. private _updateScroller;
  74194. _link(host: AdvancedDynamicTexture): void;
  74195. /** @hidden */
  74196. private _addBar;
  74197. /** @hidden */
  74198. private _attachWheel;
  74199. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74200. /** Releases associated resources */
  74201. dispose(): void;
  74202. }
  74203. }
  74204. declare module BABYLON.GUI {
  74205. /** Class used to render a grid */
  74206. export class DisplayGrid extends Control {
  74207. name?: string | undefined;
  74208. private _cellWidth;
  74209. private _cellHeight;
  74210. private _minorLineTickness;
  74211. private _minorLineColor;
  74212. private _majorLineTickness;
  74213. private _majorLineColor;
  74214. private _majorLineFrequency;
  74215. private _background;
  74216. private _displayMajorLines;
  74217. private _displayMinorLines;
  74218. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74219. get displayMinorLines(): boolean;
  74220. set displayMinorLines(value: boolean);
  74221. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74222. get displayMajorLines(): boolean;
  74223. set displayMajorLines(value: boolean);
  74224. /** Gets or sets background color (Black by default) */
  74225. get background(): string;
  74226. set background(value: string);
  74227. /** Gets or sets the width of each cell (20 by default) */
  74228. get cellWidth(): number;
  74229. set cellWidth(value: number);
  74230. /** Gets or sets the height of each cell (20 by default) */
  74231. get cellHeight(): number;
  74232. set cellHeight(value: number);
  74233. /** Gets or sets the tickness of minor lines (1 by default) */
  74234. get minorLineTickness(): number;
  74235. set minorLineTickness(value: number);
  74236. /** Gets or sets the color of minor lines (DarkGray by default) */
  74237. get minorLineColor(): string;
  74238. set minorLineColor(value: string);
  74239. /** Gets or sets the tickness of major lines (2 by default) */
  74240. get majorLineTickness(): number;
  74241. set majorLineTickness(value: number);
  74242. /** Gets or sets the color of major lines (White by default) */
  74243. get majorLineColor(): string;
  74244. set majorLineColor(value: string);
  74245. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74246. get majorLineFrequency(): number;
  74247. set majorLineFrequency(value: number);
  74248. /**
  74249. * Creates a new GridDisplayRectangle
  74250. * @param name defines the control name
  74251. */
  74252. constructor(name?: string | undefined);
  74253. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74254. protected _getTypeName(): string;
  74255. }
  74256. }
  74257. declare module BABYLON.GUI {
  74258. /**
  74259. * Class used to create slider controls based on images
  74260. */
  74261. export class ImageBasedSlider extends BaseSlider {
  74262. name?: string | undefined;
  74263. private _backgroundImage;
  74264. private _thumbImage;
  74265. private _valueBarImage;
  74266. private _tempMeasure;
  74267. get displayThumb(): boolean;
  74268. set displayThumb(value: boolean);
  74269. /**
  74270. * Gets or sets the image used to render the background
  74271. */
  74272. get backgroundImage(): Image;
  74273. set backgroundImage(value: Image);
  74274. /**
  74275. * Gets or sets the image used to render the value bar
  74276. */
  74277. get valueBarImage(): Image;
  74278. set valueBarImage(value: Image);
  74279. /**
  74280. * Gets or sets the image used to render the thumb
  74281. */
  74282. get thumbImage(): Image;
  74283. set thumbImage(value: Image);
  74284. /**
  74285. * Creates a new ImageBasedSlider
  74286. * @param name defines the control name
  74287. */
  74288. constructor(name?: string | undefined);
  74289. protected _getTypeName(): string;
  74290. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74291. }
  74292. }
  74293. declare module BABYLON.GUI {
  74294. /**
  74295. * Forcing an export so that this code will execute
  74296. * @hidden
  74297. */
  74298. const name = "Statics";
  74299. }
  74300. declare module BABYLON.GUI {
  74301. /**
  74302. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74303. */
  74304. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74305. /**
  74306. * Define the instrumented AdvancedDynamicTexture.
  74307. */
  74308. texture: AdvancedDynamicTexture;
  74309. private _captureRenderTime;
  74310. private _renderTime;
  74311. private _captureLayoutTime;
  74312. private _layoutTime;
  74313. private _onBeginRenderObserver;
  74314. private _onEndRenderObserver;
  74315. private _onBeginLayoutObserver;
  74316. private _onEndLayoutObserver;
  74317. /**
  74318. * Gets the perf counter used to capture render time
  74319. */
  74320. get renderTimeCounter(): BABYLON.PerfCounter;
  74321. /**
  74322. * Gets the perf counter used to capture layout time
  74323. */
  74324. get layoutTimeCounter(): BABYLON.PerfCounter;
  74325. /**
  74326. * Enable or disable the render time capture
  74327. */
  74328. get captureRenderTime(): boolean;
  74329. set captureRenderTime(value: boolean);
  74330. /**
  74331. * Enable or disable the layout time capture
  74332. */
  74333. get captureLayoutTime(): boolean;
  74334. set captureLayoutTime(value: boolean);
  74335. /**
  74336. * Instantiates a new advanced dynamic texture instrumentation.
  74337. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74338. * @param texture Defines the AdvancedDynamicTexture to instrument
  74339. */
  74340. constructor(
  74341. /**
  74342. * Define the instrumented AdvancedDynamicTexture.
  74343. */
  74344. texture: AdvancedDynamicTexture);
  74345. /**
  74346. * Dispose and release associated resources.
  74347. */
  74348. dispose(): void;
  74349. }
  74350. }
  74351. declare module BABYLON.GUI {
  74352. /**
  74353. * Class used to load GUI via XML.
  74354. */
  74355. export class XmlLoader {
  74356. private _nodes;
  74357. private _nodeTypes;
  74358. private _isLoaded;
  74359. private _objectAttributes;
  74360. private _parentClass;
  74361. /**
  74362. * Create a new xml loader
  74363. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74364. */
  74365. constructor(parentClass?: null);
  74366. private _getChainElement;
  74367. private _getClassAttribute;
  74368. private _createGuiElement;
  74369. private _parseGrid;
  74370. private _parseElement;
  74371. private _prepareSourceElement;
  74372. private _parseElementsFromSource;
  74373. private _parseXml;
  74374. /**
  74375. * Gets if the loading has finished.
  74376. * @returns whether the loading has finished or not
  74377. */
  74378. isLoaded(): boolean;
  74379. /**
  74380. * Gets a loaded node / control by id.
  74381. * @param id the Controls id set in the xml
  74382. * @returns element of type Control
  74383. */
  74384. getNodeById(id: string): any;
  74385. /**
  74386. * Gets all loaded nodes / controls
  74387. * @returns Array of controls
  74388. */
  74389. getNodes(): any;
  74390. /**
  74391. * Initiates the xml layout loading
  74392. * @param xmlFile defines the xml layout to load
  74393. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74394. * @param callback defines the callback called on layout load.
  74395. */
  74396. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74397. }
  74398. }
  74399. declare module BABYLON.GUI {
  74400. /**
  74401. * Class used to create containers for controls
  74402. */
  74403. export class Container3D extends Control3D {
  74404. private _blockLayout;
  74405. /**
  74406. * Gets the list of child controls
  74407. */
  74408. protected _children: Control3D[];
  74409. /**
  74410. * Gets the list of child controls
  74411. */
  74412. get children(): Array<Control3D>;
  74413. /**
  74414. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74415. * This is helpful to optimize layout operation when adding multiple children in a row
  74416. */
  74417. get blockLayout(): boolean;
  74418. set blockLayout(value: boolean);
  74419. /**
  74420. * Creates a new container
  74421. * @param name defines the container name
  74422. */
  74423. constructor(name?: string);
  74424. /**
  74425. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74426. * @returns the current container
  74427. */
  74428. updateLayout(): Container3D;
  74429. /**
  74430. * Gets a boolean indicating if the given control is in the children of this control
  74431. * @param control defines the control to check
  74432. * @returns true if the control is in the child list
  74433. */
  74434. containsControl(control: Control3D): boolean;
  74435. /**
  74436. * Adds a control to the children of this control
  74437. * @param control defines the control to add
  74438. * @returns the current container
  74439. */
  74440. addControl(control: Control3D): Container3D;
  74441. /**
  74442. * This function will be called everytime a new control is added
  74443. */
  74444. protected _arrangeChildren(): void;
  74445. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74446. /**
  74447. * Removes a control from the children of this control
  74448. * @param control defines the control to remove
  74449. * @returns the current container
  74450. */
  74451. removeControl(control: Control3D): Container3D;
  74452. protected _getTypeName(): string;
  74453. /**
  74454. * Releases all associated resources
  74455. */
  74456. dispose(): void;
  74457. /** Control rotation will remain unchanged */
  74458. static readonly UNSET_ORIENTATION: number;
  74459. /** Control will rotate to make it look at sphere central axis */
  74460. static readonly FACEORIGIN_ORIENTATION: number;
  74461. /** Control will rotate to make it look back at sphere central axis */
  74462. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74463. /** Control will rotate to look at z axis (0, 0, 1) */
  74464. static readonly FACEFORWARD_ORIENTATION: number;
  74465. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74466. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74467. }
  74468. }
  74469. declare module BABYLON.GUI {
  74470. /**
  74471. * Class used to manage 3D user interface
  74472. * @see http://doc.babylonjs.com/how_to/gui3d
  74473. */
  74474. export class GUI3DManager implements BABYLON.IDisposable {
  74475. private _scene;
  74476. private _sceneDisposeObserver;
  74477. private _utilityLayer;
  74478. private _rootContainer;
  74479. private _pointerObserver;
  74480. private _pointerOutObserver;
  74481. /** @hidden */
  74482. _lastPickedControl: Control3D;
  74483. /** @hidden */
  74484. _lastControlOver: {
  74485. [pointerId: number]: Control3D;
  74486. };
  74487. /** @hidden */
  74488. _lastControlDown: {
  74489. [pointerId: number]: Control3D;
  74490. };
  74491. /**
  74492. * BABYLON.Observable raised when the point picked by the pointer events changed
  74493. */
  74494. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74495. /** @hidden */
  74496. _sharedMaterials: {
  74497. [key: string]: BABYLON.Material;
  74498. };
  74499. /** Gets the hosting scene */
  74500. get scene(): BABYLON.Scene;
  74501. /** Gets associated utility layer */
  74502. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74503. /**
  74504. * Creates a new GUI3DManager
  74505. * @param scene
  74506. */
  74507. constructor(scene?: BABYLON.Scene);
  74508. private _handlePointerOut;
  74509. private _doPicking;
  74510. /**
  74511. * Gets the root container
  74512. */
  74513. get rootContainer(): Container3D;
  74514. /**
  74515. * Gets a boolean indicating if the given control is in the root child list
  74516. * @param control defines the control to check
  74517. * @returns true if the control is in the root child list
  74518. */
  74519. containsControl(control: Control3D): boolean;
  74520. /**
  74521. * Adds a control to the root child list
  74522. * @param control defines the control to add
  74523. * @returns the current manager
  74524. */
  74525. addControl(control: Control3D): GUI3DManager;
  74526. /**
  74527. * Removes a control from the root child list
  74528. * @param control defines the control to remove
  74529. * @returns the current container
  74530. */
  74531. removeControl(control: Control3D): GUI3DManager;
  74532. /**
  74533. * Releases all associated resources
  74534. */
  74535. dispose(): void;
  74536. }
  74537. }
  74538. declare module BABYLON.GUI {
  74539. /**
  74540. * Class used to transport BABYLON.Vector3 information for pointer events
  74541. */
  74542. export class Vector3WithInfo extends BABYLON.Vector3 {
  74543. /** defines the current mouse button index */
  74544. buttonIndex: number;
  74545. /**
  74546. * Creates a new Vector3WithInfo
  74547. * @param source defines the vector3 data to transport
  74548. * @param buttonIndex defines the current mouse button index
  74549. */
  74550. constructor(source: BABYLON.Vector3,
  74551. /** defines the current mouse button index */
  74552. buttonIndex?: number);
  74553. }
  74554. }
  74555. declare module BABYLON.GUI {
  74556. /**
  74557. * Class used as base class for controls
  74558. */
  74559. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74560. /** Defines the control name */
  74561. name?: string | undefined;
  74562. /** @hidden */
  74563. _host: GUI3DManager;
  74564. private _node;
  74565. private _downCount;
  74566. private _enterCount;
  74567. private _downPointerIds;
  74568. private _isVisible;
  74569. /** Gets or sets the control position in world space */
  74570. get position(): BABYLON.Vector3;
  74571. set position(value: BABYLON.Vector3);
  74572. /** Gets or sets the control scaling in world space */
  74573. get scaling(): BABYLON.Vector3;
  74574. set scaling(value: BABYLON.Vector3);
  74575. /** Callback used to start pointer enter animation */
  74576. pointerEnterAnimation: () => void;
  74577. /** Callback used to start pointer out animation */
  74578. pointerOutAnimation: () => void;
  74579. /** Callback used to start pointer down animation */
  74580. pointerDownAnimation: () => void;
  74581. /** Callback used to start pointer up animation */
  74582. pointerUpAnimation: () => void;
  74583. /**
  74584. * An event triggered when the pointer move over the control
  74585. */
  74586. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74587. /**
  74588. * An event triggered when the pointer move out of the control
  74589. */
  74590. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74591. /**
  74592. * An event triggered when the pointer taps the control
  74593. */
  74594. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74595. /**
  74596. * An event triggered when pointer is up
  74597. */
  74598. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74599. /**
  74600. * An event triggered when a control is clicked on (with a mouse)
  74601. */
  74602. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74603. /**
  74604. * An event triggered when pointer enters the control
  74605. */
  74606. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74607. /**
  74608. * Gets or sets the parent container
  74609. */
  74610. parent: BABYLON.Nullable<Container3D>;
  74611. private _behaviors;
  74612. /**
  74613. * Gets the list of attached behaviors
  74614. * @see http://doc.babylonjs.com/features/behaviour
  74615. */
  74616. get behaviors(): BABYLON.Behavior<Control3D>[];
  74617. /**
  74618. * Attach a behavior to the control
  74619. * @see http://doc.babylonjs.com/features/behaviour
  74620. * @param behavior defines the behavior to attach
  74621. * @returns the current control
  74622. */
  74623. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74624. /**
  74625. * Remove an attached behavior
  74626. * @see http://doc.babylonjs.com/features/behaviour
  74627. * @param behavior defines the behavior to attach
  74628. * @returns the current control
  74629. */
  74630. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74631. /**
  74632. * Gets an attached behavior by name
  74633. * @param name defines the name of the behavior to look for
  74634. * @see http://doc.babylonjs.com/features/behaviour
  74635. * @returns null if behavior was not found else the requested behavior
  74636. */
  74637. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74638. /** Gets or sets a boolean indicating if the control is visible */
  74639. get isVisible(): boolean;
  74640. set isVisible(value: boolean);
  74641. /**
  74642. * Creates a new control
  74643. * @param name defines the control name
  74644. */
  74645. constructor(
  74646. /** Defines the control name */
  74647. name?: string | undefined);
  74648. /**
  74649. * Gets a string representing the class name
  74650. */
  74651. get typeName(): string;
  74652. /**
  74653. * Get the current class name of the control.
  74654. * @returns current class name
  74655. */
  74656. getClassName(): string;
  74657. protected _getTypeName(): string;
  74658. /**
  74659. * Gets the transform node used by this control
  74660. */
  74661. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74662. /**
  74663. * Gets the mesh used to render this control
  74664. */
  74665. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74666. /**
  74667. * Link the control as child of the given node
  74668. * @param node defines the node to link to. Use null to unlink the control
  74669. * @returns the current control
  74670. */
  74671. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74672. /** @hidden **/
  74673. _prepareNode(scene: BABYLON.Scene): void;
  74674. /**
  74675. * Node creation.
  74676. * Can be overriden by children
  74677. * @param scene defines the scene where the node must be attached
  74678. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74679. */
  74680. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74681. /**
  74682. * Affect a material to the given mesh
  74683. * @param mesh defines the mesh which will represent the control
  74684. */
  74685. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74686. /** @hidden */
  74687. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74688. /** @hidden */
  74689. _onPointerEnter(target: Control3D): boolean;
  74690. /** @hidden */
  74691. _onPointerOut(target: Control3D): void;
  74692. /** @hidden */
  74693. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74694. /** @hidden */
  74695. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74696. /** @hidden */
  74697. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74698. /** @hidden */
  74699. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74700. /** @hidden */
  74701. _disposeNode(): void;
  74702. /**
  74703. * Releases all associated resources
  74704. */
  74705. dispose(): void;
  74706. }
  74707. }
  74708. declare module BABYLON.GUI {
  74709. /**
  74710. * Class used as a root to all buttons
  74711. */
  74712. export class AbstractButton3D extends Control3D {
  74713. /**
  74714. * Creates a new button
  74715. * @param name defines the control name
  74716. */
  74717. constructor(name?: string);
  74718. protected _getTypeName(): string;
  74719. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74720. }
  74721. }
  74722. declare module BABYLON.GUI {
  74723. /**
  74724. * Class used to create a button in 3D
  74725. */
  74726. export class Button3D extends AbstractButton3D {
  74727. /** @hidden */
  74728. protected _currentMaterial: BABYLON.Material;
  74729. private _facadeTexture;
  74730. private _content;
  74731. private _contentResolution;
  74732. private _contentScaleRatio;
  74733. /**
  74734. * Gets or sets the texture resolution used to render content (512 by default)
  74735. */
  74736. get contentResolution(): BABYLON.int;
  74737. set contentResolution(value: BABYLON.int);
  74738. /**
  74739. * Gets or sets the texture scale ratio used to render content (2 by default)
  74740. */
  74741. get contentScaleRatio(): number;
  74742. set contentScaleRatio(value: number);
  74743. protected _disposeFacadeTexture(): void;
  74744. protected _resetContent(): void;
  74745. /**
  74746. * Creates a new button
  74747. * @param name defines the control name
  74748. */
  74749. constructor(name?: string);
  74750. /**
  74751. * Gets or sets the GUI 2D content used to display the button's facade
  74752. */
  74753. get content(): Control;
  74754. set content(value: Control);
  74755. /**
  74756. * Apply the facade texture (created from the content property).
  74757. * This function can be overloaded by child classes
  74758. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74759. */
  74760. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74761. protected _getTypeName(): string;
  74762. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74763. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74764. /**
  74765. * Releases all associated resources
  74766. */
  74767. dispose(): void;
  74768. }
  74769. }
  74770. declare module BABYLON.GUI {
  74771. /**
  74772. * Abstract class used to create a container panel deployed on the surface of a volume
  74773. */
  74774. export abstract class VolumeBasedPanel extends Container3D {
  74775. private _columns;
  74776. private _rows;
  74777. private _rowThenColum;
  74778. private _orientation;
  74779. protected _cellWidth: number;
  74780. protected _cellHeight: number;
  74781. /**
  74782. * Gets or sets the distance between elements
  74783. */
  74784. margin: number;
  74785. /**
  74786. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74787. * | Value | Type | Description |
  74788. * | ----- | ----------------------------------- | ----------- |
  74789. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74790. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74791. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74792. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74793. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74794. */
  74795. get orientation(): number;
  74796. set orientation(value: number);
  74797. /**
  74798. * Gets or sets the number of columns requested (10 by default).
  74799. * The panel will automatically compute the number of rows based on number of child controls.
  74800. */
  74801. get columns(): BABYLON.int;
  74802. set columns(value: BABYLON.int);
  74803. /**
  74804. * Gets or sets a the number of rows requested.
  74805. * The panel will automatically compute the number of columns based on number of child controls.
  74806. */
  74807. get rows(): BABYLON.int;
  74808. set rows(value: BABYLON.int);
  74809. /**
  74810. * Creates new VolumeBasedPanel
  74811. */
  74812. constructor();
  74813. protected _arrangeChildren(): void;
  74814. /** Child classes must implement this function to provide correct control positioning */
  74815. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74816. /** Child classes can implement this function to provide additional processing */
  74817. protected _finalProcessing(): void;
  74818. }
  74819. }
  74820. declare module BABYLON.GUI {
  74821. /**
  74822. * Class used to create a container panel deployed on the surface of a cylinder
  74823. */
  74824. export class CylinderPanel extends VolumeBasedPanel {
  74825. private _radius;
  74826. /**
  74827. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74828. */
  74829. get radius(): BABYLON.float;
  74830. set radius(value: BABYLON.float);
  74831. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74832. private _cylindricalMapping;
  74833. }
  74834. }
  74835. declare module BABYLON.GUI {
  74836. /** @hidden */
  74837. export var fluentVertexShader: {
  74838. name: string;
  74839. shader: string;
  74840. };
  74841. }
  74842. declare module BABYLON.GUI {
  74843. /** @hidden */
  74844. export var fluentPixelShader: {
  74845. name: string;
  74846. shader: string;
  74847. };
  74848. }
  74849. declare module BABYLON.GUI {
  74850. /** @hidden */
  74851. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74852. INNERGLOW: boolean;
  74853. BORDER: boolean;
  74854. HOVERLIGHT: boolean;
  74855. TEXTURE: boolean;
  74856. constructor();
  74857. }
  74858. /**
  74859. * Class used to render controls with fluent desgin
  74860. */
  74861. export class FluentMaterial extends BABYLON.PushMaterial {
  74862. /**
  74863. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74864. */
  74865. innerGlowColorIntensity: number;
  74866. /**
  74867. * Gets or sets the inner glow color (white by default)
  74868. */
  74869. innerGlowColor: BABYLON.Color3;
  74870. /**
  74871. * Gets or sets alpha value (default is 1.0)
  74872. */
  74873. alpha: number;
  74874. /**
  74875. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74876. */
  74877. albedoColor: BABYLON.Color3;
  74878. /**
  74879. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74880. */
  74881. renderBorders: boolean;
  74882. /**
  74883. * Gets or sets border width (default is 0.5)
  74884. */
  74885. borderWidth: number;
  74886. /**
  74887. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74888. */
  74889. edgeSmoothingValue: number;
  74890. /**
  74891. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74892. */
  74893. borderMinValue: number;
  74894. /**
  74895. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74896. */
  74897. renderHoverLight: boolean;
  74898. /**
  74899. * Gets or sets the radius used to render the hover light (default is 1.0)
  74900. */
  74901. hoverRadius: number;
  74902. /**
  74903. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74904. */
  74905. hoverColor: BABYLON.Color4;
  74906. /**
  74907. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74908. */
  74909. hoverPosition: BABYLON.Vector3;
  74910. private _albedoTexture;
  74911. /** Gets or sets the texture to use for albedo color */
  74912. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74913. /**
  74914. * Creates a new Fluent material
  74915. * @param name defines the name of the material
  74916. * @param scene defines the hosting scene
  74917. */
  74918. constructor(name: string, scene: BABYLON.Scene);
  74919. needAlphaBlending(): boolean;
  74920. needAlphaTesting(): boolean;
  74921. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74922. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74923. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74924. getActiveTextures(): BABYLON.BaseTexture[];
  74925. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74926. dispose(forceDisposeEffect?: boolean): void;
  74927. clone(name: string): FluentMaterial;
  74928. serialize(): any;
  74929. getClassName(): string;
  74930. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74931. }
  74932. }
  74933. declare module BABYLON.GUI {
  74934. /**
  74935. * Class used to create a holographic button in 3D
  74936. */
  74937. export class HolographicButton extends Button3D {
  74938. private _backPlate;
  74939. private _textPlate;
  74940. private _frontPlate;
  74941. private _text;
  74942. private _imageUrl;
  74943. private _shareMaterials;
  74944. private _frontMaterial;
  74945. private _backMaterial;
  74946. private _plateMaterial;
  74947. private _pickedPointObserver;
  74948. private _tooltipFade;
  74949. private _tooltipTextBlock;
  74950. private _tooltipTexture;
  74951. private _tooltipMesh;
  74952. private _tooltipHoverObserver;
  74953. private _tooltipOutObserver;
  74954. private _disposeTooltip;
  74955. /**
  74956. * Rendering ground id of all the mesh in the button
  74957. */
  74958. set renderingGroupId(id: number);
  74959. get renderingGroupId(): number;
  74960. /**
  74961. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74962. */
  74963. set tooltipText(text: BABYLON.Nullable<string>);
  74964. get tooltipText(): BABYLON.Nullable<string>;
  74965. /**
  74966. * Gets or sets text for the button
  74967. */
  74968. get text(): string;
  74969. set text(value: string);
  74970. /**
  74971. * Gets or sets the image url for the button
  74972. */
  74973. get imageUrl(): string;
  74974. set imageUrl(value: string);
  74975. /**
  74976. * Gets the back material used by this button
  74977. */
  74978. get backMaterial(): FluentMaterial;
  74979. /**
  74980. * Gets the front material used by this button
  74981. */
  74982. get frontMaterial(): FluentMaterial;
  74983. /**
  74984. * Gets the plate material used by this button
  74985. */
  74986. get plateMaterial(): BABYLON.StandardMaterial;
  74987. /**
  74988. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74989. */
  74990. get shareMaterials(): boolean;
  74991. /**
  74992. * Creates a new button
  74993. * @param name defines the control name
  74994. */
  74995. constructor(name?: string, shareMaterials?: boolean);
  74996. protected _getTypeName(): string;
  74997. private _rebuildContent;
  74998. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74999. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75000. private _createBackMaterial;
  75001. private _createFrontMaterial;
  75002. private _createPlateMaterial;
  75003. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75004. /**
  75005. * Releases all associated resources
  75006. */
  75007. dispose(): void;
  75008. }
  75009. }
  75010. declare module BABYLON.GUI {
  75011. /**
  75012. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75013. */
  75014. export class MeshButton3D extends Button3D {
  75015. /** @hidden */
  75016. protected _currentMesh: BABYLON.Mesh;
  75017. /**
  75018. * Creates a new 3D button based on a mesh
  75019. * @param mesh mesh to become a 3D button
  75020. * @param name defines the control name
  75021. */
  75022. constructor(mesh: BABYLON.Mesh, name?: string);
  75023. protected _getTypeName(): string;
  75024. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75025. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75026. }
  75027. }
  75028. declare module BABYLON.GUI {
  75029. /**
  75030. * Class used to create a container panel deployed on the surface of a plane
  75031. */
  75032. export class PlanePanel extends VolumeBasedPanel {
  75033. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75034. }
  75035. }
  75036. declare module BABYLON.GUI {
  75037. /**
  75038. * Class used to create a container panel where items get randomized planar mapping
  75039. */
  75040. export class ScatterPanel extends VolumeBasedPanel {
  75041. private _iteration;
  75042. /**
  75043. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75044. */
  75045. get iteration(): BABYLON.float;
  75046. set iteration(value: BABYLON.float);
  75047. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75048. private _scatterMapping;
  75049. protected _finalProcessing(): void;
  75050. }
  75051. }
  75052. declare module BABYLON.GUI {
  75053. /**
  75054. * Class used to create a container panel deployed on the surface of a sphere
  75055. */
  75056. export class SpherePanel extends VolumeBasedPanel {
  75057. private _radius;
  75058. /**
  75059. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75060. */
  75061. get radius(): BABYLON.float;
  75062. set radius(value: BABYLON.float);
  75063. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75064. private _sphericalMapping;
  75065. }
  75066. }
  75067. declare module BABYLON.GUI {
  75068. /**
  75069. * Class used to create a stack panel in 3D on XY plane
  75070. */
  75071. export class StackPanel3D extends Container3D {
  75072. private _isVertical;
  75073. /**
  75074. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75075. */
  75076. get isVertical(): boolean;
  75077. set isVertical(value: boolean);
  75078. /**
  75079. * Gets or sets the distance between elements
  75080. */
  75081. margin: number;
  75082. /**
  75083. * Creates new StackPanel
  75084. * @param isVertical
  75085. */
  75086. constructor(isVertical?: boolean);
  75087. protected _arrangeChildren(): void;
  75088. }
  75089. }
  75090. declare module BABYLON {
  75091. /**
  75092. * Configuration for glTF validation
  75093. */
  75094. export interface IGLTFValidationConfiguration {
  75095. /**
  75096. * The url of the glTF validator.
  75097. */
  75098. url: string;
  75099. }
  75100. /**
  75101. * glTF validation
  75102. */
  75103. export class GLTFValidation {
  75104. /**
  75105. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75106. */
  75107. static Configuration: IGLTFValidationConfiguration;
  75108. private static _LoadScriptPromise;
  75109. /**
  75110. * Validate a glTF asset using the glTF-Validator.
  75111. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75112. * @param rootUrl The root url for the glTF
  75113. * @param fileName The file name for the glTF
  75114. * @param getExternalResource The callback to get external resources for the glTF validator
  75115. * @returns A promise that resolves with the glTF validation results once complete
  75116. */
  75117. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75118. }
  75119. }
  75120. declare module BABYLON {
  75121. /**
  75122. * Mode that determines the coordinate system to use.
  75123. */
  75124. export enum GLTFLoaderCoordinateSystemMode {
  75125. /**
  75126. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75127. */
  75128. AUTO = 0,
  75129. /**
  75130. * Sets the useRightHandedSystem flag on the scene.
  75131. */
  75132. FORCE_RIGHT_HANDED = 1
  75133. }
  75134. /**
  75135. * Mode that determines what animations will start.
  75136. */
  75137. export enum GLTFLoaderAnimationStartMode {
  75138. /**
  75139. * No animation will start.
  75140. */
  75141. NONE = 0,
  75142. /**
  75143. * The first animation will start.
  75144. */
  75145. FIRST = 1,
  75146. /**
  75147. * All animations will start.
  75148. */
  75149. ALL = 2
  75150. }
  75151. /**
  75152. * Interface that contains the data for the glTF asset.
  75153. */
  75154. export interface IGLTFLoaderData {
  75155. /**
  75156. * The object that represents the glTF JSON.
  75157. */
  75158. json: Object;
  75159. /**
  75160. * The BIN chunk of a binary glTF.
  75161. */
  75162. bin: Nullable<IDataBuffer>;
  75163. }
  75164. /**
  75165. * Interface for extending the loader.
  75166. */
  75167. export interface IGLTFLoaderExtension {
  75168. /**
  75169. * The name of this extension.
  75170. */
  75171. readonly name: string;
  75172. /**
  75173. * Defines whether this extension is enabled.
  75174. */
  75175. enabled: boolean;
  75176. /**
  75177. * Defines the order of this extension.
  75178. * The loader sorts the extensions using these values when loading.
  75179. */
  75180. order?: number;
  75181. }
  75182. /**
  75183. * Loader state.
  75184. */
  75185. export enum GLTFLoaderState {
  75186. /**
  75187. * The asset is loading.
  75188. */
  75189. LOADING = 0,
  75190. /**
  75191. * The asset is ready for rendering.
  75192. */
  75193. READY = 1,
  75194. /**
  75195. * The asset is completely loaded.
  75196. */
  75197. COMPLETE = 2
  75198. }
  75199. /** @hidden */
  75200. export interface IImportMeshAsyncOutput {
  75201. meshes: AbstractMesh[];
  75202. particleSystems: IParticleSystem[];
  75203. skeletons: Skeleton[];
  75204. animationGroups: AnimationGroup[];
  75205. lights: Light[];
  75206. transformNodes: TransformNode[];
  75207. }
  75208. /** @hidden */
  75209. export interface IGLTFLoader extends IDisposable {
  75210. readonly state: Nullable<GLTFLoaderState>;
  75211. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75212. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75213. }
  75214. /**
  75215. * File loader for loading glTF files into a scene.
  75216. */
  75217. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75218. /** @hidden */
  75219. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75220. /** @hidden */
  75221. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75222. /**
  75223. * Raised when the asset has been parsed
  75224. */
  75225. onParsedObservable: Observable<IGLTFLoaderData>;
  75226. private _onParsedObserver;
  75227. /**
  75228. * Raised when the asset has been parsed
  75229. */
  75230. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75231. /**
  75232. * 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.
  75233. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75234. * Defaults to true.
  75235. * @hidden
  75236. */
  75237. static IncrementalLoading: boolean;
  75238. /**
  75239. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75240. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75241. * @hidden
  75242. */
  75243. static HomogeneousCoordinates: boolean;
  75244. /**
  75245. * The coordinate system mode. Defaults to AUTO.
  75246. */
  75247. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75248. /**
  75249. * The animation start mode. Defaults to FIRST.
  75250. */
  75251. animationStartMode: GLTFLoaderAnimationStartMode;
  75252. /**
  75253. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75254. */
  75255. compileMaterials: boolean;
  75256. /**
  75257. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75258. */
  75259. useClipPlane: boolean;
  75260. /**
  75261. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75262. */
  75263. compileShadowGenerators: boolean;
  75264. /**
  75265. * Defines if the Alpha blended materials are only applied as coverage.
  75266. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75267. * If true, no extra effects are applied to transparent pixels.
  75268. */
  75269. transparencyAsCoverage: boolean;
  75270. /**
  75271. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75272. * Enabling will disable offline support and glTF validator.
  75273. * Defaults to false.
  75274. */
  75275. useRangeRequests: boolean;
  75276. /**
  75277. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75278. */
  75279. createInstances: boolean;
  75280. /**
  75281. * Function called before loading a url referenced by the asset.
  75282. */
  75283. preprocessUrlAsync: (url: string) => Promise<string>;
  75284. /**
  75285. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75286. */
  75287. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75288. private _onMeshLoadedObserver;
  75289. /**
  75290. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75291. */
  75292. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75293. /**
  75294. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75295. */
  75296. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75297. private _onTextureLoadedObserver;
  75298. /**
  75299. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75300. */
  75301. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75302. /**
  75303. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75304. */
  75305. readonly onMaterialLoadedObservable: Observable<Material>;
  75306. private _onMaterialLoadedObserver;
  75307. /**
  75308. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75309. */
  75310. set onMaterialLoaded(callback: (material: Material) => void);
  75311. /**
  75312. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75313. */
  75314. readonly onCameraLoadedObservable: Observable<Camera>;
  75315. private _onCameraLoadedObserver;
  75316. /**
  75317. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75318. */
  75319. set onCameraLoaded(callback: (camera: Camera) => void);
  75320. /**
  75321. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75322. * For assets with LODs, raised when all of the LODs are complete.
  75323. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75324. */
  75325. readonly onCompleteObservable: Observable<void>;
  75326. private _onCompleteObserver;
  75327. /**
  75328. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75329. * For assets with LODs, raised when all of the LODs are complete.
  75330. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75331. */
  75332. set onComplete(callback: () => void);
  75333. /**
  75334. * Observable raised when an error occurs.
  75335. */
  75336. readonly onErrorObservable: Observable<any>;
  75337. private _onErrorObserver;
  75338. /**
  75339. * Callback raised when an error occurs.
  75340. */
  75341. set onError(callback: (reason: any) => void);
  75342. /**
  75343. * Observable raised after the loader is disposed.
  75344. */
  75345. readonly onDisposeObservable: Observable<void>;
  75346. private _onDisposeObserver;
  75347. /**
  75348. * Callback raised after the loader is disposed.
  75349. */
  75350. set onDispose(callback: () => void);
  75351. /**
  75352. * Observable raised after a loader extension is created.
  75353. * Set additional options for a loader extension in this event.
  75354. */
  75355. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75356. private _onExtensionLoadedObserver;
  75357. /**
  75358. * Callback raised after a loader extension is created.
  75359. */
  75360. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75361. /**
  75362. * Defines if the loader logging is enabled.
  75363. */
  75364. get loggingEnabled(): boolean;
  75365. set loggingEnabled(value: boolean);
  75366. /**
  75367. * Defines if the loader should capture performance counters.
  75368. */
  75369. get capturePerformanceCounters(): boolean;
  75370. set capturePerformanceCounters(value: boolean);
  75371. /**
  75372. * Defines if the loader should validate the asset.
  75373. */
  75374. validate: boolean;
  75375. /**
  75376. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75377. */
  75378. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75379. private _onValidatedObserver;
  75380. /**
  75381. * Callback raised after a loader extension is created.
  75382. */
  75383. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75384. private _loader;
  75385. /**
  75386. * Name of the loader ("gltf")
  75387. */
  75388. name: string;
  75389. /** @hidden */
  75390. extensions: ISceneLoaderPluginExtensions;
  75391. /**
  75392. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75393. */
  75394. dispose(): void;
  75395. /** @hidden */
  75396. _clear(): void;
  75397. /** @hidden */
  75398. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75399. /** @hidden */
  75400. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75401. /** @hidden */
  75402. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75403. meshes: AbstractMesh[];
  75404. particleSystems: IParticleSystem[];
  75405. skeletons: Skeleton[];
  75406. animationGroups: AnimationGroup[];
  75407. }>;
  75408. /** @hidden */
  75409. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75410. /** @hidden */
  75411. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75412. /** @hidden */
  75413. canDirectLoad(data: string): boolean;
  75414. /** @hidden */
  75415. directLoad(scene: Scene, data: string): any;
  75416. /**
  75417. * The callback that allows custom handling of the root url based on the response url.
  75418. * @param rootUrl the original root url
  75419. * @param responseURL the response url if available
  75420. * @returns the new root url
  75421. */
  75422. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75423. /** @hidden */
  75424. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75425. /**
  75426. * The loader state or null if the loader is not active.
  75427. */
  75428. get loaderState(): Nullable<GLTFLoaderState>;
  75429. /**
  75430. * Returns a promise that resolves when the asset is completely loaded.
  75431. * @returns a promise that resolves when the asset is completely loaded.
  75432. */
  75433. whenCompleteAsync(): Promise<void>;
  75434. private _validate;
  75435. private _getLoader;
  75436. private _parseJson;
  75437. private _unpackBinaryAsync;
  75438. private _unpackBinaryV1Async;
  75439. private _unpackBinaryV2Async;
  75440. private static _parseVersion;
  75441. private static _compareVersion;
  75442. private static readonly _logSpaces;
  75443. private _logIndentLevel;
  75444. private _loggingEnabled;
  75445. /** @hidden */
  75446. _log: (message: string) => void;
  75447. /** @hidden */
  75448. _logOpen(message: string): void;
  75449. /** @hidden */
  75450. _logClose(): void;
  75451. private _logEnabled;
  75452. private _logDisabled;
  75453. private _capturePerformanceCounters;
  75454. /** @hidden */
  75455. _startPerformanceCounter: (counterName: string) => void;
  75456. /** @hidden */
  75457. _endPerformanceCounter: (counterName: string) => void;
  75458. private _startPerformanceCounterEnabled;
  75459. private _startPerformanceCounterDisabled;
  75460. private _endPerformanceCounterEnabled;
  75461. private _endPerformanceCounterDisabled;
  75462. }
  75463. }
  75464. declare module BABYLON.GLTF1 {
  75465. /**
  75466. * Enums
  75467. * @hidden
  75468. */
  75469. export enum EComponentType {
  75470. BYTE = 5120,
  75471. UNSIGNED_BYTE = 5121,
  75472. SHORT = 5122,
  75473. UNSIGNED_SHORT = 5123,
  75474. FLOAT = 5126
  75475. }
  75476. /** @hidden */
  75477. export enum EShaderType {
  75478. FRAGMENT = 35632,
  75479. VERTEX = 35633
  75480. }
  75481. /** @hidden */
  75482. export enum EParameterType {
  75483. BYTE = 5120,
  75484. UNSIGNED_BYTE = 5121,
  75485. SHORT = 5122,
  75486. UNSIGNED_SHORT = 5123,
  75487. INT = 5124,
  75488. UNSIGNED_INT = 5125,
  75489. FLOAT = 5126,
  75490. FLOAT_VEC2 = 35664,
  75491. FLOAT_VEC3 = 35665,
  75492. FLOAT_VEC4 = 35666,
  75493. INT_VEC2 = 35667,
  75494. INT_VEC3 = 35668,
  75495. INT_VEC4 = 35669,
  75496. BOOL = 35670,
  75497. BOOL_VEC2 = 35671,
  75498. BOOL_VEC3 = 35672,
  75499. BOOL_VEC4 = 35673,
  75500. FLOAT_MAT2 = 35674,
  75501. FLOAT_MAT3 = 35675,
  75502. FLOAT_MAT4 = 35676,
  75503. SAMPLER_2D = 35678
  75504. }
  75505. /** @hidden */
  75506. export enum ETextureWrapMode {
  75507. CLAMP_TO_EDGE = 33071,
  75508. MIRRORED_REPEAT = 33648,
  75509. REPEAT = 10497
  75510. }
  75511. /** @hidden */
  75512. export enum ETextureFilterType {
  75513. NEAREST = 9728,
  75514. LINEAR = 9728,
  75515. NEAREST_MIPMAP_NEAREST = 9984,
  75516. LINEAR_MIPMAP_NEAREST = 9985,
  75517. NEAREST_MIPMAP_LINEAR = 9986,
  75518. LINEAR_MIPMAP_LINEAR = 9987
  75519. }
  75520. /** @hidden */
  75521. export enum ETextureFormat {
  75522. ALPHA = 6406,
  75523. RGB = 6407,
  75524. RGBA = 6408,
  75525. LUMINANCE = 6409,
  75526. LUMINANCE_ALPHA = 6410
  75527. }
  75528. /** @hidden */
  75529. export enum ECullingType {
  75530. FRONT = 1028,
  75531. BACK = 1029,
  75532. FRONT_AND_BACK = 1032
  75533. }
  75534. /** @hidden */
  75535. export enum EBlendingFunction {
  75536. ZERO = 0,
  75537. ONE = 1,
  75538. SRC_COLOR = 768,
  75539. ONE_MINUS_SRC_COLOR = 769,
  75540. DST_COLOR = 774,
  75541. ONE_MINUS_DST_COLOR = 775,
  75542. SRC_ALPHA = 770,
  75543. ONE_MINUS_SRC_ALPHA = 771,
  75544. DST_ALPHA = 772,
  75545. ONE_MINUS_DST_ALPHA = 773,
  75546. CONSTANT_COLOR = 32769,
  75547. ONE_MINUS_CONSTANT_COLOR = 32770,
  75548. CONSTANT_ALPHA = 32771,
  75549. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75550. SRC_ALPHA_SATURATE = 776
  75551. }
  75552. /** @hidden */
  75553. export interface IGLTFProperty {
  75554. extensions?: {
  75555. [key: string]: any;
  75556. };
  75557. extras?: Object;
  75558. }
  75559. /** @hidden */
  75560. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75561. name?: string;
  75562. }
  75563. /** @hidden */
  75564. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75565. bufferView: string;
  75566. byteOffset: number;
  75567. byteStride: number;
  75568. count: number;
  75569. type: string;
  75570. componentType: EComponentType;
  75571. max?: number[];
  75572. min?: number[];
  75573. name?: string;
  75574. }
  75575. /** @hidden */
  75576. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75577. buffer: string;
  75578. byteOffset: number;
  75579. byteLength: number;
  75580. byteStride: number;
  75581. target?: number;
  75582. }
  75583. /** @hidden */
  75584. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75585. uri: string;
  75586. byteLength?: number;
  75587. type?: string;
  75588. }
  75589. /** @hidden */
  75590. export interface IGLTFShader extends IGLTFChildRootProperty {
  75591. uri: string;
  75592. type: EShaderType;
  75593. }
  75594. /** @hidden */
  75595. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75596. attributes: string[];
  75597. fragmentShader: string;
  75598. vertexShader: string;
  75599. }
  75600. /** @hidden */
  75601. export interface IGLTFTechniqueParameter {
  75602. type: number;
  75603. count?: number;
  75604. semantic?: string;
  75605. node?: string;
  75606. value?: number | boolean | string | Array<any>;
  75607. source?: string;
  75608. babylonValue?: any;
  75609. }
  75610. /** @hidden */
  75611. export interface IGLTFTechniqueCommonProfile {
  75612. lightingModel: string;
  75613. texcoordBindings: Object;
  75614. parameters?: Array<any>;
  75615. }
  75616. /** @hidden */
  75617. export interface IGLTFTechniqueStatesFunctions {
  75618. blendColor?: number[];
  75619. blendEquationSeparate?: number[];
  75620. blendFuncSeparate?: number[];
  75621. colorMask: boolean[];
  75622. cullFace: number[];
  75623. }
  75624. /** @hidden */
  75625. export interface IGLTFTechniqueStates {
  75626. enable: number[];
  75627. functions: IGLTFTechniqueStatesFunctions;
  75628. }
  75629. /** @hidden */
  75630. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75631. parameters: {
  75632. [key: string]: IGLTFTechniqueParameter;
  75633. };
  75634. program: string;
  75635. attributes: {
  75636. [key: string]: string;
  75637. };
  75638. uniforms: {
  75639. [key: string]: string;
  75640. };
  75641. states: IGLTFTechniqueStates;
  75642. }
  75643. /** @hidden */
  75644. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75645. technique?: string;
  75646. values: string[];
  75647. }
  75648. /** @hidden */
  75649. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75650. attributes: {
  75651. [key: string]: string;
  75652. };
  75653. indices: string;
  75654. material: string;
  75655. mode?: number;
  75656. }
  75657. /** @hidden */
  75658. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75659. primitives: IGLTFMeshPrimitive[];
  75660. }
  75661. /** @hidden */
  75662. export interface IGLTFImage extends IGLTFChildRootProperty {
  75663. uri: string;
  75664. }
  75665. /** @hidden */
  75666. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75667. magFilter?: number;
  75668. minFilter?: number;
  75669. wrapS?: number;
  75670. wrapT?: number;
  75671. }
  75672. /** @hidden */
  75673. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75674. sampler: string;
  75675. source: string;
  75676. format?: ETextureFormat;
  75677. internalFormat?: ETextureFormat;
  75678. target?: number;
  75679. type?: number;
  75680. babylonTexture?: Texture;
  75681. }
  75682. /** @hidden */
  75683. export interface IGLTFAmbienLight {
  75684. color?: number[];
  75685. }
  75686. /** @hidden */
  75687. export interface IGLTFDirectionalLight {
  75688. color?: number[];
  75689. }
  75690. /** @hidden */
  75691. export interface IGLTFPointLight {
  75692. color?: number[];
  75693. constantAttenuation?: number;
  75694. linearAttenuation?: number;
  75695. quadraticAttenuation?: number;
  75696. }
  75697. /** @hidden */
  75698. export interface IGLTFSpotLight {
  75699. color?: number[];
  75700. constantAttenuation?: number;
  75701. fallOfAngle?: number;
  75702. fallOffExponent?: number;
  75703. linearAttenuation?: number;
  75704. quadraticAttenuation?: number;
  75705. }
  75706. /** @hidden */
  75707. export interface IGLTFLight extends IGLTFChildRootProperty {
  75708. type: string;
  75709. }
  75710. /** @hidden */
  75711. export interface IGLTFCameraOrthographic {
  75712. xmag: number;
  75713. ymag: number;
  75714. zfar: number;
  75715. znear: number;
  75716. }
  75717. /** @hidden */
  75718. export interface IGLTFCameraPerspective {
  75719. aspectRatio: number;
  75720. yfov: number;
  75721. zfar: number;
  75722. znear: number;
  75723. }
  75724. /** @hidden */
  75725. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75726. type: string;
  75727. }
  75728. /** @hidden */
  75729. export interface IGLTFAnimationChannelTarget {
  75730. id: string;
  75731. path: string;
  75732. }
  75733. /** @hidden */
  75734. export interface IGLTFAnimationChannel {
  75735. sampler: string;
  75736. target: IGLTFAnimationChannelTarget;
  75737. }
  75738. /** @hidden */
  75739. export interface IGLTFAnimationSampler {
  75740. input: string;
  75741. output: string;
  75742. interpolation?: string;
  75743. }
  75744. /** @hidden */
  75745. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75746. channels?: IGLTFAnimationChannel[];
  75747. parameters?: {
  75748. [key: string]: string;
  75749. };
  75750. samplers?: {
  75751. [key: string]: IGLTFAnimationSampler;
  75752. };
  75753. }
  75754. /** @hidden */
  75755. export interface IGLTFNodeInstanceSkin {
  75756. skeletons: string[];
  75757. skin: string;
  75758. meshes: string[];
  75759. }
  75760. /** @hidden */
  75761. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75762. bindShapeMatrix: number[];
  75763. inverseBindMatrices: string;
  75764. jointNames: string[];
  75765. babylonSkeleton?: Skeleton;
  75766. }
  75767. /** @hidden */
  75768. export interface IGLTFNode extends IGLTFChildRootProperty {
  75769. camera?: string;
  75770. children: string[];
  75771. skin?: string;
  75772. jointName?: string;
  75773. light?: string;
  75774. matrix: number[];
  75775. mesh?: string;
  75776. meshes?: string[];
  75777. rotation?: number[];
  75778. scale?: number[];
  75779. translation?: number[];
  75780. babylonNode?: Node;
  75781. }
  75782. /** @hidden */
  75783. export interface IGLTFScene extends IGLTFChildRootProperty {
  75784. nodes: string[];
  75785. }
  75786. /** @hidden */
  75787. export interface IGLTFRuntime {
  75788. extensions: {
  75789. [key: string]: any;
  75790. };
  75791. accessors: {
  75792. [key: string]: IGLTFAccessor;
  75793. };
  75794. buffers: {
  75795. [key: string]: IGLTFBuffer;
  75796. };
  75797. bufferViews: {
  75798. [key: string]: IGLTFBufferView;
  75799. };
  75800. meshes: {
  75801. [key: string]: IGLTFMesh;
  75802. };
  75803. lights: {
  75804. [key: string]: IGLTFLight;
  75805. };
  75806. cameras: {
  75807. [key: string]: IGLTFCamera;
  75808. };
  75809. nodes: {
  75810. [key: string]: IGLTFNode;
  75811. };
  75812. images: {
  75813. [key: string]: IGLTFImage;
  75814. };
  75815. textures: {
  75816. [key: string]: IGLTFTexture;
  75817. };
  75818. shaders: {
  75819. [key: string]: IGLTFShader;
  75820. };
  75821. programs: {
  75822. [key: string]: IGLTFProgram;
  75823. };
  75824. samplers: {
  75825. [key: string]: IGLTFSampler;
  75826. };
  75827. techniques: {
  75828. [key: string]: IGLTFTechnique;
  75829. };
  75830. materials: {
  75831. [key: string]: IGLTFMaterial;
  75832. };
  75833. animations: {
  75834. [key: string]: IGLTFAnimation;
  75835. };
  75836. skins: {
  75837. [key: string]: IGLTFSkins;
  75838. };
  75839. currentScene?: Object;
  75840. scenes: {
  75841. [key: string]: IGLTFScene;
  75842. };
  75843. extensionsUsed: string[];
  75844. extensionsRequired?: string[];
  75845. buffersCount: number;
  75846. shaderscount: number;
  75847. scene: Scene;
  75848. rootUrl: string;
  75849. loadedBufferCount: number;
  75850. loadedBufferViews: {
  75851. [name: string]: ArrayBufferView;
  75852. };
  75853. loadedShaderCount: number;
  75854. importOnlyMeshes: boolean;
  75855. importMeshesNames?: string[];
  75856. dummyNodes: Node[];
  75857. forAssetContainer: boolean;
  75858. }
  75859. /** @hidden */
  75860. export interface INodeToRoot {
  75861. bone: Bone;
  75862. node: IGLTFNode;
  75863. id: string;
  75864. }
  75865. /** @hidden */
  75866. export interface IJointNode {
  75867. node: IGLTFNode;
  75868. id: string;
  75869. }
  75870. }
  75871. declare module BABYLON.GLTF1 {
  75872. /**
  75873. * Utils functions for GLTF
  75874. * @hidden
  75875. */
  75876. export class GLTFUtils {
  75877. /**
  75878. * Sets the given "parameter" matrix
  75879. * @param scene: the Scene object
  75880. * @param source: the source node where to pick the matrix
  75881. * @param parameter: the GLTF technique parameter
  75882. * @param uniformName: the name of the shader's uniform
  75883. * @param shaderMaterial: the shader material
  75884. */
  75885. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75886. /**
  75887. * Sets the given "parameter" matrix
  75888. * @param shaderMaterial: the shader material
  75889. * @param uniform: the name of the shader's uniform
  75890. * @param value: the value of the uniform
  75891. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75892. */
  75893. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75894. /**
  75895. * Returns the wrap mode of the texture
  75896. * @param mode: the mode value
  75897. */
  75898. static GetWrapMode(mode: number): number;
  75899. /**
  75900. * Returns the byte stride giving an accessor
  75901. * @param accessor: the GLTF accessor objet
  75902. */
  75903. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75904. /**
  75905. * Returns the texture filter mode giving a mode value
  75906. * @param mode: the filter mode value
  75907. */
  75908. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75909. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75910. /**
  75911. * Returns a buffer from its accessor
  75912. * @param gltfRuntime: the GLTF runtime
  75913. * @param accessor: the GLTF accessor
  75914. */
  75915. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75916. /**
  75917. * Decodes a buffer view into a string
  75918. * @param view: the buffer view
  75919. */
  75920. static DecodeBufferToText(view: ArrayBufferView): string;
  75921. /**
  75922. * Returns the default material of gltf. Related to
  75923. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75924. * @param scene: the Babylon.js scene
  75925. */
  75926. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75927. private static _DefaultMaterial;
  75928. }
  75929. }
  75930. declare module BABYLON.GLTF1 {
  75931. /**
  75932. * Implementation of the base glTF spec
  75933. * @hidden
  75934. */
  75935. export class GLTFLoaderBase {
  75936. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75937. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75938. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75939. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75940. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75941. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75942. }
  75943. /**
  75944. * glTF V1 Loader
  75945. * @hidden
  75946. */
  75947. export class GLTFLoader implements IGLTFLoader {
  75948. static Extensions: {
  75949. [name: string]: GLTFLoaderExtension;
  75950. };
  75951. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75952. state: Nullable<GLTFLoaderState>;
  75953. dispose(): void;
  75954. private _importMeshAsync;
  75955. /**
  75956. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75957. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75958. * @param scene the scene the meshes should be added to
  75959. * @param forAssetContainer defines if the entities must be stored in the scene
  75960. * @param data gltf data containing information of the meshes in a loaded file
  75961. * @param rootUrl root url to load from
  75962. * @param onProgress event that fires when loading progress has occured
  75963. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75964. */
  75965. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75966. private _loadAsync;
  75967. /**
  75968. * Imports all objects from a loaded gltf file and adds them to the scene
  75969. * @param scene the scene the objects should be added to
  75970. * @param data gltf data containing information of the meshes in a loaded file
  75971. * @param rootUrl root url to load from
  75972. * @param onProgress event that fires when loading progress has occured
  75973. * @returns a promise which completes when objects have been loaded to the scene
  75974. */
  75975. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75976. private _loadShadersAsync;
  75977. private _loadBuffersAsync;
  75978. private _createNodes;
  75979. }
  75980. /** @hidden */
  75981. export abstract class GLTFLoaderExtension {
  75982. private _name;
  75983. constructor(name: string);
  75984. get name(): string;
  75985. /**
  75986. * Defines an override for loading the runtime
  75987. * Return true to stop further extensions from loading the runtime
  75988. */
  75989. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75990. /**
  75991. * Defines an onverride for creating gltf runtime
  75992. * Return true to stop further extensions from creating the runtime
  75993. */
  75994. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75995. /**
  75996. * Defines an override for loading buffers
  75997. * Return true to stop further extensions from loading this buffer
  75998. */
  75999. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76000. /**
  76001. * Defines an override for loading texture buffers
  76002. * Return true to stop further extensions from loading this texture data
  76003. */
  76004. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76005. /**
  76006. * Defines an override for creating textures
  76007. * Return true to stop further extensions from loading this texture
  76008. */
  76009. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76010. /**
  76011. * Defines an override for loading shader strings
  76012. * Return true to stop further extensions from loading this shader data
  76013. */
  76014. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76015. /**
  76016. * Defines an override for loading materials
  76017. * Return true to stop further extensions from loading this material
  76018. */
  76019. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76020. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76021. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76022. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76023. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76024. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76025. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76026. private static LoadTextureBufferAsync;
  76027. private static CreateTextureAsync;
  76028. private static ApplyExtensions;
  76029. }
  76030. }
  76031. declare module BABYLON.GLTF1 {
  76032. /** @hidden */
  76033. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76034. private _bin;
  76035. constructor();
  76036. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76037. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76038. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76039. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76040. }
  76041. }
  76042. declare module BABYLON.GLTF1 {
  76043. /** @hidden */
  76044. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76045. constructor();
  76046. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76047. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76048. private _loadTexture;
  76049. }
  76050. }
  76051. declare module BABYLON.GLTF2.Loader {
  76052. /**
  76053. * Loader interface with an index field.
  76054. */
  76055. export interface IArrayItem {
  76056. /**
  76057. * The index of this item in the array.
  76058. */
  76059. index: number;
  76060. }
  76061. /**
  76062. * Loader interface with additional members.
  76063. */
  76064. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76065. /** @hidden */
  76066. _data?: Promise<ArrayBufferView>;
  76067. /** @hidden */
  76068. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76069. }
  76070. /**
  76071. * Loader interface with additional members.
  76072. */
  76073. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76074. }
  76075. /** @hidden */
  76076. export interface _IAnimationSamplerData {
  76077. input: Float32Array;
  76078. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76079. output: Float32Array;
  76080. }
  76081. /**
  76082. * Loader interface with additional members.
  76083. */
  76084. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76085. /** @hidden */
  76086. _data?: Promise<_IAnimationSamplerData>;
  76087. }
  76088. /**
  76089. * Loader interface with additional members.
  76090. */
  76091. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76092. channels: IAnimationChannel[];
  76093. samplers: IAnimationSampler[];
  76094. /** @hidden */
  76095. _babylonAnimationGroup?: AnimationGroup;
  76096. }
  76097. /**
  76098. * Loader interface with additional members.
  76099. */
  76100. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76101. /** @hidden */
  76102. _data?: Promise<ArrayBufferView>;
  76103. }
  76104. /**
  76105. * Loader interface with additional members.
  76106. */
  76107. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76108. /** @hidden */
  76109. _data?: Promise<ArrayBufferView>;
  76110. /** @hidden */
  76111. _babylonBuffer?: Promise<Buffer>;
  76112. }
  76113. /**
  76114. * Loader interface with additional members.
  76115. */
  76116. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76117. }
  76118. /**
  76119. * Loader interface with additional members.
  76120. */
  76121. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76122. /** @hidden */
  76123. _data?: Promise<ArrayBufferView>;
  76124. }
  76125. /**
  76126. * Loader interface with additional members.
  76127. */
  76128. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76129. }
  76130. /**
  76131. * Loader interface with additional members.
  76132. */
  76133. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76134. }
  76135. /**
  76136. * Loader interface with additional members.
  76137. */
  76138. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76139. baseColorTexture?: ITextureInfo;
  76140. metallicRoughnessTexture?: ITextureInfo;
  76141. }
  76142. /**
  76143. * Loader interface with additional members.
  76144. */
  76145. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76146. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76147. normalTexture?: IMaterialNormalTextureInfo;
  76148. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76149. emissiveTexture?: ITextureInfo;
  76150. /** @hidden */
  76151. _data?: {
  76152. [babylonDrawMode: number]: {
  76153. babylonMaterial: Material;
  76154. babylonMeshes: AbstractMesh[];
  76155. promise: Promise<void>;
  76156. };
  76157. };
  76158. }
  76159. /**
  76160. * Loader interface with additional members.
  76161. */
  76162. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76163. primitives: IMeshPrimitive[];
  76164. }
  76165. /**
  76166. * Loader interface with additional members.
  76167. */
  76168. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76169. /** @hidden */
  76170. _instanceData?: {
  76171. babylonSourceMesh: Mesh;
  76172. promise: Promise<any>;
  76173. };
  76174. }
  76175. /**
  76176. * Loader interface with additional members.
  76177. */
  76178. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76179. /**
  76180. * The parent glTF node.
  76181. */
  76182. parent?: INode;
  76183. /** @hidden */
  76184. _babylonTransformNode?: TransformNode;
  76185. /** @hidden */
  76186. _primitiveBabylonMeshes?: AbstractMesh[];
  76187. /** @hidden */
  76188. _babylonBones?: Bone[];
  76189. /** @hidden */
  76190. _numMorphTargets?: number;
  76191. }
  76192. /** @hidden */
  76193. export interface _ISamplerData {
  76194. noMipMaps: boolean;
  76195. samplingMode: number;
  76196. wrapU: number;
  76197. wrapV: number;
  76198. }
  76199. /**
  76200. * Loader interface with additional members.
  76201. */
  76202. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76203. /** @hidden */
  76204. _data?: _ISamplerData;
  76205. }
  76206. /**
  76207. * Loader interface with additional members.
  76208. */
  76209. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76210. }
  76211. /**
  76212. * Loader interface with additional members.
  76213. */
  76214. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76215. /** @hidden */
  76216. _data?: {
  76217. babylonSkeleton: Skeleton;
  76218. promise: Promise<void>;
  76219. };
  76220. }
  76221. /**
  76222. * Loader interface with additional members.
  76223. */
  76224. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76225. }
  76226. /**
  76227. * Loader interface with additional members.
  76228. */
  76229. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76230. }
  76231. /**
  76232. * Loader interface with additional members.
  76233. */
  76234. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76235. accessors?: IAccessor[];
  76236. animations?: IAnimation[];
  76237. buffers?: IBuffer[];
  76238. bufferViews?: IBufferView[];
  76239. cameras?: ICamera[];
  76240. images?: IImage[];
  76241. materials?: IMaterial[];
  76242. meshes?: IMesh[];
  76243. nodes?: INode[];
  76244. samplers?: ISampler[];
  76245. scenes?: IScene[];
  76246. skins?: ISkin[];
  76247. textures?: ITexture[];
  76248. }
  76249. }
  76250. declare module BABYLON.GLTF2 {
  76251. /**
  76252. * Interface for a glTF loader extension.
  76253. */
  76254. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76255. /**
  76256. * Called after the loader state changes to LOADING.
  76257. */
  76258. onLoading?(): void;
  76259. /**
  76260. * Called after the loader state changes to READY.
  76261. */
  76262. onReady?(): void;
  76263. /**
  76264. * Define this method to modify the default behavior when loading scenes.
  76265. * @param context The context when loading the asset
  76266. * @param scene The glTF scene property
  76267. * @returns A promise that resolves when the load is complete or null if not handled
  76268. */
  76269. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76270. /**
  76271. * Define this method to modify the default behavior when loading nodes.
  76272. * @param context The context when loading the asset
  76273. * @param node The glTF node property
  76274. * @param assign A function called synchronously after parsing the glTF properties
  76275. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76276. */
  76277. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76278. /**
  76279. * Define this method to modify the default behavior when loading cameras.
  76280. * @param context The context when loading the asset
  76281. * @param camera The glTF camera property
  76282. * @param assign A function called synchronously after parsing the glTF properties
  76283. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76284. */
  76285. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76286. /**
  76287. * @hidden
  76288. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76289. * @param context The context when loading the asset
  76290. * @param primitive The glTF mesh primitive property
  76291. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76292. */
  76293. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76294. /**
  76295. * @hidden
  76296. * Define this method to modify the default behavior when loading data for mesh primitives.
  76297. * @param context The context when loading the asset
  76298. * @param name The mesh name when loading the asset
  76299. * @param node The glTF node when loading the asset
  76300. * @param mesh The glTF mesh when loading the asset
  76301. * @param primitive The glTF mesh primitive property
  76302. * @param assign A function called synchronously after parsing the glTF properties
  76303. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76304. */
  76305. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76306. /**
  76307. * @hidden
  76308. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76309. * @param context The context when loading the asset
  76310. * @param material The glTF material property
  76311. * @param assign A function called synchronously after parsing the glTF properties
  76312. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76313. */
  76314. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76315. /**
  76316. * Define this method to modify the default behavior when creating materials.
  76317. * @param context The context when loading the asset
  76318. * @param material The glTF material property
  76319. * @param babylonDrawMode The draw mode for the Babylon material
  76320. * @returns The Babylon material or null if not handled
  76321. */
  76322. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76323. /**
  76324. * Define this method to modify the default behavior when loading material properties.
  76325. * @param context The context when loading the asset
  76326. * @param material The glTF material property
  76327. * @param babylonMaterial The Babylon material
  76328. * @returns A promise that resolves when the load is complete or null if not handled
  76329. */
  76330. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76331. /**
  76332. * Define this method to modify the default behavior when loading texture infos.
  76333. * @param context The context when loading the asset
  76334. * @param textureInfo The glTF texture info property
  76335. * @param assign A function called synchronously after parsing the glTF properties
  76336. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76337. */
  76338. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76339. /**
  76340. * @hidden
  76341. * Define this method to modify the default behavior when loading textures.
  76342. * @param context The context when loading the asset
  76343. * @param texture The glTF texture property
  76344. * @param assign A function called synchronously after parsing the glTF properties
  76345. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76346. */
  76347. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76348. /**
  76349. * Define this method to modify the default behavior when loading animations.
  76350. * @param context The context when loading the asset
  76351. * @param animation The glTF animation property
  76352. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76353. */
  76354. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76355. /**
  76356. * @hidden
  76357. * Define this method to modify the default behavior when loading skins.
  76358. * @param context The context when loading the asset
  76359. * @param node The glTF node property
  76360. * @param skin The glTF skin property
  76361. * @returns A promise that resolves when the load is complete or null if not handled
  76362. */
  76363. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76364. /**
  76365. * @hidden
  76366. * Define this method to modify the default behavior when loading uris.
  76367. * @param context The context when loading the asset
  76368. * @param property The glTF property associated with the uri
  76369. * @param uri The uri to load
  76370. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76371. */
  76372. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76373. /**
  76374. * Define this method to modify the default behavior when loading buffer views.
  76375. * @param context The context when loading the asset
  76376. * @param bufferView The glTF buffer view property
  76377. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76378. */
  76379. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76380. /**
  76381. * Define this method to modify the default behavior when loading buffers.
  76382. * @param context The context when loading the asset
  76383. * @param buffer The glTF buffer property
  76384. * @param byteOffset The byte offset to load
  76385. * @param byteLength The byte length to load
  76386. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76387. */
  76388. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76389. }
  76390. }
  76391. declare module BABYLON.GLTF2 {
  76392. /**
  76393. * Helper class for working with arrays when loading the glTF asset
  76394. */
  76395. export class ArrayItem {
  76396. /**
  76397. * Gets an item from the given array.
  76398. * @param context The context when loading the asset
  76399. * @param array The array to get the item from
  76400. * @param index The index to the array
  76401. * @returns The array item
  76402. */
  76403. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76404. /**
  76405. * Assign an `index` field to each item of the given array.
  76406. * @param array The array of items
  76407. */
  76408. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76409. }
  76410. /**
  76411. * The glTF 2.0 loader
  76412. */
  76413. export class GLTFLoader implements IGLTFLoader {
  76414. /** @hidden */
  76415. _completePromises: Promise<any>[];
  76416. /** @hidden */
  76417. _forAssetContainer: boolean;
  76418. /** Storage */
  76419. _babylonLights: Light[];
  76420. private _disposed;
  76421. private _parent;
  76422. private _state;
  76423. private _extensions;
  76424. private _rootUrl;
  76425. private _fileName;
  76426. private _uniqueRootUrl;
  76427. private _gltf;
  76428. private _bin;
  76429. private _babylonScene;
  76430. private _rootBabylonMesh;
  76431. private _defaultBabylonMaterialData;
  76432. private _progressCallback?;
  76433. private _requests;
  76434. private static _RegisteredExtensions;
  76435. /**
  76436. * The default glTF sampler.
  76437. */
  76438. static readonly DefaultSampler: ISampler;
  76439. /**
  76440. * Registers a loader extension.
  76441. * @param name The name of the loader extension.
  76442. * @param factory The factory function that creates the loader extension.
  76443. */
  76444. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76445. /**
  76446. * Unregisters a loader extension.
  76447. * @param name The name of the loader extension.
  76448. * @returns A boolean indicating whether the extension has been unregistered
  76449. */
  76450. static UnregisterExtension(name: string): boolean;
  76451. /**
  76452. * The loader state.
  76453. */
  76454. get state(): Nullable<GLTFLoaderState>;
  76455. /**
  76456. * The object that represents the glTF JSON.
  76457. */
  76458. get gltf(): IGLTF;
  76459. /**
  76460. * The BIN chunk of a binary glTF.
  76461. */
  76462. get bin(): Nullable<IDataBuffer>;
  76463. /**
  76464. * The parent file loader.
  76465. */
  76466. get parent(): GLTFFileLoader;
  76467. /**
  76468. * The Babylon scene when loading the asset.
  76469. */
  76470. get babylonScene(): Scene;
  76471. /**
  76472. * The root Babylon mesh when loading the asset.
  76473. */
  76474. get rootBabylonMesh(): Mesh;
  76475. /** @hidden */
  76476. constructor(parent: GLTFFileLoader);
  76477. /** @hidden */
  76478. dispose(): void;
  76479. /** @hidden */
  76480. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76481. /** @hidden */
  76482. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76483. private _loadAsync;
  76484. private _loadData;
  76485. private _setupData;
  76486. private _loadExtensions;
  76487. private _checkExtensions;
  76488. private _setState;
  76489. private _createRootNode;
  76490. /**
  76491. * Loads a glTF scene.
  76492. * @param context The context when loading the asset
  76493. * @param scene The glTF scene property
  76494. * @returns A promise that resolves when the load is complete
  76495. */
  76496. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76497. private _forEachPrimitive;
  76498. private _getMeshes;
  76499. private _getTransformNodes;
  76500. private _getSkeletons;
  76501. private _getAnimationGroups;
  76502. private _startAnimations;
  76503. /**
  76504. * Loads a glTF node.
  76505. * @param context The context when loading the asset
  76506. * @param node The glTF node property
  76507. * @param assign A function called synchronously after parsing the glTF properties
  76508. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76509. */
  76510. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76511. private _loadMeshAsync;
  76512. /**
  76513. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76514. * @param context The context when loading the asset
  76515. * @param name The mesh name when loading the asset
  76516. * @param node The glTF node when loading the asset
  76517. * @param mesh The glTF mesh when loading the asset
  76518. * @param primitive The glTF mesh primitive property
  76519. * @param assign A function called synchronously after parsing the glTF properties
  76520. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76521. */
  76522. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76523. private _loadVertexDataAsync;
  76524. private _createMorphTargets;
  76525. private _loadMorphTargetsAsync;
  76526. private _loadMorphTargetVertexDataAsync;
  76527. private static _LoadTransform;
  76528. private _loadSkinAsync;
  76529. private _loadBones;
  76530. private _loadBone;
  76531. private _loadSkinInverseBindMatricesDataAsync;
  76532. private _updateBoneMatrices;
  76533. private _getNodeMatrix;
  76534. /**
  76535. * Loads a glTF camera.
  76536. * @param context The context when loading the asset
  76537. * @param camera The glTF camera property
  76538. * @param assign A function called synchronously after parsing the glTF properties
  76539. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76540. */
  76541. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76542. private _loadAnimationsAsync;
  76543. /**
  76544. * Loads a glTF animation.
  76545. * @param context The context when loading the asset
  76546. * @param animation The glTF animation property
  76547. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76548. */
  76549. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76550. /**
  76551. * @hidden Loads a glTF animation channel.
  76552. * @param context The context when loading the asset
  76553. * @param animationContext The context of the animation when loading the asset
  76554. * @param animation The glTF animation property
  76555. * @param channel The glTF animation channel property
  76556. * @param babylonAnimationGroup The babylon animation group property
  76557. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76558. * @returns A void promise when the channel load is complete
  76559. */
  76560. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76561. private _loadAnimationSamplerAsync;
  76562. private _loadBufferAsync;
  76563. /**
  76564. * Loads a glTF buffer view.
  76565. * @param context The context when loading the asset
  76566. * @param bufferView The glTF buffer view property
  76567. * @returns A promise that resolves with the loaded data when the load is complete
  76568. */
  76569. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76570. private _loadAccessorAsync;
  76571. /** @hidden */
  76572. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76573. private _loadIndicesAccessorAsync;
  76574. private _loadVertexBufferViewAsync;
  76575. private _loadVertexAccessorAsync;
  76576. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76577. /** @hidden */
  76578. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76579. private _createDefaultMaterial;
  76580. /**
  76581. * Creates a Babylon material from a glTF material.
  76582. * @param context The context when loading the asset
  76583. * @param material The glTF material property
  76584. * @param babylonDrawMode The draw mode for the Babylon material
  76585. * @returns The Babylon material
  76586. */
  76587. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76588. /**
  76589. * Loads properties from a glTF material into a Babylon material.
  76590. * @param context The context when loading the asset
  76591. * @param material The glTF material property
  76592. * @param babylonMaterial The Babylon material
  76593. * @returns A promise that resolves when the load is complete
  76594. */
  76595. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76596. /**
  76597. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76598. * @param context The context when loading the asset
  76599. * @param material The glTF material property
  76600. * @param babylonMaterial The Babylon material
  76601. * @returns A promise that resolves when the load is complete
  76602. */
  76603. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76604. /**
  76605. * Loads the alpha properties from a glTF material into a Babylon material.
  76606. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76607. * @param context The context when loading the asset
  76608. * @param material The glTF material property
  76609. * @param babylonMaterial The Babylon material
  76610. */
  76611. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76612. /**
  76613. * Loads a glTF texture info.
  76614. * @param context The context when loading the asset
  76615. * @param textureInfo The glTF texture info property
  76616. * @param assign A function called synchronously after parsing the glTF properties
  76617. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76618. */
  76619. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76620. /** @hidden */
  76621. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76622. /** @hidden */
  76623. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76624. private _loadSampler;
  76625. /**
  76626. * Loads a glTF image.
  76627. * @param context The context when loading the asset
  76628. * @param image The glTF image property
  76629. * @returns A promise that resolves with the loaded data when the load is complete
  76630. */
  76631. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76632. /**
  76633. * Loads a glTF uri.
  76634. * @param context The context when loading the asset
  76635. * @param property The glTF property associated with the uri
  76636. * @param uri The base64 or relative uri
  76637. * @returns A promise that resolves with the loaded data when the load is complete
  76638. */
  76639. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76640. private _onProgress;
  76641. /**
  76642. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76643. * @param babylonObject the Babylon object with metadata
  76644. * @param pointer the JSON pointer
  76645. */
  76646. static AddPointerMetadata(babylonObject: {
  76647. metadata: any;
  76648. }, pointer: string): void;
  76649. private static _GetTextureWrapMode;
  76650. private static _GetTextureSamplingMode;
  76651. private static _GetTypedArrayConstructor;
  76652. private static _GetTypedArray;
  76653. private static _GetNumComponents;
  76654. private static _ValidateUri;
  76655. private static _GetDrawMode;
  76656. private _compileMaterialsAsync;
  76657. private _compileShadowGeneratorsAsync;
  76658. private _forEachExtensions;
  76659. private _applyExtensions;
  76660. private _extensionsOnLoading;
  76661. private _extensionsOnReady;
  76662. private _extensionsLoadSceneAsync;
  76663. private _extensionsLoadNodeAsync;
  76664. private _extensionsLoadCameraAsync;
  76665. private _extensionsLoadVertexDataAsync;
  76666. private _extensionsLoadMeshPrimitiveAsync;
  76667. private _extensionsLoadMaterialAsync;
  76668. private _extensionsCreateMaterial;
  76669. private _extensionsLoadMaterialPropertiesAsync;
  76670. private _extensionsLoadTextureInfoAsync;
  76671. private _extensionsLoadTextureAsync;
  76672. private _extensionsLoadAnimationAsync;
  76673. private _extensionsLoadSkinAsync;
  76674. private _extensionsLoadUriAsync;
  76675. private _extensionsLoadBufferViewAsync;
  76676. private _extensionsLoadBufferAsync;
  76677. /**
  76678. * Helper method called by a loader extension to load an glTF extension.
  76679. * @param context The context when loading the asset
  76680. * @param property The glTF property to load the extension from
  76681. * @param extensionName The name of the extension to load
  76682. * @param actionAsync The action to run
  76683. * @returns The promise returned by actionAsync or null if the extension does not exist
  76684. */
  76685. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76686. /**
  76687. * Helper method called by a loader extension to load a glTF extra.
  76688. * @param context The context when loading the asset
  76689. * @param property The glTF property to load the extra from
  76690. * @param extensionName The name of the extension to load
  76691. * @param actionAsync The action to run
  76692. * @returns The promise returned by actionAsync or null if the extra does not exist
  76693. */
  76694. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76695. /**
  76696. * Checks for presence of an extension.
  76697. * @param name The name of the extension to check
  76698. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76699. */
  76700. isExtensionUsed(name: string): boolean;
  76701. /**
  76702. * Increments the indentation level and logs a message.
  76703. * @param message The message to log
  76704. */
  76705. logOpen(message: string): void;
  76706. /**
  76707. * Decrements the indentation level.
  76708. */
  76709. logClose(): void;
  76710. /**
  76711. * Logs a message
  76712. * @param message The message to log
  76713. */
  76714. log(message: string): void;
  76715. /**
  76716. * Starts a performance counter.
  76717. * @param counterName The name of the performance counter
  76718. */
  76719. startPerformanceCounter(counterName: string): void;
  76720. /**
  76721. * Ends a performance counter.
  76722. * @param counterName The name of the performance counter
  76723. */
  76724. endPerformanceCounter(counterName: string): void;
  76725. }
  76726. }
  76727. declare module BABYLON.GLTF2.Loader.Extensions {
  76728. /**
  76729. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76730. */
  76731. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76732. /**
  76733. * The name of this extension.
  76734. */
  76735. readonly name: string;
  76736. /**
  76737. * Defines whether this extension is enabled.
  76738. */
  76739. enabled: boolean;
  76740. private _loader;
  76741. private _lights?;
  76742. /** @hidden */
  76743. constructor(loader: GLTFLoader);
  76744. /** @hidden */
  76745. dispose(): void;
  76746. /** @hidden */
  76747. onLoading(): void;
  76748. /** @hidden */
  76749. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76750. private _loadLightAsync;
  76751. }
  76752. }
  76753. declare module BABYLON.GLTF2.Loader.Extensions {
  76754. /**
  76755. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76756. */
  76757. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76758. /**
  76759. * The name of this extension.
  76760. */
  76761. readonly name: string;
  76762. /**
  76763. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76764. */
  76765. dracoCompression?: DracoCompression;
  76766. /**
  76767. * Defines whether this extension is enabled.
  76768. */
  76769. enabled: boolean;
  76770. private _loader;
  76771. /** @hidden */
  76772. constructor(loader: GLTFLoader);
  76773. /** @hidden */
  76774. dispose(): void;
  76775. /** @hidden */
  76776. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76777. }
  76778. }
  76779. declare module BABYLON.GLTF2.Loader.Extensions {
  76780. /**
  76781. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76782. */
  76783. export class KHR_lights implements IGLTFLoaderExtension {
  76784. /**
  76785. * The name of this extension.
  76786. */
  76787. readonly name: string;
  76788. /**
  76789. * Defines whether this extension is enabled.
  76790. */
  76791. enabled: boolean;
  76792. private _loader;
  76793. private _lights?;
  76794. /** @hidden */
  76795. constructor(loader: GLTFLoader);
  76796. /** @hidden */
  76797. dispose(): void;
  76798. /** @hidden */
  76799. onLoading(): void;
  76800. /** @hidden */
  76801. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76802. }
  76803. }
  76804. declare module BABYLON.GLTF2.Loader.Extensions {
  76805. /**
  76806. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76807. */
  76808. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76809. /**
  76810. * The name of this extension.
  76811. */
  76812. readonly name: string;
  76813. /**
  76814. * Defines whether this extension is enabled.
  76815. */
  76816. enabled: boolean;
  76817. /**
  76818. * Defines a number that determines the order the extensions are applied.
  76819. */
  76820. order: number;
  76821. private _loader;
  76822. /** @hidden */
  76823. constructor(loader: GLTFLoader);
  76824. /** @hidden */
  76825. dispose(): void;
  76826. /** @hidden */
  76827. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76828. private _loadSpecularGlossinessPropertiesAsync;
  76829. }
  76830. }
  76831. declare module BABYLON.GLTF2.Loader.Extensions {
  76832. /**
  76833. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76834. */
  76835. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76836. /**
  76837. * The name of this extension.
  76838. */
  76839. readonly name: string;
  76840. /**
  76841. * Defines whether this extension is enabled.
  76842. */
  76843. enabled: boolean;
  76844. /**
  76845. * Defines a number that determines the order the extensions are applied.
  76846. */
  76847. order: number;
  76848. private _loader;
  76849. /** @hidden */
  76850. constructor(loader: GLTFLoader);
  76851. /** @hidden */
  76852. dispose(): void;
  76853. /** @hidden */
  76854. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76855. private _loadUnlitPropertiesAsync;
  76856. }
  76857. }
  76858. declare module BABYLON.GLTF2.Loader.Extensions {
  76859. /**
  76860. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76861. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76862. * !!! Experimental Extension Subject to Changes !!!
  76863. */
  76864. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76865. /**
  76866. * The name of this extension.
  76867. */
  76868. readonly name: string;
  76869. /**
  76870. * Defines whether this extension is enabled.
  76871. */
  76872. enabled: boolean;
  76873. /**
  76874. * Defines a number that determines the order the extensions are applied.
  76875. */
  76876. order: number;
  76877. private _loader;
  76878. /** @hidden */
  76879. constructor(loader: GLTFLoader);
  76880. /** @hidden */
  76881. dispose(): void;
  76882. /** @hidden */
  76883. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76884. private _loadClearCoatPropertiesAsync;
  76885. }
  76886. }
  76887. declare module BABYLON.GLTF2.Loader.Extensions {
  76888. /**
  76889. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76890. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76891. * !!! Experimental Extension Subject to Changes !!!
  76892. */
  76893. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76894. /**
  76895. * The name of this extension.
  76896. */
  76897. readonly name: string;
  76898. /**
  76899. * Defines whether this extension is enabled.
  76900. */
  76901. enabled: boolean;
  76902. /**
  76903. * Defines a number that determines the order the extensions are applied.
  76904. */
  76905. order: number;
  76906. private _loader;
  76907. /** @hidden */
  76908. constructor(loader: GLTFLoader);
  76909. /** @hidden */
  76910. dispose(): void;
  76911. /** @hidden */
  76912. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76913. private _loadSheenPropertiesAsync;
  76914. }
  76915. }
  76916. declare module BABYLON.GLTF2.Loader.Extensions {
  76917. /**
  76918. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76919. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76920. * !!! Experimental Extension Subject to Changes !!!
  76921. */
  76922. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76923. /**
  76924. * The name of this extension.
  76925. */
  76926. readonly name: string;
  76927. /**
  76928. * Defines whether this extension is enabled.
  76929. */
  76930. enabled: boolean;
  76931. /**
  76932. * Defines a number that determines the order the extensions are applied.
  76933. */
  76934. order: number;
  76935. private _loader;
  76936. /** @hidden */
  76937. constructor(loader: GLTFLoader);
  76938. /** @hidden */
  76939. dispose(): void;
  76940. /** @hidden */
  76941. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76942. private _loadSpecularPropertiesAsync;
  76943. }
  76944. }
  76945. declare module BABYLON.GLTF2.Loader.Extensions {
  76946. /**
  76947. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76948. * [Playground Sample](//TODO)
  76949. * !!! Experimental Extension Subject to Changes !!!
  76950. */
  76951. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76952. /**
  76953. * The name of this extension.
  76954. */
  76955. readonly name: string;
  76956. /**
  76957. * Defines whether this extension is enabled.
  76958. */
  76959. enabled: boolean;
  76960. private _loader;
  76961. /** @hidden */
  76962. constructor(loader: GLTFLoader);
  76963. /** @hidden */
  76964. dispose(): void;
  76965. /** @hidden */
  76966. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76967. }
  76968. }
  76969. declare module BABYLON.GLTF2.Loader.Extensions {
  76970. /**
  76971. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76972. */
  76973. export class KHR_mesh_quantization 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. /** @hidden */
  76983. constructor(loader: GLTFLoader);
  76984. /** @hidden */
  76985. dispose(): void;
  76986. }
  76987. }
  76988. declare module BABYLON.GLTF2.Loader.Extensions {
  76989. /**
  76990. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76991. * !!! Experimental Extension Subject to Changes !!!
  76992. */
  76993. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  76994. /** The name of this extension. */
  76995. readonly name: string;
  76996. /** Defines whether this extension is enabled. */
  76997. enabled: boolean;
  76998. private _loader;
  76999. /** @hidden */
  77000. constructor(loader: GLTFLoader);
  77001. /** @hidden */
  77002. dispose(): void;
  77003. /** @hidden */
  77004. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77005. }
  77006. }
  77007. declare module BABYLON.GLTF2.Loader.Extensions {
  77008. /**
  77009. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77010. */
  77011. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77012. /**
  77013. * The name of this extension.
  77014. */
  77015. readonly name: string;
  77016. /**
  77017. * Defines whether this extension is enabled.
  77018. */
  77019. enabled: boolean;
  77020. private _loader;
  77021. /** @hidden */
  77022. constructor(loader: GLTFLoader);
  77023. /** @hidden */
  77024. dispose(): void;
  77025. /** @hidden */
  77026. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77027. }
  77028. }
  77029. declare module BABYLON.GLTF2.Loader.Extensions {
  77030. /**
  77031. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77032. */
  77033. export class MSFT_audio_emitter 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. private _clips;
  77044. private _emitters;
  77045. /** @hidden */
  77046. constructor(loader: GLTFLoader);
  77047. /** @hidden */
  77048. dispose(): void;
  77049. /** @hidden */
  77050. onLoading(): void;
  77051. /** @hidden */
  77052. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77053. /** @hidden */
  77054. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77055. /** @hidden */
  77056. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77057. private _loadClipAsync;
  77058. private _loadEmitterAsync;
  77059. private _getEventAction;
  77060. private _loadAnimationEventAsync;
  77061. }
  77062. }
  77063. declare module BABYLON.GLTF2.Loader.Extensions {
  77064. /**
  77065. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77066. */
  77067. export class MSFT_lod implements IGLTFLoaderExtension {
  77068. /**
  77069. * The name of this extension.
  77070. */
  77071. readonly name: string;
  77072. /**
  77073. * Defines whether this extension is enabled.
  77074. */
  77075. enabled: boolean;
  77076. /**
  77077. * Defines a number that determines the order the extensions are applied.
  77078. */
  77079. order: number;
  77080. /**
  77081. * Maximum number of LODs to load, starting from the lowest LOD.
  77082. */
  77083. maxLODsToLoad: number;
  77084. /**
  77085. * Observable raised when all node LODs of one level are loaded.
  77086. * The event data is the index of the loaded LOD starting from zero.
  77087. * Dispose the loader to cancel the loading of the next level of LODs.
  77088. */
  77089. onNodeLODsLoadedObservable: Observable<number>;
  77090. /**
  77091. * Observable raised when all material LODs of one level are loaded.
  77092. * The event data is the index of the loaded LOD starting from zero.
  77093. * Dispose the loader to cancel the loading of the next level of LODs.
  77094. */
  77095. onMaterialLODsLoadedObservable: Observable<number>;
  77096. private _loader;
  77097. private _nodeIndexLOD;
  77098. private _nodeSignalLODs;
  77099. private _nodePromiseLODs;
  77100. private _materialIndexLOD;
  77101. private _materialSignalLODs;
  77102. private _materialPromiseLODs;
  77103. private _indexLOD;
  77104. private _bufferLODs;
  77105. /** @hidden */
  77106. constructor(loader: GLTFLoader);
  77107. /** @hidden */
  77108. dispose(): void;
  77109. /** @hidden */
  77110. onReady(): void;
  77111. /** @hidden */
  77112. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77113. /** @hidden */
  77114. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77115. /** @hidden */
  77116. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77117. /** @hidden */
  77118. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77119. /** @hidden */
  77120. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77121. private _loadBufferLOD;
  77122. /**
  77123. * Gets an array of LOD properties from lowest to highest.
  77124. */
  77125. private _getLODs;
  77126. private _disposeTransformNode;
  77127. private _disposeMaterials;
  77128. }
  77129. }
  77130. declare module BABYLON.GLTF2.Loader.Extensions {
  77131. /** @hidden */
  77132. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77133. readonly name: string;
  77134. enabled: boolean;
  77135. private _loader;
  77136. constructor(loader: GLTFLoader);
  77137. dispose(): void;
  77138. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77139. }
  77140. }
  77141. declare module BABYLON.GLTF2.Loader.Extensions {
  77142. /** @hidden */
  77143. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77144. readonly name: string;
  77145. enabled: boolean;
  77146. private _loader;
  77147. constructor(loader: GLTFLoader);
  77148. dispose(): void;
  77149. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77150. }
  77151. }
  77152. declare module BABYLON.GLTF2.Loader.Extensions {
  77153. /**
  77154. * Store glTF extras (if present) in BJS objects' metadata
  77155. */
  77156. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77157. /**
  77158. * The name of this extension.
  77159. */
  77160. readonly name: string;
  77161. /**
  77162. * Defines whether this extension is enabled.
  77163. */
  77164. enabled: boolean;
  77165. private _loader;
  77166. private _assignExtras;
  77167. /** @hidden */
  77168. constructor(loader: GLTFLoader);
  77169. /** @hidden */
  77170. dispose(): void;
  77171. /** @hidden */
  77172. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77173. /** @hidden */
  77174. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77175. /** @hidden */
  77176. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77177. }
  77178. }
  77179. declare module BABYLON {
  77180. /**
  77181. * Class reading and parsing the MTL file bundled with the obj file.
  77182. */
  77183. export class MTLFileLoader {
  77184. /**
  77185. * Invert Y-Axis of referenced textures on load
  77186. */
  77187. static INVERT_TEXTURE_Y: boolean;
  77188. /**
  77189. * All material loaded from the mtl will be set here
  77190. */
  77191. materials: StandardMaterial[];
  77192. /**
  77193. * This function will read the mtl file and create each material described inside
  77194. * This function could be improve by adding :
  77195. * -some component missing (Ni, Tf...)
  77196. * -including the specific options available
  77197. *
  77198. * @param scene defines the scene the material will be created in
  77199. * @param data defines the mtl data to parse
  77200. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77201. * @param forAssetContainer defines if the material should be registered in the scene
  77202. */
  77203. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77204. /**
  77205. * Gets the texture for the material.
  77206. *
  77207. * If the material is imported from input file,
  77208. * We sanitize the url to ensure it takes the textre from aside the material.
  77209. *
  77210. * @param rootUrl The root url to load from
  77211. * @param value The value stored in the mtl
  77212. * @return The Texture
  77213. */
  77214. private static _getTexture;
  77215. }
  77216. }
  77217. declare module BABYLON {
  77218. /**
  77219. * Options for loading OBJ/MTL files
  77220. */
  77221. type MeshLoadOptions = {
  77222. /**
  77223. * Defines if UVs are optimized by default during load.
  77224. */
  77225. OptimizeWithUV: boolean;
  77226. /**
  77227. * Defines custom scaling of UV coordinates of loaded meshes.
  77228. */
  77229. UVScaling: Vector2;
  77230. /**
  77231. * Invert model on y-axis (does a model scaling inversion)
  77232. */
  77233. InvertY: boolean;
  77234. /**
  77235. * Invert Y-Axis of referenced textures on load
  77236. */
  77237. InvertTextureY: boolean;
  77238. /**
  77239. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77240. */
  77241. ImportVertexColors: boolean;
  77242. /**
  77243. * Compute the normals for the model, even if normals are present in the file.
  77244. */
  77245. ComputeNormals: boolean;
  77246. /**
  77247. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77248. */
  77249. SkipMaterials: boolean;
  77250. /**
  77251. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77252. */
  77253. MaterialLoadingFailsSilently: boolean;
  77254. };
  77255. /**
  77256. * OBJ file type loader.
  77257. * This is a babylon scene loader plugin.
  77258. */
  77259. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77260. /**
  77261. * Defines if UVs are optimized by default during load.
  77262. */
  77263. static OPTIMIZE_WITH_UV: boolean;
  77264. /**
  77265. * Invert model on y-axis (does a model scaling inversion)
  77266. */
  77267. static INVERT_Y: boolean;
  77268. /**
  77269. * Invert Y-Axis of referenced textures on load
  77270. */
  77271. static get INVERT_TEXTURE_Y(): boolean;
  77272. static set INVERT_TEXTURE_Y(value: boolean);
  77273. /**
  77274. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77275. */
  77276. static IMPORT_VERTEX_COLORS: boolean;
  77277. /**
  77278. * Compute the normals for the model, even if normals are present in the file.
  77279. */
  77280. static COMPUTE_NORMALS: boolean;
  77281. /**
  77282. * Defines custom scaling of UV coordinates of loaded meshes.
  77283. */
  77284. static UV_SCALING: Vector2;
  77285. /**
  77286. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77287. */
  77288. static SKIP_MATERIALS: boolean;
  77289. /**
  77290. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77291. *
  77292. * Defaults to true for backwards compatibility.
  77293. */
  77294. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77295. /**
  77296. * Defines the name of the plugin.
  77297. */
  77298. name: string;
  77299. /**
  77300. * Defines the extension the plugin is able to load.
  77301. */
  77302. extensions: string;
  77303. /** @hidden */
  77304. obj: RegExp;
  77305. /** @hidden */
  77306. group: RegExp;
  77307. /** @hidden */
  77308. mtllib: RegExp;
  77309. /** @hidden */
  77310. usemtl: RegExp;
  77311. /** @hidden */
  77312. smooth: RegExp;
  77313. /** @hidden */
  77314. vertexPattern: RegExp;
  77315. /** @hidden */
  77316. normalPattern: RegExp;
  77317. /** @hidden */
  77318. uvPattern: RegExp;
  77319. /** @hidden */
  77320. facePattern1: RegExp;
  77321. /** @hidden */
  77322. facePattern2: RegExp;
  77323. /** @hidden */
  77324. facePattern3: RegExp;
  77325. /** @hidden */
  77326. facePattern4: RegExp;
  77327. /** @hidden */
  77328. facePattern5: RegExp;
  77329. private _forAssetContainer;
  77330. private _meshLoadOptions;
  77331. /**
  77332. * Creates loader for .OBJ files
  77333. *
  77334. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77335. */
  77336. constructor(meshLoadOptions?: MeshLoadOptions);
  77337. private static get currentMeshLoadOptions();
  77338. /**
  77339. * Calls synchronously the MTL file attached to this obj.
  77340. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77341. * Without this function materials are not displayed in the first frame (but displayed after).
  77342. * In consequence it is impossible to get material information in your HTML file
  77343. *
  77344. * @param url The URL of the MTL file
  77345. * @param rootUrl
  77346. * @param onSuccess Callback function to be called when the MTL file is loaded
  77347. * @private
  77348. */
  77349. private _loadMTL;
  77350. /**
  77351. * Instantiates a OBJ file loader plugin.
  77352. * @returns the created plugin
  77353. */
  77354. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77355. /**
  77356. * If the data string can be loaded directly.
  77357. *
  77358. * @param data string containing the file data
  77359. * @returns if the data can be loaded directly
  77360. */
  77361. canDirectLoad(data: string): boolean;
  77362. /**
  77363. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77364. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77365. * @param scene the scene the meshes should be added to
  77366. * @param data the OBJ data to load
  77367. * @param rootUrl root url to load from
  77368. * @param onProgress event that fires when loading progress has occured
  77369. * @param fileName Defines the name of the file to load
  77370. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77371. */
  77372. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77373. meshes: AbstractMesh[];
  77374. particleSystems: IParticleSystem[];
  77375. skeletons: Skeleton[];
  77376. animationGroups: AnimationGroup[];
  77377. }>;
  77378. /**
  77379. * Imports all objects from the loaded OBJ data and adds them to the scene
  77380. * @param scene the scene the objects should be added to
  77381. * @param data the OBJ data to load
  77382. * @param rootUrl root url to load from
  77383. * @param onProgress event that fires when loading progress has occured
  77384. * @param fileName Defines the name of the file to load
  77385. * @returns a promise which completes when objects have been loaded to the scene
  77386. */
  77387. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77388. /**
  77389. * Load into an asset container.
  77390. * @param scene The scene to load into
  77391. * @param data The data to import
  77392. * @param rootUrl The root url for scene and resources
  77393. * @param onProgress The callback when the load progresses
  77394. * @param fileName Defines the name of the file to load
  77395. * @returns The loaded asset container
  77396. */
  77397. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77398. /**
  77399. * Read the OBJ file and create an Array of meshes.
  77400. * Each mesh contains all information given by the OBJ and the MTL file.
  77401. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77402. *
  77403. * @param meshesNames
  77404. * @param scene Scene The scene where are displayed the data
  77405. * @param data String The content of the obj file
  77406. * @param rootUrl String The path to the folder
  77407. * @returns Array<AbstractMesh>
  77408. * @private
  77409. */
  77410. private _parseSolid;
  77411. }
  77412. }
  77413. declare module BABYLON {
  77414. /**
  77415. * STL file type loader.
  77416. * This is a babylon scene loader plugin.
  77417. */
  77418. export class STLFileLoader implements ISceneLoaderPlugin {
  77419. /** @hidden */
  77420. solidPattern: RegExp;
  77421. /** @hidden */
  77422. facetsPattern: RegExp;
  77423. /** @hidden */
  77424. normalPattern: RegExp;
  77425. /** @hidden */
  77426. vertexPattern: RegExp;
  77427. /**
  77428. * Defines the name of the plugin.
  77429. */
  77430. name: string;
  77431. /**
  77432. * Defines the extensions the stl loader is able to load.
  77433. * force data to come in as an ArrayBuffer
  77434. * we'll convert to string if it looks like it's an ASCII .stl
  77435. */
  77436. extensions: ISceneLoaderPluginExtensions;
  77437. /**
  77438. * Import meshes into a scene.
  77439. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77440. * @param scene The scene to import into
  77441. * @param data The data to import
  77442. * @param rootUrl The root url for scene and resources
  77443. * @param meshes The meshes array to import into
  77444. * @param particleSystems The particle systems array to import into
  77445. * @param skeletons The skeletons array to import into
  77446. * @param onError The callback when import fails
  77447. * @returns True if successful or false otherwise
  77448. */
  77449. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77450. /**
  77451. * Load into a scene.
  77452. * @param scene The scene to load into
  77453. * @param data The data to import
  77454. * @param rootUrl The root url for scene and resources
  77455. * @param onError The callback when import fails
  77456. * @returns true if successful or false otherwise
  77457. */
  77458. load(scene: Scene, data: any, rootUrl: string): boolean;
  77459. /**
  77460. * Load into an asset container.
  77461. * @param scene The scene to load into
  77462. * @param data The data to import
  77463. * @param rootUrl The root url for scene and resources
  77464. * @param onError The callback when import fails
  77465. * @returns The loaded asset container
  77466. */
  77467. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77468. private _isBinary;
  77469. private _parseBinary;
  77470. private _parseASCII;
  77471. }
  77472. }
  77473. declare module BABYLON {
  77474. /**
  77475. * Class for generating OBJ data from a Babylon scene.
  77476. */
  77477. export class OBJExport {
  77478. /**
  77479. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77480. * @param mesh defines the list of meshes to serialize
  77481. * @param materials defines if materials should be exported
  77482. * @param matlibname defines the name of the associated mtl file
  77483. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77484. * @returns the OBJ content
  77485. */
  77486. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77487. /**
  77488. * Exports the material(s) of a mesh in .MTL file format (text)
  77489. * @param mesh defines the mesh to extract the material from
  77490. * @returns the mtl content
  77491. */
  77492. static MTL(mesh: Mesh): string;
  77493. }
  77494. }
  77495. declare module BABYLON {
  77496. /** @hidden */
  77497. export var __IGLTFExporterExtension: number;
  77498. /**
  77499. * Interface for extending the exporter
  77500. * @hidden
  77501. */
  77502. export interface IGLTFExporterExtension {
  77503. /**
  77504. * The name of this extension
  77505. */
  77506. readonly name: string;
  77507. /**
  77508. * Defines whether this extension is enabled
  77509. */
  77510. enabled: boolean;
  77511. /**
  77512. * Defines whether this extension is required
  77513. */
  77514. required: boolean;
  77515. }
  77516. }
  77517. declare module BABYLON.GLTF2.Exporter {
  77518. /** @hidden */
  77519. export var __IGLTFExporterExtensionV2: number;
  77520. /**
  77521. * Interface for a glTF exporter extension
  77522. * @hidden
  77523. */
  77524. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77525. /**
  77526. * Define this method to modify the default behavior before exporting a texture
  77527. * @param context The context when loading the asset
  77528. * @param babylonTexture The Babylon.js texture
  77529. * @param mimeType The mime-type of the generated image
  77530. * @returns A promise that resolves with the exported texture
  77531. */
  77532. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77533. /**
  77534. * Define this method to get notified when a texture info is created
  77535. * @param context The context when loading the asset
  77536. * @param textureInfo The glTF texture info
  77537. * @param babylonTexture The Babylon.js texture
  77538. */
  77539. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77540. /**
  77541. * Define this method to modify the default behavior when exporting texture info
  77542. * @param context The context when loading the asset
  77543. * @param meshPrimitive glTF mesh primitive
  77544. * @param babylonSubMesh Babylon submesh
  77545. * @param binaryWriter glTF serializer binary writer instance
  77546. * @returns nullable IMeshPrimitive promise
  77547. */
  77548. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77549. /**
  77550. * Define this method to modify the default behavior when exporting a node
  77551. * @param context The context when exporting the node
  77552. * @param node glTF node
  77553. * @param babylonNode BabylonJS node
  77554. * @returns nullable INode promise
  77555. */
  77556. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77557. [key: number]: number;
  77558. }): Promise<Nullable<INode>>;
  77559. /**
  77560. * Define this method to modify the default behavior when exporting a material
  77561. * @param material glTF material
  77562. * @param babylonMaterial BabylonJS material
  77563. * @returns nullable IMaterial promise
  77564. */
  77565. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77566. /**
  77567. * Define this method to return additional textures to export from a material
  77568. * @param material glTF material
  77569. * @param babylonMaterial BabylonJS material
  77570. * @returns List of textures
  77571. */
  77572. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77573. /** Gets a boolean indicating that this extension was used */
  77574. wasUsed: boolean;
  77575. /** Gets a boolean indicating that this extension is required for the file to work */
  77576. required: boolean;
  77577. /**
  77578. * Called after the exporter state changes to EXPORTING
  77579. */
  77580. onExporting?(): void;
  77581. }
  77582. }
  77583. declare module BABYLON.GLTF2.Exporter {
  77584. /**
  77585. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77586. * @hidden
  77587. */
  77588. export class _GLTFMaterialExporter {
  77589. /**
  77590. * Represents the dielectric specular values for R, G and B
  77591. */
  77592. private static readonly _DielectricSpecular;
  77593. /**
  77594. * Allows the maximum specular power to be defined for material calculations
  77595. */
  77596. private static readonly _MaxSpecularPower;
  77597. /**
  77598. * Mapping to store textures
  77599. */
  77600. private _textureMap;
  77601. /**
  77602. * Numeric tolerance value
  77603. */
  77604. private static readonly _Epsilon;
  77605. /**
  77606. * Reference to the glTF Exporter
  77607. */
  77608. private _exporter;
  77609. constructor(exporter: _Exporter);
  77610. /**
  77611. * Specifies if two colors are approximately equal in value
  77612. * @param color1 first color to compare to
  77613. * @param color2 second color to compare to
  77614. * @param epsilon threshold value
  77615. */
  77616. private static FuzzyEquals;
  77617. /**
  77618. * Gets the materials from a Babylon scene and converts them to glTF materials
  77619. * @param scene babylonjs scene
  77620. * @param mimeType texture mime type
  77621. * @param images array of images
  77622. * @param textures array of textures
  77623. * @param materials array of materials
  77624. * @param imageData mapping of texture names to base64 textures
  77625. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77626. */
  77627. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77628. /**
  77629. * Makes a copy of the glTF material without the texture parameters
  77630. * @param originalMaterial original glTF material
  77631. * @returns glTF material without texture parameters
  77632. */
  77633. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77634. /**
  77635. * Specifies if the material has any texture parameters present
  77636. * @param material glTF Material
  77637. * @returns boolean specifying if texture parameters are present
  77638. */
  77639. _hasTexturesPresent(material: IMaterial): boolean;
  77640. /**
  77641. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77642. * @param babylonStandardMaterial
  77643. * @returns glTF Metallic Roughness Material representation
  77644. */
  77645. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77646. /**
  77647. * Computes the metallic factor
  77648. * @param diffuse diffused value
  77649. * @param specular specular value
  77650. * @param oneMinusSpecularStrength one minus the specular strength
  77651. * @returns metallic value
  77652. */
  77653. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77654. /**
  77655. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77656. * @param glTFMaterial glTF material
  77657. * @param babylonMaterial Babylon material
  77658. */
  77659. private static _SetAlphaMode;
  77660. /**
  77661. * Converts a Babylon Standard Material to a glTF Material
  77662. * @param babylonStandardMaterial BJS Standard Material
  77663. * @param mimeType mime type to use for the textures
  77664. * @param images array of glTF image interfaces
  77665. * @param textures array of glTF texture interfaces
  77666. * @param materials array of glTF material interfaces
  77667. * @param imageData map of image file name to data
  77668. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77669. */
  77670. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77671. private _finishMaterial;
  77672. /**
  77673. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77674. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77675. * @param mimeType mime type to use for the textures
  77676. * @param images array of glTF image interfaces
  77677. * @param textures array of glTF texture interfaces
  77678. * @param materials array of glTF material interfaces
  77679. * @param imageData map of image file name to data
  77680. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77681. */
  77682. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77683. /**
  77684. * Converts an image typed array buffer to a base64 image
  77685. * @param buffer typed array buffer
  77686. * @param width width of the image
  77687. * @param height height of the image
  77688. * @param mimeType mimetype of the image
  77689. * @returns base64 image string
  77690. */
  77691. private _createBase64FromCanvasAsync;
  77692. /**
  77693. * Generates a white texture based on the specified width and height
  77694. * @param width width of the texture in pixels
  77695. * @param height height of the texture in pixels
  77696. * @param scene babylonjs scene
  77697. * @returns white texture
  77698. */
  77699. private _createWhiteTexture;
  77700. /**
  77701. * 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
  77702. * @param texture1 first texture to resize
  77703. * @param texture2 second texture to resize
  77704. * @param scene babylonjs scene
  77705. * @returns resized textures or null
  77706. */
  77707. private _resizeTexturesToSameDimensions;
  77708. /**
  77709. * Converts an array of pixels to a Float32Array
  77710. * Throws an error if the pixel format is not supported
  77711. * @param pixels - array buffer containing pixel values
  77712. * @returns Float32 of pixels
  77713. */
  77714. private _convertPixelArrayToFloat32;
  77715. /**
  77716. * Convert Specular Glossiness Textures to Metallic Roughness
  77717. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77718. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77719. * @param diffuseTexture texture used to store diffuse information
  77720. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77721. * @param factors specular glossiness material factors
  77722. * @param mimeType the mime type to use for the texture
  77723. * @returns pbr metallic roughness interface or null
  77724. */
  77725. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77726. /**
  77727. * Converts specular glossiness material properties to metallic roughness
  77728. * @param specularGlossiness interface with specular glossiness material properties
  77729. * @returns interface with metallic roughness material properties
  77730. */
  77731. private _convertSpecularGlossinessToMetallicRoughness;
  77732. /**
  77733. * Calculates the surface reflectance, independent of lighting conditions
  77734. * @param color Color source to calculate brightness from
  77735. * @returns number representing the perceived brightness, or zero if color is undefined
  77736. */
  77737. private _getPerceivedBrightness;
  77738. /**
  77739. * Returns the maximum color component value
  77740. * @param color
  77741. * @returns maximum color component value, or zero if color is null or undefined
  77742. */
  77743. private _getMaxComponent;
  77744. /**
  77745. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77746. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77747. * @param mimeType mime type to use for the textures
  77748. * @param images array of glTF image interfaces
  77749. * @param textures array of glTF texture interfaces
  77750. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77751. * @param imageData map of image file name to data
  77752. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77753. * @returns glTF PBR Metallic Roughness factors
  77754. */
  77755. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77756. private _getGLTFTextureSampler;
  77757. private _getGLTFTextureWrapMode;
  77758. private _getGLTFTextureWrapModesSampler;
  77759. /**
  77760. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77761. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77762. * @param mimeType mime type to use for the textures
  77763. * @param images array of glTF image interfaces
  77764. * @param textures array of glTF texture interfaces
  77765. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77766. * @param imageData map of image file name to data
  77767. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77768. * @returns glTF PBR Metallic Roughness factors
  77769. */
  77770. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77771. /**
  77772. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77773. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77774. * @param mimeType mime type to use for the textures
  77775. * @param images array of glTF image interfaces
  77776. * @param textures array of glTF texture interfaces
  77777. * @param materials array of glTF material interfaces
  77778. * @param imageData map of image file name to data
  77779. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77780. */
  77781. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77782. private setMetallicRoughnessPbrMaterial;
  77783. private getPixelsFromTexture;
  77784. /**
  77785. * Extracts a texture from a Babylon texture into file data and glTF data
  77786. * @param babylonTexture Babylon texture to extract
  77787. * @param mimeType Mime Type of the babylonTexture
  77788. * @return glTF texture info, or null if the texture format is not supported
  77789. */
  77790. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77791. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77792. /**
  77793. * Builds a texture from base64 string
  77794. * @param base64Texture base64 texture string
  77795. * @param baseTextureName Name to use for the texture
  77796. * @param mimeType image mime type for the texture
  77797. * @param images array of images
  77798. * @param textures array of textures
  77799. * @param imageData map of image data
  77800. * @returns glTF texture info, or null if the texture format is not supported
  77801. */
  77802. private _getTextureInfoFromBase64;
  77803. }
  77804. }
  77805. declare module BABYLON {
  77806. /**
  77807. * Class for holding and downloading glTF file data
  77808. */
  77809. export class GLTFData {
  77810. /**
  77811. * Object which contains the file name as the key and its data as the value
  77812. */
  77813. glTFFiles: {
  77814. [fileName: string]: string | Blob;
  77815. };
  77816. /**
  77817. * Initializes the glTF file object
  77818. */
  77819. constructor();
  77820. /**
  77821. * Downloads the glTF data as files based on their names and data
  77822. */
  77823. downloadFiles(): void;
  77824. }
  77825. }
  77826. declare module BABYLON {
  77827. /**
  77828. * Holds a collection of exporter options and parameters
  77829. */
  77830. export interface IExportOptions {
  77831. /**
  77832. * Function which indicates whether a babylon node should be exported or not
  77833. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77834. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77835. */
  77836. shouldExportNode?(node: Node): boolean;
  77837. /**
  77838. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77839. * @param metadata source metadata to read from
  77840. * @returns the data to store to glTF node extras
  77841. */
  77842. metadataSelector?(metadata: any): any;
  77843. /**
  77844. * The sample rate to bake animation curves
  77845. */
  77846. animationSampleRate?: number;
  77847. /**
  77848. * Begin serialization without waiting for the scene to be ready
  77849. */
  77850. exportWithoutWaitingForScene?: boolean;
  77851. /**
  77852. * Indicates if coordinate system swapping root nodes should be included in export
  77853. */
  77854. includeCoordinateSystemConversionNodes?: boolean;
  77855. }
  77856. /**
  77857. * Class for generating glTF data from a Babylon scene.
  77858. */
  77859. export class GLTF2Export {
  77860. /**
  77861. * Exports the geometry of the scene to .gltf file format asynchronously
  77862. * @param scene Babylon scene with scene hierarchy information
  77863. * @param filePrefix File prefix to use when generating the glTF file
  77864. * @param options Exporter options
  77865. * @returns Returns an object with a .gltf file and associates texture names
  77866. * as keys and their data and paths as values
  77867. */
  77868. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77869. private static _PreExportAsync;
  77870. private static _PostExportAsync;
  77871. /**
  77872. * Exports the geometry of the scene to .glb file format asychronously
  77873. * @param scene Babylon scene with scene hierarchy information
  77874. * @param filePrefix File prefix to use when generating glb file
  77875. * @param options Exporter options
  77876. * @returns Returns an object with a .glb filename as key and data as value
  77877. */
  77878. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77879. }
  77880. }
  77881. declare module BABYLON.GLTF2.Exporter {
  77882. /**
  77883. * @hidden
  77884. */
  77885. export class _GLTFUtilities {
  77886. /**
  77887. * Creates a buffer view based on the supplied arguments
  77888. * @param bufferIndex index value of the specified buffer
  77889. * @param byteOffset byte offset value
  77890. * @param byteLength byte length of the bufferView
  77891. * @param byteStride byte distance between conequential elements
  77892. * @param name name of the buffer view
  77893. * @returns bufferView for glTF
  77894. */
  77895. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77896. /**
  77897. * Creates an accessor based on the supplied arguments
  77898. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77899. * @param name The name of the accessor
  77900. * @param type The type of the accessor
  77901. * @param componentType The datatype of components in the attribute
  77902. * @param count The number of attributes referenced by this accessor
  77903. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77904. * @param min Minimum value of each component in this attribute
  77905. * @param max Maximum value of each component in this attribute
  77906. * @returns accessor for glTF
  77907. */
  77908. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77909. /**
  77910. * Calculates the minimum and maximum values of an array of position floats
  77911. * @param positions Positions array of a mesh
  77912. * @param vertexStart Starting vertex offset to calculate min and max values
  77913. * @param vertexCount Number of vertices to check for min and max values
  77914. * @returns min number array and max number array
  77915. */
  77916. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77917. min: number[];
  77918. max: number[];
  77919. };
  77920. /**
  77921. * Converts a new right-handed Vector3
  77922. * @param vector vector3 array
  77923. * @returns right-handed Vector3
  77924. */
  77925. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77926. /**
  77927. * Converts a Vector3 to right-handed
  77928. * @param vector Vector3 to convert to right-handed
  77929. */
  77930. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77931. /**
  77932. * Converts a three element number array to right-handed
  77933. * @param vector number array to convert to right-handed
  77934. */
  77935. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77936. /**
  77937. * Converts a new right-handed Vector3
  77938. * @param vector vector3 array
  77939. * @returns right-handed Vector3
  77940. */
  77941. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77942. /**
  77943. * Converts a Vector3 to right-handed
  77944. * @param vector Vector3 to convert to right-handed
  77945. */
  77946. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77947. /**
  77948. * Converts a three element number array to right-handed
  77949. * @param vector number array to convert to right-handed
  77950. */
  77951. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77952. /**
  77953. * Converts a Vector4 to right-handed
  77954. * @param vector Vector4 to convert to right-handed
  77955. */
  77956. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77957. /**
  77958. * Converts a Vector4 to right-handed
  77959. * @param vector Vector4 to convert to right-handed
  77960. */
  77961. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77962. /**
  77963. * Converts a Quaternion to right-handed
  77964. * @param quaternion Source quaternion to convert to right-handed
  77965. */
  77966. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77967. /**
  77968. * Converts a Quaternion to right-handed
  77969. * @param quaternion Source quaternion to convert to right-handed
  77970. */
  77971. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77972. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77973. }
  77974. }
  77975. declare module BABYLON.GLTF2.Exporter {
  77976. /**
  77977. * Converts Babylon Scene into glTF 2.0.
  77978. * @hidden
  77979. */
  77980. export class _Exporter {
  77981. /**
  77982. * Stores the glTF to export
  77983. */
  77984. _glTF: IGLTF;
  77985. /**
  77986. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77987. */
  77988. _bufferViews: IBufferView[];
  77989. /**
  77990. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77991. */
  77992. _accessors: IAccessor[];
  77993. /**
  77994. * Stores all the generated nodes, which contains transform and/or mesh information per node
  77995. */
  77996. _nodes: INode[];
  77997. /**
  77998. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  77999. */
  78000. private _scenes;
  78001. /**
  78002. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78003. */
  78004. private _meshes;
  78005. /**
  78006. * Stores all the generated material information, which represents the appearance of each primitive
  78007. */
  78008. _materials: IMaterial[];
  78009. _materialMap: {
  78010. [materialID: number]: number;
  78011. };
  78012. /**
  78013. * Stores all the generated texture information, which is referenced by glTF materials
  78014. */
  78015. _textures: ITexture[];
  78016. /**
  78017. * Stores all the generated image information, which is referenced by glTF textures
  78018. */
  78019. _images: IImage[];
  78020. /**
  78021. * Stores all the texture samplers
  78022. */
  78023. _samplers: ISampler[];
  78024. /**
  78025. * Stores all the generated animation samplers, which is referenced by glTF animations
  78026. */
  78027. /**
  78028. * Stores the animations for glTF models
  78029. */
  78030. private _animations;
  78031. /**
  78032. * Stores the total amount of bytes stored in the glTF buffer
  78033. */
  78034. private _totalByteLength;
  78035. /**
  78036. * Stores a reference to the Babylon scene containing the source geometry and material information
  78037. */
  78038. _babylonScene: Scene;
  78039. /**
  78040. * Stores a map of the image data, where the key is the file name and the value
  78041. * is the image data
  78042. */
  78043. _imageData: {
  78044. [fileName: string]: {
  78045. data: Uint8Array;
  78046. mimeType: ImageMimeType;
  78047. };
  78048. };
  78049. /**
  78050. * Stores a map of the unique id of a node to its index in the node array
  78051. */
  78052. _nodeMap: {
  78053. [key: number]: number;
  78054. };
  78055. /**
  78056. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78057. */
  78058. _convertToRightHandedSystem: boolean;
  78059. /**
  78060. * Specifies if a Babylon node should be converted to right-handed on export
  78061. */
  78062. _convertToRightHandedSystemMap: {
  78063. [nodeId: number]: boolean;
  78064. };
  78065. _includeCoordinateSystemConversionNodes: boolean;
  78066. /**
  78067. * Baked animation sample rate
  78068. */
  78069. private _animationSampleRate;
  78070. private _options;
  78071. private _localEngine;
  78072. _glTFMaterialExporter: _GLTFMaterialExporter;
  78073. private _extensions;
  78074. private static _ExtensionNames;
  78075. private static _ExtensionFactories;
  78076. private _applyExtension;
  78077. private _applyExtensions;
  78078. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78079. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78080. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78081. [key: number]: number;
  78082. }): Promise<Nullable<INode>>;
  78083. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78084. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78085. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78086. private _forEachExtensions;
  78087. private _extensionsOnExporting;
  78088. /**
  78089. * Load glTF serializer extensions
  78090. */
  78091. private _loadExtensions;
  78092. /**
  78093. * Creates a glTF Exporter instance, which can accept optional exporter options
  78094. * @param babylonScene Babylon scene object
  78095. * @param options Options to modify the behavior of the exporter
  78096. */
  78097. constructor(babylonScene: Scene, options?: IExportOptions);
  78098. dispose(): void;
  78099. /**
  78100. * Registers a glTF exporter extension
  78101. * @param name Name of the extension to export
  78102. * @param factory The factory function that creates the exporter extension
  78103. */
  78104. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78105. /**
  78106. * Un-registers an exporter extension
  78107. * @param name The name fo the exporter extension
  78108. * @returns A boolean indicating whether the extension has been un-registered
  78109. */
  78110. static UnregisterExtension(name: string): boolean;
  78111. /**
  78112. * Lazy load a local engine
  78113. */
  78114. _getLocalEngine(): Engine;
  78115. private reorderIndicesBasedOnPrimitiveMode;
  78116. /**
  78117. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78118. * clock-wise during export to glTF
  78119. * @param submesh BabylonJS submesh
  78120. * @param primitiveMode Primitive mode of the mesh
  78121. * @param sideOrientation the winding order of the submesh
  78122. * @param vertexBufferKind The type of vertex attribute
  78123. * @param meshAttributeArray The vertex attribute data
  78124. * @param byteOffset The offset to the binary data
  78125. * @param binaryWriter The binary data for the glTF file
  78126. * @param convertToRightHandedSystem Converts the values to right-handed
  78127. */
  78128. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78129. /**
  78130. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78131. * clock-wise during export to glTF
  78132. * @param submesh BabylonJS submesh
  78133. * @param primitiveMode Primitive mode of the mesh
  78134. * @param sideOrientation the winding order of the submesh
  78135. * @param vertexBufferKind The type of vertex attribute
  78136. * @param meshAttributeArray The vertex attribute data
  78137. * @param byteOffset The offset to the binary data
  78138. * @param binaryWriter The binary data for the glTF file
  78139. * @param convertToRightHandedSystem Converts the values to right-handed
  78140. */
  78141. private reorderTriangleFillMode;
  78142. /**
  78143. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78144. * clock-wise during export to glTF
  78145. * @param submesh BabylonJS submesh
  78146. * @param primitiveMode Primitive mode of the mesh
  78147. * @param sideOrientation the winding order of the submesh
  78148. * @param vertexBufferKind The type of vertex attribute
  78149. * @param meshAttributeArray The vertex attribute data
  78150. * @param byteOffset The offset to the binary data
  78151. * @param binaryWriter The binary data for the glTF file
  78152. * @param convertToRightHandedSystem Converts the values to right-handed
  78153. */
  78154. private reorderTriangleStripDrawMode;
  78155. /**
  78156. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78157. * clock-wise during export to glTF
  78158. * @param submesh BabylonJS submesh
  78159. * @param primitiveMode Primitive mode of the mesh
  78160. * @param sideOrientation the winding order of the submesh
  78161. * @param vertexBufferKind The type of vertex attribute
  78162. * @param meshAttributeArray The vertex attribute data
  78163. * @param byteOffset The offset to the binary data
  78164. * @param binaryWriter The binary data for the glTF file
  78165. * @param convertToRightHandedSystem Converts the values to right-handed
  78166. */
  78167. private reorderTriangleFanMode;
  78168. /**
  78169. * Writes the vertex attribute data to binary
  78170. * @param vertices The vertices to write to the binary writer
  78171. * @param byteOffset The offset into the binary writer to overwrite binary data
  78172. * @param vertexAttributeKind The vertex attribute type
  78173. * @param meshAttributeArray The vertex attribute data
  78174. * @param binaryWriter The writer containing the binary data
  78175. * @param convertToRightHandedSystem Converts the values to right-handed
  78176. */
  78177. private writeVertexAttributeData;
  78178. /**
  78179. * Writes mesh attribute data to a data buffer
  78180. * Returns the bytelength of the data
  78181. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78182. * @param meshAttributeArray Array containing the attribute data
  78183. * @param binaryWriter The buffer to write the binary data to
  78184. * @param indices Used to specify the order of the vertex data
  78185. * @param convertToRightHandedSystem Converts the values to right-handed
  78186. */
  78187. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78188. /**
  78189. * Generates glTF json data
  78190. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78191. * @param glTFPrefix Text to use when prefixing a glTF file
  78192. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78193. * @returns json data as string
  78194. */
  78195. private generateJSON;
  78196. /**
  78197. * Generates data for .gltf and .bin files based on the glTF prefix string
  78198. * @param glTFPrefix Text to use when prefixing a glTF file
  78199. * @param dispose Dispose the exporter
  78200. * @returns GLTFData with glTF file data
  78201. */
  78202. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78203. /**
  78204. * Creates a binary buffer for glTF
  78205. * @returns array buffer for binary data
  78206. */
  78207. private _generateBinaryAsync;
  78208. /**
  78209. * Pads the number to a multiple of 4
  78210. * @param num number to pad
  78211. * @returns padded number
  78212. */
  78213. private _getPadding;
  78214. /**
  78215. * @hidden
  78216. */
  78217. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78218. /**
  78219. * Sets the TRS for each node
  78220. * @param node glTF Node for storing the transformation data
  78221. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78222. * @param convertToRightHandedSystem Converts the values to right-handed
  78223. */
  78224. private setNodeTransformation;
  78225. private getVertexBufferFromMesh;
  78226. /**
  78227. * Creates a bufferview based on the vertices type for the Babylon mesh
  78228. * @param kind Indicates the type of vertices data
  78229. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78230. * @param binaryWriter The buffer to write the bufferview data to
  78231. * @param convertToRightHandedSystem Converts the values to right-handed
  78232. */
  78233. private createBufferViewKind;
  78234. /**
  78235. * The primitive mode of the Babylon mesh
  78236. * @param babylonMesh The BabylonJS mesh
  78237. */
  78238. private getMeshPrimitiveMode;
  78239. /**
  78240. * Sets the primitive mode of the glTF mesh primitive
  78241. * @param meshPrimitive glTF mesh primitive
  78242. * @param primitiveMode The primitive mode
  78243. */
  78244. private setPrimitiveMode;
  78245. /**
  78246. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78247. * @param meshPrimitive glTF mesh primitive
  78248. * @param attributeKind vertex attribute
  78249. * @returns boolean specifying if uv coordinates are present
  78250. */
  78251. private setAttributeKind;
  78252. /**
  78253. * Sets data for the primitive attributes of each submesh
  78254. * @param mesh glTF Mesh object to store the primitive attribute information
  78255. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78256. * @param binaryWriter Buffer to write the attribute data to
  78257. * @param convertToRightHandedSystem Converts the values to right-handed
  78258. */
  78259. private setPrimitiveAttributesAsync;
  78260. /**
  78261. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78262. * @param node The node to check
  78263. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78264. */
  78265. private isBabylonCoordinateSystemConvertingNode;
  78266. /**
  78267. * Creates a glTF scene based on the array of meshes
  78268. * Returns the the total byte offset
  78269. * @param babylonScene Babylon scene to get the mesh data from
  78270. * @param binaryWriter Buffer to write binary data to
  78271. */
  78272. private createSceneAsync;
  78273. /**
  78274. * Creates a mapping of Node unique id to node index and handles animations
  78275. * @param babylonScene Babylon Scene
  78276. * @param nodes Babylon transform nodes
  78277. * @param binaryWriter Buffer to write binary data to
  78278. * @returns Node mapping of unique id to index
  78279. */
  78280. private createNodeMapAndAnimationsAsync;
  78281. /**
  78282. * Creates a glTF node from a Babylon mesh
  78283. * @param babylonMesh Source Babylon mesh
  78284. * @param binaryWriter Buffer for storing geometry data
  78285. * @param convertToRightHandedSystem Converts the values to right-handed
  78286. * @param nodeMap Node mapping of unique id to glTF node index
  78287. * @returns glTF node
  78288. */
  78289. private createNodeAsync;
  78290. }
  78291. /**
  78292. * @hidden
  78293. *
  78294. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78295. */
  78296. export class _BinaryWriter {
  78297. /**
  78298. * Array buffer which stores all binary data
  78299. */
  78300. private _arrayBuffer;
  78301. /**
  78302. * View of the array buffer
  78303. */
  78304. private _dataView;
  78305. /**
  78306. * byte offset of data in array buffer
  78307. */
  78308. private _byteOffset;
  78309. /**
  78310. * Initialize binary writer with an initial byte length
  78311. * @param byteLength Initial byte length of the array buffer
  78312. */
  78313. constructor(byteLength: number);
  78314. /**
  78315. * Resize the array buffer to the specified byte length
  78316. * @param byteLength
  78317. */
  78318. private resizeBuffer;
  78319. /**
  78320. * Get an array buffer with the length of the byte offset
  78321. * @returns ArrayBuffer resized to the byte offset
  78322. */
  78323. getArrayBuffer(): ArrayBuffer;
  78324. /**
  78325. * Get the byte offset of the array buffer
  78326. * @returns byte offset
  78327. */
  78328. getByteOffset(): number;
  78329. /**
  78330. * Stores an UInt8 in the array buffer
  78331. * @param entry
  78332. * @param byteOffset If defined, specifies where to set the value as an offset.
  78333. */
  78334. setUInt8(entry: number, byteOffset?: number): void;
  78335. /**
  78336. * Gets an UInt32 in the array buffer
  78337. * @param entry
  78338. * @param byteOffset If defined, specifies where to set the value as an offset.
  78339. */
  78340. getUInt32(byteOffset: number): number;
  78341. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78342. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78343. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78344. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78345. /**
  78346. * Stores a Float32 in the array buffer
  78347. * @param entry
  78348. */
  78349. setFloat32(entry: number, byteOffset?: number): void;
  78350. /**
  78351. * Stores an UInt32 in the array buffer
  78352. * @param entry
  78353. * @param byteOffset If defined, specifies where to set the value as an offset.
  78354. */
  78355. setUInt32(entry: number, byteOffset?: number): void;
  78356. }
  78357. }
  78358. declare module BABYLON.GLTF2.Exporter {
  78359. /**
  78360. * @hidden
  78361. * Interface to store animation data.
  78362. */
  78363. export interface _IAnimationData {
  78364. /**
  78365. * Keyframe data.
  78366. */
  78367. inputs: number[];
  78368. /**
  78369. * Value data.
  78370. */
  78371. outputs: number[][];
  78372. /**
  78373. * Animation interpolation data.
  78374. */
  78375. samplerInterpolation: AnimationSamplerInterpolation;
  78376. /**
  78377. * Minimum keyframe value.
  78378. */
  78379. inputsMin: number;
  78380. /**
  78381. * Maximum keyframe value.
  78382. */
  78383. inputsMax: number;
  78384. }
  78385. /**
  78386. * @hidden
  78387. */
  78388. export interface _IAnimationInfo {
  78389. /**
  78390. * The target channel for the animation
  78391. */
  78392. animationChannelTargetPath: AnimationChannelTargetPath;
  78393. /**
  78394. * The glTF accessor type for the data.
  78395. */
  78396. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78397. /**
  78398. * Specifies if quaternions should be used.
  78399. */
  78400. useQuaternion: boolean;
  78401. }
  78402. /**
  78403. * @hidden
  78404. * Utility class for generating glTF animation data from BabylonJS.
  78405. */
  78406. export class _GLTFAnimation {
  78407. /**
  78408. * @ignore
  78409. *
  78410. * Creates glTF channel animation from BabylonJS animation.
  78411. * @param babylonTransformNode - BabylonJS mesh.
  78412. * @param animation - animation.
  78413. * @param animationChannelTargetPath - The target animation channel.
  78414. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78415. * @param useQuaternion - Specifies if quaternions are used.
  78416. * @returns nullable IAnimationData
  78417. */
  78418. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78419. private static _DeduceAnimationInfo;
  78420. /**
  78421. * @ignore
  78422. * Create node animations from the transform node animations
  78423. * @param babylonNode
  78424. * @param runtimeGLTFAnimation
  78425. * @param idleGLTFAnimations
  78426. * @param nodeMap
  78427. * @param nodes
  78428. * @param binaryWriter
  78429. * @param bufferViews
  78430. * @param accessors
  78431. * @param convertToRightHandedSystem
  78432. * @param animationSampleRate
  78433. */
  78434. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78435. [key: number]: number;
  78436. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78437. /**
  78438. * @ignore
  78439. * Create node animations from the animation groups
  78440. * @param babylonScene
  78441. * @param glTFAnimations
  78442. * @param nodeMap
  78443. * @param nodes
  78444. * @param binaryWriter
  78445. * @param bufferViews
  78446. * @param accessors
  78447. * @param convertToRightHandedSystemMap
  78448. * @param animationSampleRate
  78449. */
  78450. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78451. [key: number]: number;
  78452. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78453. [nodeId: number]: boolean;
  78454. }, animationSampleRate: number): void;
  78455. private static AddAnimation;
  78456. /**
  78457. * Create a baked animation
  78458. * @param babylonTransformNode BabylonJS mesh
  78459. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78460. * @param animationChannelTargetPath animation target channel
  78461. * @param minFrame minimum animation frame
  78462. * @param maxFrame maximum animation frame
  78463. * @param fps frames per second of the animation
  78464. * @param inputs input key frames of the animation
  78465. * @param outputs output key frame data of the animation
  78466. * @param convertToRightHandedSystem converts the values to right-handed
  78467. * @param useQuaternion specifies if quaternions should be used
  78468. */
  78469. private static _CreateBakedAnimation;
  78470. private static _ConvertFactorToVector3OrQuaternion;
  78471. private static _SetInterpolatedValue;
  78472. /**
  78473. * Creates linear animation from the animation key frames
  78474. * @param babylonTransformNode BabylonJS mesh
  78475. * @param animation BabylonJS animation
  78476. * @param animationChannelTargetPath The target animation channel
  78477. * @param frameDelta The difference between the last and first frame of the animation
  78478. * @param inputs Array to store the key frame times
  78479. * @param outputs Array to store the key frame data
  78480. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78481. * @param useQuaternion Specifies if quaternions are used in the animation
  78482. */
  78483. private static _CreateLinearOrStepAnimation;
  78484. /**
  78485. * Creates cubic spline animation from the animation key frames
  78486. * @param babylonTransformNode BabylonJS mesh
  78487. * @param animation BabylonJS animation
  78488. * @param animationChannelTargetPath The target animation channel
  78489. * @param frameDelta The difference between the last and first frame of the animation
  78490. * @param inputs Array to store the key frame times
  78491. * @param outputs Array to store the key frame data
  78492. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78493. * @param useQuaternion Specifies if quaternions are used in the animation
  78494. */
  78495. private static _CreateCubicSplineAnimation;
  78496. private static _GetBasePositionRotationOrScale;
  78497. /**
  78498. * Adds a key frame value
  78499. * @param keyFrame
  78500. * @param animation
  78501. * @param outputs
  78502. * @param animationChannelTargetPath
  78503. * @param basePositionRotationOrScale
  78504. * @param convertToRightHandedSystem
  78505. * @param useQuaternion
  78506. */
  78507. private static _AddKeyframeValue;
  78508. /**
  78509. * Determine the interpolation based on the key frames
  78510. * @param keyFrames
  78511. * @param animationChannelTargetPath
  78512. * @param useQuaternion
  78513. */
  78514. private static _DeduceInterpolation;
  78515. /**
  78516. * Adds an input tangent or output tangent to the output data
  78517. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78518. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78519. * @param outputs The animation data by keyframe
  78520. * @param animationChannelTargetPath The target animation channel
  78521. * @param interpolation The interpolation type
  78522. * @param keyFrame The key frame with the animation data
  78523. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78524. * @param useQuaternion Specifies if quaternions are used
  78525. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78526. */
  78527. private static AddSplineTangent;
  78528. /**
  78529. * Get the minimum and maximum key frames' frame values
  78530. * @param keyFrames animation key frames
  78531. * @returns the minimum and maximum key frame value
  78532. */
  78533. private static calculateMinMaxKeyFrames;
  78534. }
  78535. }
  78536. declare module BABYLON.GLTF2.Exporter {
  78537. /** @hidden */
  78538. export var textureTransformPixelShader: {
  78539. name: string;
  78540. shader: string;
  78541. };
  78542. }
  78543. declare module BABYLON.GLTF2.Exporter.Extensions {
  78544. /**
  78545. * @hidden
  78546. */
  78547. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78548. private _recordedTextures;
  78549. /** Name of this extension */
  78550. readonly name: string;
  78551. /** Defines whether this extension is enabled */
  78552. enabled: boolean;
  78553. /** Defines whether this extension is required */
  78554. required: boolean;
  78555. /** Reference to the glTF exporter */
  78556. private _wasUsed;
  78557. constructor(exporter: _Exporter);
  78558. dispose(): void;
  78559. /** @hidden */
  78560. get wasUsed(): boolean;
  78561. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78562. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78563. /**
  78564. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78565. * @param babylonTexture
  78566. * @param offset
  78567. * @param rotation
  78568. * @param scale
  78569. * @param scene
  78570. */
  78571. private _textureTransformTextureAsync;
  78572. }
  78573. }
  78574. declare module BABYLON.GLTF2.Exporter.Extensions {
  78575. /**
  78576. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78577. */
  78578. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78579. /** The name of this extension. */
  78580. readonly name: string;
  78581. /** Defines whether this extension is enabled. */
  78582. enabled: boolean;
  78583. /** Defines whether this extension is required */
  78584. required: boolean;
  78585. /** Reference to the glTF exporter */
  78586. private _exporter;
  78587. private _lights;
  78588. /** @hidden */
  78589. constructor(exporter: _Exporter);
  78590. /** @hidden */
  78591. dispose(): void;
  78592. /** @hidden */
  78593. get wasUsed(): boolean;
  78594. /** @hidden */
  78595. onExporting(): void;
  78596. /**
  78597. * Define this method to modify the default behavior when exporting a node
  78598. * @param context The context when exporting the node
  78599. * @param node glTF node
  78600. * @param babylonNode BabylonJS node
  78601. * @param nodeMap Node mapping of unique id to glTF node index
  78602. * @returns nullable INode promise
  78603. */
  78604. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78605. [key: number]: number;
  78606. }): Promise<Nullable<INode>>;
  78607. }
  78608. }
  78609. declare module BABYLON.GLTF2.Exporter.Extensions {
  78610. /**
  78611. * @hidden
  78612. */
  78613. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78614. /** Name of this extension */
  78615. readonly name: string;
  78616. /** Defines whether this extension is enabled */
  78617. enabled: boolean;
  78618. /** Defines whether this extension is required */
  78619. required: boolean;
  78620. /** Reference to the glTF exporter */
  78621. private _textureInfos;
  78622. private _exportedTextures;
  78623. private _wasUsed;
  78624. constructor(exporter: _Exporter);
  78625. dispose(): void;
  78626. /** @hidden */
  78627. get wasUsed(): boolean;
  78628. private _getTextureIndex;
  78629. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78630. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78631. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78632. }
  78633. }
  78634. declare module BABYLON {
  78635. /**
  78636. * Class for generating STL data from a Babylon scene.
  78637. */
  78638. export class STLExport {
  78639. /**
  78640. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78641. * @param meshes list defines the mesh to serialize
  78642. * @param download triggers the automatic download of the file.
  78643. * @param fileName changes the downloads fileName.
  78644. * @param binary changes the STL to a binary type.
  78645. * @param isLittleEndian toggle for binary type exporter.
  78646. * @returns the STL as UTF8 string
  78647. */
  78648. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78649. }
  78650. }
  78651. declare module "babylonjs-gltf2interface" {
  78652. export = BABYLON.GLTF2;
  78653. }
  78654. /**
  78655. * Module for glTF 2.0 Interface
  78656. */
  78657. declare module BABYLON.GLTF2 {
  78658. /**
  78659. * The datatype of the components in the attribute
  78660. */
  78661. const enum AccessorComponentType {
  78662. /**
  78663. * Byte
  78664. */
  78665. BYTE = 5120,
  78666. /**
  78667. * Unsigned Byte
  78668. */
  78669. UNSIGNED_BYTE = 5121,
  78670. /**
  78671. * Short
  78672. */
  78673. SHORT = 5122,
  78674. /**
  78675. * Unsigned Short
  78676. */
  78677. UNSIGNED_SHORT = 5123,
  78678. /**
  78679. * Unsigned Int
  78680. */
  78681. UNSIGNED_INT = 5125,
  78682. /**
  78683. * Float
  78684. */
  78685. FLOAT = 5126,
  78686. }
  78687. /**
  78688. * Specifies if the attirbute is a scalar, vector, or matrix
  78689. */
  78690. const enum AccessorType {
  78691. /**
  78692. * Scalar
  78693. */
  78694. SCALAR = "SCALAR",
  78695. /**
  78696. * Vector2
  78697. */
  78698. VEC2 = "VEC2",
  78699. /**
  78700. * Vector3
  78701. */
  78702. VEC3 = "VEC3",
  78703. /**
  78704. * Vector4
  78705. */
  78706. VEC4 = "VEC4",
  78707. /**
  78708. * Matrix2x2
  78709. */
  78710. MAT2 = "MAT2",
  78711. /**
  78712. * Matrix3x3
  78713. */
  78714. MAT3 = "MAT3",
  78715. /**
  78716. * Matrix4x4
  78717. */
  78718. MAT4 = "MAT4",
  78719. }
  78720. /**
  78721. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78722. */
  78723. const enum AnimationChannelTargetPath {
  78724. /**
  78725. * Translation
  78726. */
  78727. TRANSLATION = "translation",
  78728. /**
  78729. * Rotation
  78730. */
  78731. ROTATION = "rotation",
  78732. /**
  78733. * Scale
  78734. */
  78735. SCALE = "scale",
  78736. /**
  78737. * Weights
  78738. */
  78739. WEIGHTS = "weights",
  78740. }
  78741. /**
  78742. * Interpolation algorithm
  78743. */
  78744. const enum AnimationSamplerInterpolation {
  78745. /**
  78746. * The animated values are linearly interpolated between keyframes
  78747. */
  78748. LINEAR = "LINEAR",
  78749. /**
  78750. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78751. */
  78752. STEP = "STEP",
  78753. /**
  78754. * The animation's interpolation is computed using a cubic spline with specified tangents
  78755. */
  78756. CUBICSPLINE = "CUBICSPLINE",
  78757. }
  78758. /**
  78759. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78760. */
  78761. const enum CameraType {
  78762. /**
  78763. * A perspective camera containing properties to create a perspective projection matrix
  78764. */
  78765. PERSPECTIVE = "perspective",
  78766. /**
  78767. * An orthographic camera containing properties to create an orthographic projection matrix
  78768. */
  78769. ORTHOGRAPHIC = "orthographic",
  78770. }
  78771. /**
  78772. * The mime-type of the image
  78773. */
  78774. const enum ImageMimeType {
  78775. /**
  78776. * JPEG Mime-type
  78777. */
  78778. JPEG = "image/jpeg",
  78779. /**
  78780. * PNG Mime-type
  78781. */
  78782. PNG = "image/png",
  78783. }
  78784. /**
  78785. * The alpha rendering mode of the material
  78786. */
  78787. const enum MaterialAlphaMode {
  78788. /**
  78789. * The alpha value is ignored and the rendered output is fully opaque
  78790. */
  78791. OPAQUE = "OPAQUE",
  78792. /**
  78793. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78794. */
  78795. MASK = "MASK",
  78796. /**
  78797. * 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)
  78798. */
  78799. BLEND = "BLEND",
  78800. }
  78801. /**
  78802. * The type of the primitives to render
  78803. */
  78804. const enum MeshPrimitiveMode {
  78805. /**
  78806. * Points
  78807. */
  78808. POINTS = 0,
  78809. /**
  78810. * Lines
  78811. */
  78812. LINES = 1,
  78813. /**
  78814. * Line Loop
  78815. */
  78816. LINE_LOOP = 2,
  78817. /**
  78818. * Line Strip
  78819. */
  78820. LINE_STRIP = 3,
  78821. /**
  78822. * Triangles
  78823. */
  78824. TRIANGLES = 4,
  78825. /**
  78826. * Triangle Strip
  78827. */
  78828. TRIANGLE_STRIP = 5,
  78829. /**
  78830. * Triangle Fan
  78831. */
  78832. TRIANGLE_FAN = 6,
  78833. }
  78834. /**
  78835. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78836. */
  78837. const enum TextureMagFilter {
  78838. /**
  78839. * Nearest
  78840. */
  78841. NEAREST = 9728,
  78842. /**
  78843. * Linear
  78844. */
  78845. LINEAR = 9729,
  78846. }
  78847. /**
  78848. * Minification filter. All valid values correspond to WebGL enums
  78849. */
  78850. const enum TextureMinFilter {
  78851. /**
  78852. * Nearest
  78853. */
  78854. NEAREST = 9728,
  78855. /**
  78856. * Linear
  78857. */
  78858. LINEAR = 9729,
  78859. /**
  78860. * Nearest Mip-Map Nearest
  78861. */
  78862. NEAREST_MIPMAP_NEAREST = 9984,
  78863. /**
  78864. * Linear Mipmap Nearest
  78865. */
  78866. LINEAR_MIPMAP_NEAREST = 9985,
  78867. /**
  78868. * Nearest Mipmap Linear
  78869. */
  78870. NEAREST_MIPMAP_LINEAR = 9986,
  78871. /**
  78872. * Linear Mipmap Linear
  78873. */
  78874. LINEAR_MIPMAP_LINEAR = 9987,
  78875. }
  78876. /**
  78877. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78878. */
  78879. const enum TextureWrapMode {
  78880. /**
  78881. * Clamp to Edge
  78882. */
  78883. CLAMP_TO_EDGE = 33071,
  78884. /**
  78885. * Mirrored Repeat
  78886. */
  78887. MIRRORED_REPEAT = 33648,
  78888. /**
  78889. * Repeat
  78890. */
  78891. REPEAT = 10497,
  78892. }
  78893. /**
  78894. * glTF Property
  78895. */
  78896. interface IProperty {
  78897. /**
  78898. * Dictionary object with extension-specific objects
  78899. */
  78900. extensions?: {
  78901. [key: string]: any;
  78902. };
  78903. /**
  78904. * Application-Specific data
  78905. */
  78906. extras?: any;
  78907. }
  78908. /**
  78909. * glTF Child of Root Property
  78910. */
  78911. interface IChildRootProperty extends IProperty {
  78912. /**
  78913. * The user-defined name of this object
  78914. */
  78915. name?: string;
  78916. }
  78917. /**
  78918. * Indices of those attributes that deviate from their initialization value
  78919. */
  78920. interface IAccessorSparseIndices extends IProperty {
  78921. /**
  78922. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78923. */
  78924. bufferView: number;
  78925. /**
  78926. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78927. */
  78928. byteOffset?: number;
  78929. /**
  78930. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78931. */
  78932. componentType: AccessorComponentType;
  78933. }
  78934. /**
  78935. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78936. */
  78937. interface IAccessorSparseValues extends IProperty {
  78938. /**
  78939. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78940. */
  78941. bufferView: number;
  78942. /**
  78943. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78944. */
  78945. byteOffset?: number;
  78946. }
  78947. /**
  78948. * Sparse storage of attributes that deviate from their initialization value
  78949. */
  78950. interface IAccessorSparse extends IProperty {
  78951. /**
  78952. * The number of attributes encoded in this sparse accessor
  78953. */
  78954. count: number;
  78955. /**
  78956. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78957. */
  78958. indices: IAccessorSparseIndices;
  78959. /**
  78960. * 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
  78961. */
  78962. values: IAccessorSparseValues;
  78963. }
  78964. /**
  78965. * 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
  78966. */
  78967. interface IAccessor extends IChildRootProperty {
  78968. /**
  78969. * The index of the bufferview
  78970. */
  78971. bufferView?: number;
  78972. /**
  78973. * The offset relative to the start of the bufferView in bytes
  78974. */
  78975. byteOffset?: number;
  78976. /**
  78977. * The datatype of components in the attribute
  78978. */
  78979. componentType: AccessorComponentType;
  78980. /**
  78981. * Specifies whether integer data values should be normalized
  78982. */
  78983. normalized?: boolean;
  78984. /**
  78985. * The number of attributes referenced by this accessor
  78986. */
  78987. count: number;
  78988. /**
  78989. * Specifies if the attribute is a scalar, vector, or matrix
  78990. */
  78991. type: AccessorType;
  78992. /**
  78993. * Maximum value of each component in this attribute
  78994. */
  78995. max?: number[];
  78996. /**
  78997. * Minimum value of each component in this attribute
  78998. */
  78999. min?: number[];
  79000. /**
  79001. * Sparse storage of attributes that deviate from their initialization value
  79002. */
  79003. sparse?: IAccessorSparse;
  79004. }
  79005. /**
  79006. * Targets an animation's sampler at a node's property
  79007. */
  79008. interface IAnimationChannel extends IProperty {
  79009. /**
  79010. * The index of a sampler in this animation used to compute the value for the target
  79011. */
  79012. sampler: number;
  79013. /**
  79014. * The index of the node and TRS property to target
  79015. */
  79016. target: IAnimationChannelTarget;
  79017. }
  79018. /**
  79019. * The index of the node and TRS property that an animation channel targets
  79020. */
  79021. interface IAnimationChannelTarget extends IProperty {
  79022. /**
  79023. * The index of the node to target
  79024. */
  79025. node: number;
  79026. /**
  79027. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79028. */
  79029. path: AnimationChannelTargetPath;
  79030. }
  79031. /**
  79032. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79033. */
  79034. interface IAnimationSampler extends IProperty {
  79035. /**
  79036. * The index of an accessor containing keyframe input values, e.g., time
  79037. */
  79038. input: number;
  79039. /**
  79040. * Interpolation algorithm
  79041. */
  79042. interpolation?: AnimationSamplerInterpolation;
  79043. /**
  79044. * The index of an accessor, containing keyframe output values
  79045. */
  79046. output: number;
  79047. }
  79048. /**
  79049. * A keyframe animation
  79050. */
  79051. interface IAnimation extends IChildRootProperty {
  79052. /**
  79053. * An array of channels, each of which targets an animation's sampler at a node's property
  79054. */
  79055. channels: IAnimationChannel[];
  79056. /**
  79057. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79058. */
  79059. samplers: IAnimationSampler[];
  79060. }
  79061. /**
  79062. * Metadata about the glTF asset
  79063. */
  79064. interface IAsset extends IChildRootProperty {
  79065. /**
  79066. * A copyright message suitable for display to credit the content creator
  79067. */
  79068. copyright?: string;
  79069. /**
  79070. * Tool that generated this glTF model. Useful for debugging
  79071. */
  79072. generator?: string;
  79073. /**
  79074. * The glTF version that this asset targets
  79075. */
  79076. version: string;
  79077. /**
  79078. * The minimum glTF version that this asset targets
  79079. */
  79080. minVersion?: string;
  79081. }
  79082. /**
  79083. * A buffer points to binary geometry, animation, or skins
  79084. */
  79085. interface IBuffer extends IChildRootProperty {
  79086. /**
  79087. * 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
  79088. */
  79089. uri?: string;
  79090. /**
  79091. * The length of the buffer in bytes
  79092. */
  79093. byteLength: number;
  79094. }
  79095. /**
  79096. * A view into a buffer generally representing a subset of the buffer
  79097. */
  79098. interface IBufferView extends IChildRootProperty {
  79099. /**
  79100. * The index of the buffer
  79101. */
  79102. buffer: number;
  79103. /**
  79104. * The offset into the buffer in bytes
  79105. */
  79106. byteOffset?: number;
  79107. /**
  79108. * The lenth of the bufferView in bytes
  79109. */
  79110. byteLength: number;
  79111. /**
  79112. * The stride, in bytes
  79113. */
  79114. byteStride?: number;
  79115. }
  79116. /**
  79117. * An orthographic camera containing properties to create an orthographic projection matrix
  79118. */
  79119. interface ICameraOrthographic extends IProperty {
  79120. /**
  79121. * The floating-point horizontal magnification of the view. Must not be zero
  79122. */
  79123. xmag: number;
  79124. /**
  79125. * The floating-point vertical magnification of the view. Must not be zero
  79126. */
  79127. ymag: number;
  79128. /**
  79129. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79130. */
  79131. zfar: number;
  79132. /**
  79133. * The floating-point distance to the near clipping plane
  79134. */
  79135. znear: number;
  79136. }
  79137. /**
  79138. * A perspective camera containing properties to create a perspective projection matrix
  79139. */
  79140. interface ICameraPerspective extends IProperty {
  79141. /**
  79142. * The floating-point aspect ratio of the field of view
  79143. */
  79144. aspectRatio?: number;
  79145. /**
  79146. * The floating-point vertical field of view in radians
  79147. */
  79148. yfov: number;
  79149. /**
  79150. * The floating-point distance to the far clipping plane
  79151. */
  79152. zfar?: number;
  79153. /**
  79154. * The floating-point distance to the near clipping plane
  79155. */
  79156. znear: number;
  79157. }
  79158. /**
  79159. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79160. */
  79161. interface ICamera extends IChildRootProperty {
  79162. /**
  79163. * An orthographic camera containing properties to create an orthographic projection matrix
  79164. */
  79165. orthographic?: ICameraOrthographic;
  79166. /**
  79167. * A perspective camera containing properties to create a perspective projection matrix
  79168. */
  79169. perspective?: ICameraPerspective;
  79170. /**
  79171. * Specifies if the camera uses a perspective or orthographic projection
  79172. */
  79173. type: CameraType;
  79174. }
  79175. /**
  79176. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79177. */
  79178. interface IImage extends IChildRootProperty {
  79179. /**
  79180. * 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
  79181. */
  79182. uri?: string;
  79183. /**
  79184. * The image's MIME type
  79185. */
  79186. mimeType?: ImageMimeType;
  79187. /**
  79188. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79189. */
  79190. bufferView?: number;
  79191. }
  79192. /**
  79193. * Material Normal Texture Info
  79194. */
  79195. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79196. /**
  79197. * The scalar multiplier applied to each normal vector of the normal texture
  79198. */
  79199. scale?: number;
  79200. }
  79201. /**
  79202. * Material Occlusion Texture Info
  79203. */
  79204. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79205. /**
  79206. * A scalar multiplier controlling the amount of occlusion applied
  79207. */
  79208. strength?: number;
  79209. }
  79210. /**
  79211. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79212. */
  79213. interface IMaterialPbrMetallicRoughness {
  79214. /**
  79215. * The material's base color factor
  79216. */
  79217. baseColorFactor?: number[];
  79218. /**
  79219. * The base color texture
  79220. */
  79221. baseColorTexture?: ITextureInfo;
  79222. /**
  79223. * The metalness of the material
  79224. */
  79225. metallicFactor?: number;
  79226. /**
  79227. * The roughness of the material
  79228. */
  79229. roughnessFactor?: number;
  79230. /**
  79231. * The metallic-roughness texture
  79232. */
  79233. metallicRoughnessTexture?: ITextureInfo;
  79234. }
  79235. /**
  79236. * The material appearance of a primitive
  79237. */
  79238. interface IMaterial extends IChildRootProperty {
  79239. /**
  79240. * 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
  79241. */
  79242. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79243. /**
  79244. * The normal map texture
  79245. */
  79246. normalTexture?: IMaterialNormalTextureInfo;
  79247. /**
  79248. * The occlusion map texture
  79249. */
  79250. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79251. /**
  79252. * The emissive map texture
  79253. */
  79254. emissiveTexture?: ITextureInfo;
  79255. /**
  79256. * 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
  79257. */
  79258. emissiveFactor?: number[];
  79259. /**
  79260. * The alpha rendering mode of the material
  79261. */
  79262. alphaMode?: MaterialAlphaMode;
  79263. /**
  79264. * The alpha cutoff value of the material
  79265. */
  79266. alphaCutoff?: number;
  79267. /**
  79268. * Specifies whether the material is double sided
  79269. */
  79270. doubleSided?: boolean;
  79271. }
  79272. /**
  79273. * Geometry to be rendered with the given material
  79274. */
  79275. interface IMeshPrimitive extends IProperty {
  79276. /**
  79277. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79278. */
  79279. attributes: {
  79280. [name: string]: number;
  79281. };
  79282. /**
  79283. * The index of the accessor that contains the indices
  79284. */
  79285. indices?: number;
  79286. /**
  79287. * The index of the material to apply to this primitive when rendering
  79288. */
  79289. material?: number;
  79290. /**
  79291. * The type of primitives to render. All valid values correspond to WebGL enums
  79292. */
  79293. mode?: MeshPrimitiveMode;
  79294. /**
  79295. * 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
  79296. */
  79297. targets?: {
  79298. [name: string]: number;
  79299. }[];
  79300. }
  79301. /**
  79302. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79303. */
  79304. interface IMesh extends IChildRootProperty {
  79305. /**
  79306. * An array of primitives, each defining geometry to be rendered with a material
  79307. */
  79308. primitives: IMeshPrimitive[];
  79309. /**
  79310. * Array of weights to be applied to the Morph Targets
  79311. */
  79312. weights?: number[];
  79313. }
  79314. /**
  79315. * A node in the node hierarchy
  79316. */
  79317. interface INode extends IChildRootProperty {
  79318. /**
  79319. * The index of the camera referenced by this node
  79320. */
  79321. camera?: number;
  79322. /**
  79323. * The indices of this node's children
  79324. */
  79325. children?: number[];
  79326. /**
  79327. * The index of the skin referenced by this node
  79328. */
  79329. skin?: number;
  79330. /**
  79331. * A floating-point 4x4 transformation matrix stored in column-major order
  79332. */
  79333. matrix?: number[];
  79334. /**
  79335. * The index of the mesh in this node
  79336. */
  79337. mesh?: number;
  79338. /**
  79339. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79340. */
  79341. rotation?: number[];
  79342. /**
  79343. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79344. */
  79345. scale?: number[];
  79346. /**
  79347. * The node's translation along the x, y, and z axes
  79348. */
  79349. translation?: number[];
  79350. /**
  79351. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79352. */
  79353. weights?: number[];
  79354. }
  79355. /**
  79356. * Texture sampler properties for filtering and wrapping modes
  79357. */
  79358. interface ISampler extends IChildRootProperty {
  79359. /**
  79360. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79361. */
  79362. magFilter?: TextureMagFilter;
  79363. /**
  79364. * Minification filter. All valid values correspond to WebGL enums
  79365. */
  79366. minFilter?: TextureMinFilter;
  79367. /**
  79368. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79369. */
  79370. wrapS?: TextureWrapMode;
  79371. /**
  79372. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79373. */
  79374. wrapT?: TextureWrapMode;
  79375. }
  79376. /**
  79377. * The root nodes of a scene
  79378. */
  79379. interface IScene extends IChildRootProperty {
  79380. /**
  79381. * The indices of each root node
  79382. */
  79383. nodes: number[];
  79384. }
  79385. /**
  79386. * Joints and matrices defining a skin
  79387. */
  79388. interface ISkin extends IChildRootProperty {
  79389. /**
  79390. * 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
  79391. */
  79392. inverseBindMatrices?: number;
  79393. /**
  79394. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79395. */
  79396. skeleton?: number;
  79397. /**
  79398. * 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)
  79399. */
  79400. joints: number[];
  79401. }
  79402. /**
  79403. * A texture and its sampler
  79404. */
  79405. interface ITexture extends IChildRootProperty {
  79406. /**
  79407. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79408. */
  79409. sampler?: number;
  79410. /**
  79411. * The index of the image used by this texture
  79412. */
  79413. source: number;
  79414. }
  79415. /**
  79416. * Reference to a texture
  79417. */
  79418. interface ITextureInfo extends IProperty {
  79419. /**
  79420. * The index of the texture
  79421. */
  79422. index: number;
  79423. /**
  79424. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79425. */
  79426. texCoord?: number;
  79427. }
  79428. /**
  79429. * The root object for a glTF asset
  79430. */
  79431. interface IGLTF extends IProperty {
  79432. /**
  79433. * An array of accessors. An accessor is a typed view into a bufferView
  79434. */
  79435. accessors?: IAccessor[];
  79436. /**
  79437. * An array of keyframe animations
  79438. */
  79439. animations?: IAnimation[];
  79440. /**
  79441. * Metadata about the glTF asset
  79442. */
  79443. asset: IAsset;
  79444. /**
  79445. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79446. */
  79447. buffers?: IBuffer[];
  79448. /**
  79449. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79450. */
  79451. bufferViews?: IBufferView[];
  79452. /**
  79453. * An array of cameras
  79454. */
  79455. cameras?: ICamera[];
  79456. /**
  79457. * Names of glTF extensions used somewhere in this asset
  79458. */
  79459. extensionsUsed?: string[];
  79460. /**
  79461. * Names of glTF extensions required to properly load this asset
  79462. */
  79463. extensionsRequired?: string[];
  79464. /**
  79465. * An array of images. An image defines data used to create a texture
  79466. */
  79467. images?: IImage[];
  79468. /**
  79469. * An array of materials. A material defines the appearance of a primitive
  79470. */
  79471. materials?: IMaterial[];
  79472. /**
  79473. * An array of meshes. A mesh is a set of primitives to be rendered
  79474. */
  79475. meshes?: IMesh[];
  79476. /**
  79477. * An array of nodes
  79478. */
  79479. nodes?: INode[];
  79480. /**
  79481. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79482. */
  79483. samplers?: ISampler[];
  79484. /**
  79485. * The index of the default scene
  79486. */
  79487. scene?: number;
  79488. /**
  79489. * An array of scenes
  79490. */
  79491. scenes?: IScene[];
  79492. /**
  79493. * An array of skins. A skin is defined by joints and matrices
  79494. */
  79495. skins?: ISkin[];
  79496. /**
  79497. * An array of textures
  79498. */
  79499. textures?: ITexture[];
  79500. }
  79501. /**
  79502. * The glTF validation results
  79503. * @ignore
  79504. */
  79505. interface IGLTFValidationResults {
  79506. info: {
  79507. generator: string;
  79508. hasAnimations: boolean;
  79509. hasDefaultScene: boolean;
  79510. hasMaterials: boolean;
  79511. hasMorphTargets: boolean;
  79512. hasSkins: boolean;
  79513. hasTextures: boolean;
  79514. maxAttributesUsed: number;
  79515. primitivesCount: number
  79516. };
  79517. issues: {
  79518. messages: Array<string>;
  79519. numErrors: number;
  79520. numHints: number;
  79521. numInfos: number;
  79522. numWarnings: number;
  79523. truncated: boolean
  79524. };
  79525. mimeType: string;
  79526. uri: string;
  79527. validatedAt: string;
  79528. validatorVersion: string;
  79529. }
  79530. /**
  79531. * The glTF validation options
  79532. */
  79533. interface IGLTFValidationOptions {
  79534. /** Uri to use */
  79535. uri?: string;
  79536. /** Function used to load external resources */
  79537. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79538. /** Boolean indicating that we need to validate accessor data */
  79539. validateAccessorData?: boolean;
  79540. /** max number of issues allowed */
  79541. maxIssues?: number;
  79542. /** Ignored issues */
  79543. ignoredIssues?: Array<string>;
  79544. /** Value to override severy settings */
  79545. severityOverrides?: Object;
  79546. }
  79547. /**
  79548. * The glTF validator object
  79549. * @ignore
  79550. */
  79551. interface IGLTFValidator {
  79552. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79553. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79554. }
  79555. }
  79556. declare module BABYLON {
  79557. /** @hidden */
  79558. export var cellPixelShader: {
  79559. name: string;
  79560. shader: string;
  79561. };
  79562. }
  79563. declare module BABYLON {
  79564. /** @hidden */
  79565. export var cellVertexShader: {
  79566. name: string;
  79567. shader: string;
  79568. };
  79569. }
  79570. declare module BABYLON {
  79571. export class CellMaterial extends BABYLON.PushMaterial {
  79572. private _diffuseTexture;
  79573. diffuseTexture: BABYLON.BaseTexture;
  79574. diffuseColor: BABYLON.Color3;
  79575. _computeHighLevel: boolean;
  79576. computeHighLevel: boolean;
  79577. private _disableLighting;
  79578. disableLighting: boolean;
  79579. private _maxSimultaneousLights;
  79580. maxSimultaneousLights: number;
  79581. constructor(name: string, scene: BABYLON.Scene);
  79582. needAlphaBlending(): boolean;
  79583. needAlphaTesting(): boolean;
  79584. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79585. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79586. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79587. getAnimatables(): BABYLON.IAnimatable[];
  79588. getActiveTextures(): BABYLON.BaseTexture[];
  79589. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79590. dispose(forceDisposeEffect?: boolean): void;
  79591. getClassName(): string;
  79592. clone(name: string): CellMaterial;
  79593. serialize(): any;
  79594. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79595. }
  79596. }
  79597. declare module BABYLON {
  79598. export class CustomShaderStructure {
  79599. FragmentStore: string;
  79600. VertexStore: string;
  79601. constructor();
  79602. }
  79603. export class ShaderSpecialParts {
  79604. constructor();
  79605. Fragment_Begin: string;
  79606. Fragment_Definitions: string;
  79607. Fragment_MainBegin: string;
  79608. Fragment_Custom_Diffuse: string;
  79609. Fragment_Before_Lights: string;
  79610. Fragment_Before_Fog: string;
  79611. Fragment_Custom_Alpha: string;
  79612. Fragment_Before_FragColor: string;
  79613. Vertex_Begin: string;
  79614. Vertex_Definitions: string;
  79615. Vertex_MainBegin: string;
  79616. Vertex_Before_PositionUpdated: string;
  79617. Vertex_Before_NormalUpdated: string;
  79618. Vertex_MainEnd: string;
  79619. }
  79620. export class CustomMaterial extends BABYLON.StandardMaterial {
  79621. static ShaderIndexer: number;
  79622. CustomParts: ShaderSpecialParts;
  79623. _isCreatedShader: boolean;
  79624. _createdShaderName: string;
  79625. _customUniform: string[];
  79626. _newUniforms: string[];
  79627. _newUniformInstances: any[];
  79628. _newSamplerInstances: BABYLON.Texture[];
  79629. _customAttributes: string[];
  79630. FragmentShader: string;
  79631. VertexShader: string;
  79632. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79633. ReviewUniform(name: string, arr: string[]): string[];
  79634. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines, attributes?: string[]): string;
  79635. constructor(name: string, scene: BABYLON.Scene);
  79636. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79637. AddAttribute(name: string): CustomMaterial;
  79638. Fragment_Begin(shaderPart: string): CustomMaterial;
  79639. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79640. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79641. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79642. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79643. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79644. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79645. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79646. Vertex_Begin(shaderPart: string): CustomMaterial;
  79647. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79648. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79649. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79650. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79651. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79652. }
  79653. }
  79654. declare module BABYLON {
  79655. export class ShaderAlebdoParts {
  79656. constructor();
  79657. Fragment_Begin: string;
  79658. Fragment_Definitions: string;
  79659. Fragment_MainBegin: string;
  79660. Fragment_Custom_Albedo: string;
  79661. Fragment_Before_Lights: string;
  79662. Fragment_Custom_MetallicRoughness: string;
  79663. Fragment_Custom_MicroSurface: string;
  79664. Fragment_Before_Fog: string;
  79665. Fragment_Custom_Alpha: string;
  79666. Fragment_Before_FragColor: string;
  79667. Vertex_Begin: string;
  79668. Vertex_Definitions: string;
  79669. Vertex_MainBegin: string;
  79670. Vertex_Before_PositionUpdated: string;
  79671. Vertex_Before_NormalUpdated: string;
  79672. Vertex_MainEnd: string;
  79673. }
  79674. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79675. static ShaderIndexer: number;
  79676. CustomParts: ShaderAlebdoParts;
  79677. _isCreatedShader: boolean;
  79678. _createdShaderName: string;
  79679. _customUniform: string[];
  79680. _newUniforms: string[];
  79681. _newUniformInstances: any[];
  79682. _newSamplerInstances: BABYLON.Texture[];
  79683. _customAttributes: string[];
  79684. FragmentShader: string;
  79685. VertexShader: string;
  79686. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79687. ReviewUniform(name: string, arr: string[]): string[];
  79688. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines, attributes?: string[]): string;
  79689. constructor(name: string, scene: BABYLON.Scene);
  79690. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79691. AddAttribute(name: string): PBRCustomMaterial;
  79692. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79693. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79694. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79695. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79696. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79697. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79698. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79699. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79700. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79701. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79702. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79703. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79704. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79705. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79706. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79707. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79708. }
  79709. }
  79710. declare module BABYLON {
  79711. /** @hidden */
  79712. export var firePixelShader: {
  79713. name: string;
  79714. shader: string;
  79715. };
  79716. }
  79717. declare module BABYLON {
  79718. /** @hidden */
  79719. export var fireVertexShader: {
  79720. name: string;
  79721. shader: string;
  79722. };
  79723. }
  79724. declare module BABYLON {
  79725. export class FireMaterial extends BABYLON.PushMaterial {
  79726. private _diffuseTexture;
  79727. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79728. private _distortionTexture;
  79729. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79730. private _opacityTexture;
  79731. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79732. diffuseColor: BABYLON.Color3;
  79733. speed: number;
  79734. private _scaledDiffuse;
  79735. private _lastTime;
  79736. constructor(name: string, scene: BABYLON.Scene);
  79737. needAlphaBlending(): boolean;
  79738. needAlphaTesting(): boolean;
  79739. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79740. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79741. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79742. getAnimatables(): BABYLON.IAnimatable[];
  79743. getActiveTextures(): BABYLON.BaseTexture[];
  79744. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79745. getClassName(): string;
  79746. dispose(forceDisposeEffect?: boolean): void;
  79747. clone(name: string): FireMaterial;
  79748. serialize(): any;
  79749. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79750. }
  79751. }
  79752. declare module BABYLON {
  79753. /** @hidden */
  79754. export var furPixelShader: {
  79755. name: string;
  79756. shader: string;
  79757. };
  79758. }
  79759. declare module BABYLON {
  79760. /** @hidden */
  79761. export var furVertexShader: {
  79762. name: string;
  79763. shader: string;
  79764. };
  79765. }
  79766. declare module BABYLON {
  79767. export class FurMaterial extends BABYLON.PushMaterial {
  79768. private _diffuseTexture;
  79769. diffuseTexture: BABYLON.BaseTexture;
  79770. private _heightTexture;
  79771. heightTexture: BABYLON.BaseTexture;
  79772. diffuseColor: BABYLON.Color3;
  79773. furLength: number;
  79774. furAngle: number;
  79775. furColor: BABYLON.Color3;
  79776. furOffset: number;
  79777. furSpacing: number;
  79778. furGravity: BABYLON.Vector3;
  79779. furSpeed: number;
  79780. furDensity: number;
  79781. furOcclusion: number;
  79782. furTexture: BABYLON.DynamicTexture;
  79783. private _disableLighting;
  79784. disableLighting: boolean;
  79785. private _maxSimultaneousLights;
  79786. maxSimultaneousLights: number;
  79787. highLevelFur: boolean;
  79788. _meshes: BABYLON.AbstractMesh[];
  79789. private _furTime;
  79790. constructor(name: string, scene: BABYLON.Scene);
  79791. get furTime(): number;
  79792. set furTime(furTime: number);
  79793. needAlphaBlending(): boolean;
  79794. needAlphaTesting(): boolean;
  79795. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79796. updateFur(): void;
  79797. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79798. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79799. getAnimatables(): BABYLON.IAnimatable[];
  79800. getActiveTextures(): BABYLON.BaseTexture[];
  79801. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79802. dispose(forceDisposeEffect?: boolean): void;
  79803. clone(name: string): FurMaterial;
  79804. serialize(): any;
  79805. getClassName(): string;
  79806. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79807. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79808. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79809. }
  79810. }
  79811. declare module BABYLON {
  79812. /** @hidden */
  79813. export var gradientPixelShader: {
  79814. name: string;
  79815. shader: string;
  79816. };
  79817. }
  79818. declare module BABYLON {
  79819. /** @hidden */
  79820. export var gradientVertexShader: {
  79821. name: string;
  79822. shader: string;
  79823. };
  79824. }
  79825. declare module BABYLON {
  79826. export class GradientMaterial extends BABYLON.PushMaterial {
  79827. private _maxSimultaneousLights;
  79828. maxSimultaneousLights: number;
  79829. topColor: BABYLON.Color3;
  79830. topColorAlpha: number;
  79831. bottomColor: BABYLON.Color3;
  79832. bottomColorAlpha: number;
  79833. offset: number;
  79834. scale: number;
  79835. smoothness: number;
  79836. private _disableLighting;
  79837. disableLighting: boolean;
  79838. constructor(name: string, scene: BABYLON.Scene);
  79839. needAlphaBlending(): boolean;
  79840. needAlphaTesting(): boolean;
  79841. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79842. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79843. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79844. getAnimatables(): BABYLON.IAnimatable[];
  79845. dispose(forceDisposeEffect?: boolean): void;
  79846. clone(name: string): GradientMaterial;
  79847. serialize(): any;
  79848. getClassName(): string;
  79849. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79850. }
  79851. }
  79852. declare module BABYLON {
  79853. /** @hidden */
  79854. export var gridPixelShader: {
  79855. name: string;
  79856. shader: string;
  79857. };
  79858. }
  79859. declare module BABYLON {
  79860. /** @hidden */
  79861. export var gridVertexShader: {
  79862. name: string;
  79863. shader: string;
  79864. };
  79865. }
  79866. declare module BABYLON {
  79867. /**
  79868. * The grid materials allows you to wrap any shape with a grid.
  79869. * Colors are customizable.
  79870. */
  79871. export class GridMaterial extends BABYLON.PushMaterial {
  79872. /**
  79873. * Main color of the grid (e.g. between lines)
  79874. */
  79875. mainColor: BABYLON.Color3;
  79876. /**
  79877. * Color of the grid lines.
  79878. */
  79879. lineColor: BABYLON.Color3;
  79880. /**
  79881. * The scale of the grid compared to unit.
  79882. */
  79883. gridRatio: number;
  79884. /**
  79885. * Allows setting an offset for the grid lines.
  79886. */
  79887. gridOffset: BABYLON.Vector3;
  79888. /**
  79889. * The frequency of thicker lines.
  79890. */
  79891. majorUnitFrequency: number;
  79892. /**
  79893. * The visibility of minor units in the grid.
  79894. */
  79895. minorUnitVisibility: number;
  79896. /**
  79897. * The grid opacity outside of the lines.
  79898. */
  79899. opacity: number;
  79900. /**
  79901. * Determine RBG output is premultiplied by alpha value.
  79902. */
  79903. preMultiplyAlpha: boolean;
  79904. private _opacityTexture;
  79905. opacityTexture: BABYLON.BaseTexture;
  79906. private _gridControl;
  79907. /**
  79908. * constructor
  79909. * @param name The name given to the material in order to identify it afterwards.
  79910. * @param scene The scene the material is used in.
  79911. */
  79912. constructor(name: string, scene: BABYLON.Scene);
  79913. /**
  79914. * Returns wehter or not the grid requires alpha blending.
  79915. */
  79916. needAlphaBlending(): boolean;
  79917. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79918. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79919. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79920. /**
  79921. * Dispose the material and its associated resources.
  79922. * @param forceDisposeEffect will also dispose the used effect when true
  79923. */
  79924. dispose(forceDisposeEffect?: boolean): void;
  79925. clone(name: string): GridMaterial;
  79926. serialize(): any;
  79927. getClassName(): string;
  79928. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79929. }
  79930. }
  79931. declare module BABYLON {
  79932. /** @hidden */
  79933. export var lavaPixelShader: {
  79934. name: string;
  79935. shader: string;
  79936. };
  79937. }
  79938. declare module BABYLON {
  79939. /** @hidden */
  79940. export var lavaVertexShader: {
  79941. name: string;
  79942. shader: string;
  79943. };
  79944. }
  79945. declare module BABYLON {
  79946. export class LavaMaterial extends BABYLON.PushMaterial {
  79947. private _diffuseTexture;
  79948. diffuseTexture: BABYLON.BaseTexture;
  79949. noiseTexture: BABYLON.BaseTexture;
  79950. fogColor: BABYLON.Color3;
  79951. speed: number;
  79952. movingSpeed: number;
  79953. lowFrequencySpeed: number;
  79954. fogDensity: number;
  79955. private _lastTime;
  79956. diffuseColor: BABYLON.Color3;
  79957. private _disableLighting;
  79958. disableLighting: boolean;
  79959. private _unlit;
  79960. unlit: boolean;
  79961. private _maxSimultaneousLights;
  79962. maxSimultaneousLights: number;
  79963. private _scaledDiffuse;
  79964. constructor(name: string, scene: BABYLON.Scene);
  79965. needAlphaBlending(): boolean;
  79966. needAlphaTesting(): boolean;
  79967. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79968. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79969. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79970. getAnimatables(): BABYLON.IAnimatable[];
  79971. getActiveTextures(): BABYLON.BaseTexture[];
  79972. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79973. dispose(forceDisposeEffect?: boolean): void;
  79974. clone(name: string): LavaMaterial;
  79975. serialize(): any;
  79976. getClassName(): string;
  79977. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79978. }
  79979. }
  79980. declare module BABYLON {
  79981. /** @hidden */
  79982. export var mixPixelShader: {
  79983. name: string;
  79984. shader: string;
  79985. };
  79986. }
  79987. declare module BABYLON {
  79988. /** @hidden */
  79989. export var mixVertexShader: {
  79990. name: string;
  79991. shader: string;
  79992. };
  79993. }
  79994. declare module BABYLON {
  79995. export class MixMaterial extends BABYLON.PushMaterial {
  79996. /**
  79997. * Mix textures
  79998. */
  79999. private _mixTexture1;
  80000. mixTexture1: BABYLON.BaseTexture;
  80001. private _mixTexture2;
  80002. mixTexture2: BABYLON.BaseTexture;
  80003. /**
  80004. * Diffuse textures
  80005. */
  80006. private _diffuseTexture1;
  80007. diffuseTexture1: BABYLON.Texture;
  80008. private _diffuseTexture2;
  80009. diffuseTexture2: BABYLON.Texture;
  80010. private _diffuseTexture3;
  80011. diffuseTexture3: BABYLON.Texture;
  80012. private _diffuseTexture4;
  80013. diffuseTexture4: BABYLON.Texture;
  80014. private _diffuseTexture5;
  80015. diffuseTexture5: BABYLON.Texture;
  80016. private _diffuseTexture6;
  80017. diffuseTexture6: BABYLON.Texture;
  80018. private _diffuseTexture7;
  80019. diffuseTexture7: BABYLON.Texture;
  80020. private _diffuseTexture8;
  80021. diffuseTexture8: BABYLON.Texture;
  80022. /**
  80023. * Uniforms
  80024. */
  80025. diffuseColor: BABYLON.Color3;
  80026. specularColor: BABYLON.Color3;
  80027. specularPower: number;
  80028. private _disableLighting;
  80029. disableLighting: boolean;
  80030. private _maxSimultaneousLights;
  80031. maxSimultaneousLights: number;
  80032. constructor(name: string, scene: BABYLON.Scene);
  80033. needAlphaBlending(): boolean;
  80034. needAlphaTesting(): boolean;
  80035. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80036. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80037. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80038. getAnimatables(): BABYLON.IAnimatable[];
  80039. getActiveTextures(): BABYLON.BaseTexture[];
  80040. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80041. dispose(forceDisposeEffect?: boolean): void;
  80042. clone(name: string): MixMaterial;
  80043. serialize(): any;
  80044. getClassName(): string;
  80045. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80046. }
  80047. }
  80048. declare module BABYLON {
  80049. /** @hidden */
  80050. export var normalPixelShader: {
  80051. name: string;
  80052. shader: string;
  80053. };
  80054. }
  80055. declare module BABYLON {
  80056. /** @hidden */
  80057. export var normalVertexShader: {
  80058. name: string;
  80059. shader: string;
  80060. };
  80061. }
  80062. declare module BABYLON {
  80063. export class NormalMaterial extends BABYLON.PushMaterial {
  80064. private _diffuseTexture;
  80065. diffuseTexture: BABYLON.BaseTexture;
  80066. diffuseColor: BABYLON.Color3;
  80067. private _disableLighting;
  80068. disableLighting: boolean;
  80069. private _maxSimultaneousLights;
  80070. maxSimultaneousLights: number;
  80071. constructor(name: string, scene: BABYLON.Scene);
  80072. needAlphaBlending(): boolean;
  80073. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80074. needAlphaTesting(): boolean;
  80075. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80076. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80077. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80078. getAnimatables(): BABYLON.IAnimatable[];
  80079. getActiveTextures(): BABYLON.BaseTexture[];
  80080. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80081. dispose(forceDisposeEffect?: boolean): void;
  80082. clone(name: string): NormalMaterial;
  80083. serialize(): any;
  80084. getClassName(): string;
  80085. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80086. }
  80087. }
  80088. declare module BABYLON {
  80089. /** @hidden */
  80090. export var shadowOnlyPixelShader: {
  80091. name: string;
  80092. shader: string;
  80093. };
  80094. }
  80095. declare module BABYLON {
  80096. /** @hidden */
  80097. export var shadowOnlyVertexShader: {
  80098. name: string;
  80099. shader: string;
  80100. };
  80101. }
  80102. declare module BABYLON {
  80103. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80104. private _activeLight;
  80105. constructor(name: string, scene: BABYLON.Scene);
  80106. shadowColor: BABYLON.Color3;
  80107. needAlphaBlending(): boolean;
  80108. needAlphaTesting(): boolean;
  80109. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80110. get activeLight(): BABYLON.IShadowLight;
  80111. set activeLight(light: BABYLON.IShadowLight);
  80112. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80113. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80114. clone(name: string): ShadowOnlyMaterial;
  80115. serialize(): any;
  80116. getClassName(): string;
  80117. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80118. }
  80119. }
  80120. declare module BABYLON {
  80121. /** @hidden */
  80122. export var simplePixelShader: {
  80123. name: string;
  80124. shader: string;
  80125. };
  80126. }
  80127. declare module BABYLON {
  80128. /** @hidden */
  80129. export var simpleVertexShader: {
  80130. name: string;
  80131. shader: string;
  80132. };
  80133. }
  80134. declare module BABYLON {
  80135. export class SimpleMaterial extends BABYLON.PushMaterial {
  80136. private _diffuseTexture;
  80137. diffuseTexture: BABYLON.BaseTexture;
  80138. diffuseColor: BABYLON.Color3;
  80139. private _disableLighting;
  80140. disableLighting: boolean;
  80141. private _maxSimultaneousLights;
  80142. maxSimultaneousLights: number;
  80143. constructor(name: string, scene: BABYLON.Scene);
  80144. needAlphaBlending(): boolean;
  80145. needAlphaTesting(): boolean;
  80146. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80147. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80148. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80149. getAnimatables(): BABYLON.IAnimatable[];
  80150. getActiveTextures(): BABYLON.BaseTexture[];
  80151. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80152. dispose(forceDisposeEffect?: boolean): void;
  80153. clone(name: string): SimpleMaterial;
  80154. serialize(): any;
  80155. getClassName(): string;
  80156. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80157. }
  80158. }
  80159. declare module BABYLON {
  80160. /** @hidden */
  80161. export var skyPixelShader: {
  80162. name: string;
  80163. shader: string;
  80164. };
  80165. }
  80166. declare module BABYLON {
  80167. /** @hidden */
  80168. export var skyVertexShader: {
  80169. name: string;
  80170. shader: string;
  80171. };
  80172. }
  80173. declare module BABYLON {
  80174. /**
  80175. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80176. * @see https://doc.babylonjs.com/extensions/sky
  80177. */
  80178. export class SkyMaterial extends BABYLON.PushMaterial {
  80179. /**
  80180. * Defines the overall luminance of sky in interval ]0, 1[.
  80181. */
  80182. luminance: number;
  80183. /**
  80184. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80185. */
  80186. turbidity: number;
  80187. /**
  80188. * Defines the sky appearance (light intensity).
  80189. */
  80190. rayleigh: number;
  80191. /**
  80192. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80193. */
  80194. mieCoefficient: number;
  80195. /**
  80196. * Defines the amount of haze particles following the Mie scattering theory.
  80197. */
  80198. mieDirectionalG: number;
  80199. /**
  80200. * Defines the distance of the sun according to the active scene camera.
  80201. */
  80202. distance: number;
  80203. /**
  80204. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80205. * "inclined".
  80206. */
  80207. inclination: number;
  80208. /**
  80209. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80210. * an object direction and a reference direction.
  80211. */
  80212. azimuth: number;
  80213. /**
  80214. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80215. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80216. */
  80217. sunPosition: BABYLON.Vector3;
  80218. /**
  80219. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80220. * .sunPosition property.
  80221. */
  80222. useSunPosition: boolean;
  80223. /**
  80224. * Defines an offset vector used to get a horizon offset.
  80225. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80226. */
  80227. cameraOffset: BABYLON.Vector3;
  80228. private _cameraPosition;
  80229. /**
  80230. * Instantiates a new sky material.
  80231. * This material allows to create dynamic and texture free
  80232. * effects for skyboxes by taking care of the atmosphere state.
  80233. * @see https://doc.babylonjs.com/extensions/sky
  80234. * @param name Define the name of the material in the scene
  80235. * @param scene Define the scene the material belong to
  80236. */
  80237. constructor(name: string, scene: BABYLON.Scene);
  80238. /**
  80239. * Specifies if the material will require alpha blending
  80240. * @returns a boolean specifying if alpha blending is needed
  80241. */
  80242. needAlphaBlending(): boolean;
  80243. /**
  80244. * Specifies if this material should be rendered in alpha test mode
  80245. * @returns false as the sky material doesn't need alpha testing.
  80246. */
  80247. needAlphaTesting(): boolean;
  80248. /**
  80249. * Get the texture used for alpha test purpose.
  80250. * @returns null as the sky material has no texture.
  80251. */
  80252. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80253. /**
  80254. * Get if the submesh is ready to be used and all its information available.
  80255. * Child classes can use it to update shaders
  80256. * @param mesh defines the mesh to check
  80257. * @param subMesh defines which submesh to check
  80258. * @param useInstances specifies that instances should be used
  80259. * @returns a boolean indicating that the submesh is ready or not
  80260. */
  80261. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80262. /**
  80263. * Binds the submesh to this material by preparing the effect and shader to draw
  80264. * @param world defines the world transformation matrix
  80265. * @param mesh defines the mesh containing the submesh
  80266. * @param subMesh defines the submesh to bind the material to
  80267. */
  80268. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80269. /**
  80270. * Get the list of animatables in the material.
  80271. * @returns the list of animatables object used in the material
  80272. */
  80273. getAnimatables(): BABYLON.IAnimatable[];
  80274. /**
  80275. * Disposes the material
  80276. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80277. */
  80278. dispose(forceDisposeEffect?: boolean): void;
  80279. /**
  80280. * Makes a duplicate of the material, and gives it a new name
  80281. * @param name defines the new name for the duplicated material
  80282. * @returns the cloned material
  80283. */
  80284. clone(name: string): SkyMaterial;
  80285. /**
  80286. * Serializes this material in a JSON representation
  80287. * @returns the serialized material object
  80288. */
  80289. serialize(): any;
  80290. /**
  80291. * Gets the current class name of the material e.g. "SkyMaterial"
  80292. * Mainly use in serialization.
  80293. * @returns the class name
  80294. */
  80295. getClassName(): string;
  80296. /**
  80297. * Creates a sky material from parsed material data
  80298. * @param source defines the JSON representation of the material
  80299. * @param scene defines the hosting scene
  80300. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80301. * @returns a new sky material
  80302. */
  80303. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80304. }
  80305. }
  80306. declare module BABYLON {
  80307. /** @hidden */
  80308. export var terrainPixelShader: {
  80309. name: string;
  80310. shader: string;
  80311. };
  80312. }
  80313. declare module BABYLON {
  80314. /** @hidden */
  80315. export var terrainVertexShader: {
  80316. name: string;
  80317. shader: string;
  80318. };
  80319. }
  80320. declare module BABYLON {
  80321. export class TerrainMaterial extends BABYLON.PushMaterial {
  80322. private _mixTexture;
  80323. mixTexture: BABYLON.BaseTexture;
  80324. private _diffuseTexture1;
  80325. diffuseTexture1: BABYLON.Texture;
  80326. private _diffuseTexture2;
  80327. diffuseTexture2: BABYLON.Texture;
  80328. private _diffuseTexture3;
  80329. diffuseTexture3: BABYLON.Texture;
  80330. private _bumpTexture1;
  80331. bumpTexture1: BABYLON.Texture;
  80332. private _bumpTexture2;
  80333. bumpTexture2: BABYLON.Texture;
  80334. private _bumpTexture3;
  80335. bumpTexture3: BABYLON.Texture;
  80336. diffuseColor: BABYLON.Color3;
  80337. specularColor: BABYLON.Color3;
  80338. specularPower: number;
  80339. private _disableLighting;
  80340. disableLighting: boolean;
  80341. private _maxSimultaneousLights;
  80342. maxSimultaneousLights: number;
  80343. constructor(name: string, scene: BABYLON.Scene);
  80344. needAlphaBlending(): boolean;
  80345. needAlphaTesting(): boolean;
  80346. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80347. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80348. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80349. getAnimatables(): BABYLON.IAnimatable[];
  80350. getActiveTextures(): BABYLON.BaseTexture[];
  80351. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80352. dispose(forceDisposeEffect?: boolean): void;
  80353. clone(name: string): TerrainMaterial;
  80354. serialize(): any;
  80355. getClassName(): string;
  80356. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80357. }
  80358. }
  80359. declare module BABYLON {
  80360. /** @hidden */
  80361. export var triplanarPixelShader: {
  80362. name: string;
  80363. shader: string;
  80364. };
  80365. }
  80366. declare module BABYLON {
  80367. /** @hidden */
  80368. export var triplanarVertexShader: {
  80369. name: string;
  80370. shader: string;
  80371. };
  80372. }
  80373. declare module BABYLON {
  80374. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80375. mixTexture: BABYLON.BaseTexture;
  80376. private _diffuseTextureX;
  80377. diffuseTextureX: BABYLON.BaseTexture;
  80378. private _diffuseTextureY;
  80379. diffuseTextureY: BABYLON.BaseTexture;
  80380. private _diffuseTextureZ;
  80381. diffuseTextureZ: BABYLON.BaseTexture;
  80382. private _normalTextureX;
  80383. normalTextureX: BABYLON.BaseTexture;
  80384. private _normalTextureY;
  80385. normalTextureY: BABYLON.BaseTexture;
  80386. private _normalTextureZ;
  80387. normalTextureZ: BABYLON.BaseTexture;
  80388. tileSize: number;
  80389. diffuseColor: BABYLON.Color3;
  80390. specularColor: BABYLON.Color3;
  80391. specularPower: number;
  80392. private _disableLighting;
  80393. disableLighting: boolean;
  80394. private _maxSimultaneousLights;
  80395. maxSimultaneousLights: number;
  80396. constructor(name: string, scene: BABYLON.Scene);
  80397. needAlphaBlending(): boolean;
  80398. needAlphaTesting(): boolean;
  80399. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80400. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80401. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80402. getAnimatables(): BABYLON.IAnimatable[];
  80403. getActiveTextures(): BABYLON.BaseTexture[];
  80404. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80405. dispose(forceDisposeEffect?: boolean): void;
  80406. clone(name: string): TriPlanarMaterial;
  80407. serialize(): any;
  80408. getClassName(): string;
  80409. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80410. }
  80411. }
  80412. declare module BABYLON {
  80413. /** @hidden */
  80414. export var waterPixelShader: {
  80415. name: string;
  80416. shader: string;
  80417. };
  80418. }
  80419. declare module BABYLON {
  80420. /** @hidden */
  80421. export var waterVertexShader: {
  80422. name: string;
  80423. shader: string;
  80424. };
  80425. }
  80426. declare module BABYLON {
  80427. export class WaterMaterial extends BABYLON.PushMaterial {
  80428. renderTargetSize: BABYLON.Vector2;
  80429. private _bumpTexture;
  80430. bumpTexture: BABYLON.BaseTexture;
  80431. diffuseColor: BABYLON.Color3;
  80432. specularColor: BABYLON.Color3;
  80433. specularPower: number;
  80434. private _disableLighting;
  80435. disableLighting: boolean;
  80436. private _maxSimultaneousLights;
  80437. maxSimultaneousLights: number;
  80438. /**
  80439. * @param {number}: Represents the wind force
  80440. */
  80441. windForce: number;
  80442. /**
  80443. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80444. */
  80445. windDirection: BABYLON.Vector2;
  80446. /**
  80447. * @param {number}: Wave height, represents the height of the waves
  80448. */
  80449. waveHeight: number;
  80450. /**
  80451. * @param {number}: Bump height, represents the bump height related to the bump map
  80452. */
  80453. bumpHeight: number;
  80454. /**
  80455. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80456. */
  80457. private _bumpSuperimpose;
  80458. bumpSuperimpose: boolean;
  80459. /**
  80460. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80461. */
  80462. private _fresnelSeparate;
  80463. fresnelSeparate: boolean;
  80464. /**
  80465. * @param {boolean}: bump Waves modify the reflection.
  80466. */
  80467. private _bumpAffectsReflection;
  80468. bumpAffectsReflection: boolean;
  80469. /**
  80470. * @param {number}: The water color blended with the refraction (near)
  80471. */
  80472. waterColor: BABYLON.Color3;
  80473. /**
  80474. * @param {number}: The blend factor related to the water color
  80475. */
  80476. colorBlendFactor: number;
  80477. /**
  80478. * @param {number}: The water color blended with the reflection (far)
  80479. */
  80480. waterColor2: BABYLON.Color3;
  80481. /**
  80482. * @param {number}: The blend factor related to the water color (reflection, far)
  80483. */
  80484. colorBlendFactor2: number;
  80485. /**
  80486. * @param {number}: Represents the maximum length of a wave
  80487. */
  80488. waveLength: number;
  80489. /**
  80490. * @param {number}: Defines the waves speed
  80491. */
  80492. waveSpeed: number;
  80493. /**
  80494. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80495. * will avoid calculating useless pixels in the pixel shader of the water material.
  80496. */
  80497. disableClipPlane: boolean;
  80498. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80499. private _mesh;
  80500. private _refractionRTT;
  80501. private _reflectionRTT;
  80502. private _reflectionTransform;
  80503. private _lastTime;
  80504. private _lastDeltaTime;
  80505. private _useLogarithmicDepth;
  80506. private _waitingRenderList;
  80507. private _imageProcessingConfiguration;
  80508. private _imageProcessingObserver;
  80509. /**
  80510. * Gets a boolean indicating that current material needs to register RTT
  80511. */
  80512. get hasRenderTargetTextures(): boolean;
  80513. /**
  80514. * Constructor
  80515. */
  80516. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80517. get useLogarithmicDepth(): boolean;
  80518. set useLogarithmicDepth(value: boolean);
  80519. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80520. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80521. addToRenderList(node: any): void;
  80522. enableRenderTargets(enable: boolean): void;
  80523. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80524. get renderTargetsEnabled(): boolean;
  80525. needAlphaBlending(): boolean;
  80526. needAlphaTesting(): boolean;
  80527. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80528. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80529. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80530. private _createRenderTargets;
  80531. getAnimatables(): BABYLON.IAnimatable[];
  80532. getActiveTextures(): BABYLON.BaseTexture[];
  80533. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80534. dispose(forceDisposeEffect?: boolean): void;
  80535. clone(name: string): WaterMaterial;
  80536. serialize(): any;
  80537. getClassName(): string;
  80538. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80539. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80540. }
  80541. }
  80542. declare module BABYLON {
  80543. /** @hidden */
  80544. export var asciiartPixelShader: {
  80545. name: string;
  80546. shader: string;
  80547. };
  80548. }
  80549. declare module BABYLON {
  80550. /**
  80551. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80552. *
  80553. * It basically takes care rendering the font front the given font size to a texture.
  80554. * This is used later on in the postprocess.
  80555. */
  80556. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80557. private _font;
  80558. private _text;
  80559. private _charSize;
  80560. /**
  80561. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80562. */
  80563. get charSize(): number;
  80564. /**
  80565. * Create a new instance of the Ascii Art FontTexture class
  80566. * @param name the name of the texture
  80567. * @param font the font to use, use the W3C CSS notation
  80568. * @param text the caracter set to use in the rendering.
  80569. * @param scene the scene that owns the texture
  80570. */
  80571. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80572. /**
  80573. * Gets the max char width of a font.
  80574. * @param font the font to use, use the W3C CSS notation
  80575. * @return the max char width
  80576. */
  80577. private getFontWidth;
  80578. /**
  80579. * Gets the max char height of a font.
  80580. * @param font the font to use, use the W3C CSS notation
  80581. * @return the max char height
  80582. */
  80583. private getFontHeight;
  80584. /**
  80585. * Clones the current AsciiArtTexture.
  80586. * @return the clone of the texture.
  80587. */
  80588. clone(): AsciiArtFontTexture;
  80589. /**
  80590. * Parses a json object representing the texture and returns an instance of it.
  80591. * @param source the source JSON representation
  80592. * @param scene the scene to create the texture for
  80593. * @return the parsed texture
  80594. */
  80595. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80596. }
  80597. /**
  80598. * Option available in the Ascii Art Post Process.
  80599. */
  80600. export interface IAsciiArtPostProcessOptions {
  80601. /**
  80602. * The font to use following the w3c font definition.
  80603. */
  80604. font?: string;
  80605. /**
  80606. * The character set to use in the postprocess.
  80607. */
  80608. characterSet?: string;
  80609. /**
  80610. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80611. * This number is defined between 0 and 1;
  80612. */
  80613. mixToTile?: number;
  80614. /**
  80615. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80616. * This number is defined between 0 and 1;
  80617. */
  80618. mixToNormal?: number;
  80619. }
  80620. /**
  80621. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80622. *
  80623. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80624. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80625. */
  80626. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80627. /**
  80628. * The font texture used to render the char in the post process.
  80629. */
  80630. private _asciiArtFontTexture;
  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. * Instantiates a new Ascii Art Post Process.
  80643. * @param name the name to give to the postprocess
  80644. * @camera the camera to apply the post process to.
  80645. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80646. */
  80647. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80648. }
  80649. }
  80650. declare module BABYLON {
  80651. /** @hidden */
  80652. export var digitalrainPixelShader: {
  80653. name: string;
  80654. shader: string;
  80655. };
  80656. }
  80657. declare module BABYLON {
  80658. /**
  80659. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80660. *
  80661. * It basically takes care rendering the font front the given font size to a texture.
  80662. * This is used later on in the postprocess.
  80663. */
  80664. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80665. private _font;
  80666. private _text;
  80667. private _charSize;
  80668. /**
  80669. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80670. */
  80671. get charSize(): number;
  80672. /**
  80673. * Create a new instance of the Digital Rain FontTexture class
  80674. * @param name the name of the texture
  80675. * @param font the font to use, use the W3C CSS notation
  80676. * @param text the caracter set to use in the rendering.
  80677. * @param scene the scene that owns the texture
  80678. */
  80679. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80680. /**
  80681. * Gets the max char width of a font.
  80682. * @param font the font to use, use the W3C CSS notation
  80683. * @return the max char width
  80684. */
  80685. private getFontWidth;
  80686. /**
  80687. * Gets the max char height of a font.
  80688. * @param font the font to use, use the W3C CSS notation
  80689. * @return the max char height
  80690. */
  80691. private getFontHeight;
  80692. /**
  80693. * Clones the current DigitalRainFontTexture.
  80694. * @return the clone of the texture.
  80695. */
  80696. clone(): DigitalRainFontTexture;
  80697. /**
  80698. * Parses a json object representing the texture and returns an instance of it.
  80699. * @param source the source JSON representation
  80700. * @param scene the scene to create the texture for
  80701. * @return the parsed texture
  80702. */
  80703. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80704. }
  80705. /**
  80706. * Option available in the Digital Rain Post Process.
  80707. */
  80708. export interface IDigitalRainPostProcessOptions {
  80709. /**
  80710. * The font to use following the w3c font definition.
  80711. */
  80712. font?: string;
  80713. /**
  80714. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80715. * This number is defined between 0 and 1;
  80716. */
  80717. mixToTile?: number;
  80718. /**
  80719. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80720. * This number is defined between 0 and 1;
  80721. */
  80722. mixToNormal?: number;
  80723. }
  80724. /**
  80725. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80726. *
  80727. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80728. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80729. */
  80730. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80731. /**
  80732. * The font texture used to render the char in the post process.
  80733. */
  80734. private _digitalRainFontTexture;
  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. * Instantiates a new Digital Rain Post Process.
  80747. * @param name the name to give to the postprocess
  80748. * @camera the camera to apply the post process to.
  80749. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80750. */
  80751. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80752. }
  80753. }
  80754. declare module BABYLON {
  80755. /** @hidden */
  80756. export var brickProceduralTexturePixelShader: {
  80757. name: string;
  80758. shader: string;
  80759. };
  80760. }
  80761. declare module BABYLON {
  80762. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80763. private _numberOfBricksHeight;
  80764. private _numberOfBricksWidth;
  80765. private _jointColor;
  80766. private _brickColor;
  80767. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80768. updateShaderUniforms(): void;
  80769. get numberOfBricksHeight(): number;
  80770. set numberOfBricksHeight(value: number);
  80771. get numberOfBricksWidth(): number;
  80772. set numberOfBricksWidth(value: number);
  80773. get jointColor(): BABYLON.Color3;
  80774. set jointColor(value: BABYLON.Color3);
  80775. get brickColor(): BABYLON.Color3;
  80776. set brickColor(value: BABYLON.Color3);
  80777. /**
  80778. * Serializes this brick procedural texture
  80779. * @returns a serialized brick procedural texture object
  80780. */
  80781. serialize(): any;
  80782. /**
  80783. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80784. * @param parsedTexture defines parsed texture data
  80785. * @param scene defines the current scene
  80786. * @param rootUrl defines the root URL containing brick procedural texture information
  80787. * @returns a parsed Brick Procedural BABYLON.Texture
  80788. */
  80789. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80790. }
  80791. }
  80792. declare module BABYLON {
  80793. /** @hidden */
  80794. export var cloudProceduralTexturePixelShader: {
  80795. name: string;
  80796. shader: string;
  80797. };
  80798. }
  80799. declare module BABYLON {
  80800. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80801. private _skyColor;
  80802. private _cloudColor;
  80803. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80804. updateShaderUniforms(): void;
  80805. get skyColor(): BABYLON.Color4;
  80806. set skyColor(value: BABYLON.Color4);
  80807. get cloudColor(): BABYLON.Color4;
  80808. set cloudColor(value: BABYLON.Color4);
  80809. /**
  80810. * Serializes this cloud procedural texture
  80811. * @returns a serialized cloud procedural texture object
  80812. */
  80813. serialize(): any;
  80814. /**
  80815. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80816. * @param parsedTexture defines parsed texture data
  80817. * @param scene defines the current scene
  80818. * @param rootUrl defines the root URL containing cloud procedural texture information
  80819. * @returns a parsed Cloud Procedural BABYLON.Texture
  80820. */
  80821. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80822. }
  80823. }
  80824. declare module BABYLON {
  80825. /** @hidden */
  80826. export var fireProceduralTexturePixelShader: {
  80827. name: string;
  80828. shader: string;
  80829. };
  80830. }
  80831. declare module BABYLON {
  80832. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80833. private _time;
  80834. private _speed;
  80835. private _autoGenerateTime;
  80836. private _fireColors;
  80837. private _alphaThreshold;
  80838. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80839. updateShaderUniforms(): void;
  80840. render(useCameraPostProcess?: boolean): void;
  80841. static get PurpleFireColors(): BABYLON.Color3[];
  80842. static get GreenFireColors(): BABYLON.Color3[];
  80843. static get RedFireColors(): BABYLON.Color3[];
  80844. static get BlueFireColors(): BABYLON.Color3[];
  80845. get autoGenerateTime(): boolean;
  80846. set autoGenerateTime(value: boolean);
  80847. get fireColors(): BABYLON.Color3[];
  80848. set fireColors(value: BABYLON.Color3[]);
  80849. get time(): number;
  80850. set time(value: number);
  80851. get speed(): BABYLON.Vector2;
  80852. set speed(value: BABYLON.Vector2);
  80853. get alphaThreshold(): number;
  80854. set alphaThreshold(value: number);
  80855. /**
  80856. * Serializes this fire procedural texture
  80857. * @returns a serialized fire procedural texture object
  80858. */
  80859. serialize(): any;
  80860. /**
  80861. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80862. * @param parsedTexture defines parsed texture data
  80863. * @param scene defines the current scene
  80864. * @param rootUrl defines the root URL containing fire procedural texture information
  80865. * @returns a parsed Fire Procedural BABYLON.Texture
  80866. */
  80867. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80868. }
  80869. }
  80870. declare module BABYLON {
  80871. /** @hidden */
  80872. export var grassProceduralTexturePixelShader: {
  80873. name: string;
  80874. shader: string;
  80875. };
  80876. }
  80877. declare module BABYLON {
  80878. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  80879. private _grassColors;
  80880. private _groundColor;
  80881. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80882. updateShaderUniforms(): void;
  80883. get grassColors(): BABYLON.Color3[];
  80884. set grassColors(value: BABYLON.Color3[]);
  80885. get groundColor(): BABYLON.Color3;
  80886. set groundColor(value: BABYLON.Color3);
  80887. /**
  80888. * Serializes this grass procedural texture
  80889. * @returns a serialized grass procedural texture object
  80890. */
  80891. serialize(): any;
  80892. /**
  80893. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80894. * @param parsedTexture defines parsed texture data
  80895. * @param scene defines the current scene
  80896. * @param rootUrl defines the root URL containing grass procedural texture information
  80897. * @returns a parsed Grass Procedural BABYLON.Texture
  80898. */
  80899. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80900. }
  80901. }
  80902. declare module BABYLON {
  80903. /** @hidden */
  80904. export var marbleProceduralTexturePixelShader: {
  80905. name: string;
  80906. shader: string;
  80907. };
  80908. }
  80909. declare module BABYLON {
  80910. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80911. private _numberOfTilesHeight;
  80912. private _numberOfTilesWidth;
  80913. private _amplitude;
  80914. private _jointColor;
  80915. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80916. updateShaderUniforms(): void;
  80917. get numberOfTilesHeight(): number;
  80918. set numberOfTilesHeight(value: number);
  80919. get amplitude(): number;
  80920. set amplitude(value: number);
  80921. get numberOfTilesWidth(): number;
  80922. set numberOfTilesWidth(value: number);
  80923. get jointColor(): BABYLON.Color3;
  80924. set jointColor(value: BABYLON.Color3);
  80925. /**
  80926. * Serializes this marble procedural texture
  80927. * @returns a serialized marble procedural texture object
  80928. */
  80929. serialize(): any;
  80930. /**
  80931. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80932. * @param parsedTexture defines parsed texture data
  80933. * @param scene defines the current scene
  80934. * @param rootUrl defines the root URL containing marble procedural texture information
  80935. * @returns a parsed Marble Procedural BABYLON.Texture
  80936. */
  80937. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80938. }
  80939. }
  80940. declare module BABYLON {
  80941. /** @hidden */
  80942. export var normalMapProceduralTexturePixelShader: {
  80943. name: string;
  80944. shader: string;
  80945. };
  80946. }
  80947. declare module BABYLON {
  80948. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80949. private _baseTexture;
  80950. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80951. updateShaderUniforms(): void;
  80952. render(useCameraPostProcess?: boolean): void;
  80953. resize(size: any, generateMipMaps: any): void;
  80954. get baseTexture(): BABYLON.Texture;
  80955. set baseTexture(texture: BABYLON.Texture);
  80956. /**
  80957. * Serializes this normal map procedural texture
  80958. * @returns a serialized normal map procedural texture object
  80959. */
  80960. serialize(): any;
  80961. /**
  80962. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80963. * @param parsedTexture defines parsed texture data
  80964. * @param scene defines the current scene
  80965. * @param rootUrl defines the root URL containing normal map procedural texture information
  80966. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80967. */
  80968. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80969. }
  80970. }
  80971. declare module BABYLON {
  80972. /** @hidden */
  80973. export var perlinNoiseProceduralTexturePixelShader: {
  80974. name: string;
  80975. shader: string;
  80976. };
  80977. }
  80978. declare module BABYLON {
  80979. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  80980. time: number;
  80981. timeScale: number;
  80982. translationSpeed: number;
  80983. private _currentTranslation;
  80984. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80985. updateShaderUniforms(): void;
  80986. render(useCameraPostProcess?: boolean): void;
  80987. resize(size: any, generateMipMaps: any): void;
  80988. /**
  80989. * Serializes this perlin noise procedural texture
  80990. * @returns a serialized perlin noise procedural texture object
  80991. */
  80992. serialize(): any;
  80993. /**
  80994. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  80995. * @param parsedTexture defines parsed texture data
  80996. * @param scene defines the current scene
  80997. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  80998. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  80999. */
  81000. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81001. }
  81002. }
  81003. declare module BABYLON {
  81004. /** @hidden */
  81005. export var roadProceduralTexturePixelShader: {
  81006. name: string;
  81007. shader: string;
  81008. };
  81009. }
  81010. declare module BABYLON {
  81011. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81012. private _roadColor;
  81013. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81014. updateShaderUniforms(): void;
  81015. get roadColor(): BABYLON.Color3;
  81016. set roadColor(value: BABYLON.Color3);
  81017. /**
  81018. * Serializes this road procedural texture
  81019. * @returns a serialized road procedural texture object
  81020. */
  81021. serialize(): any;
  81022. /**
  81023. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81024. * @param parsedTexture defines parsed texture data
  81025. * @param scene defines the current scene
  81026. * @param rootUrl defines the root URL containing road procedural texture information
  81027. * @returns a parsed Road Procedural BABYLON.Texture
  81028. */
  81029. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81030. }
  81031. }
  81032. declare module BABYLON {
  81033. /** @hidden */
  81034. export var starfieldProceduralTexturePixelShader: {
  81035. name: string;
  81036. shader: string;
  81037. };
  81038. }
  81039. declare module BABYLON {
  81040. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81041. private _time;
  81042. private _alpha;
  81043. private _beta;
  81044. private _zoom;
  81045. private _formuparam;
  81046. private _stepsize;
  81047. private _tile;
  81048. private _brightness;
  81049. private _darkmatter;
  81050. private _distfading;
  81051. private _saturation;
  81052. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81053. updateShaderUniforms(): void;
  81054. get time(): number;
  81055. set time(value: number);
  81056. get alpha(): number;
  81057. set alpha(value: number);
  81058. get beta(): number;
  81059. set beta(value: number);
  81060. get formuparam(): number;
  81061. set formuparam(value: number);
  81062. get stepsize(): number;
  81063. set stepsize(value: number);
  81064. get zoom(): number;
  81065. set zoom(value: number);
  81066. get tile(): number;
  81067. set tile(value: number);
  81068. get brightness(): number;
  81069. set brightness(value: number);
  81070. get darkmatter(): number;
  81071. set darkmatter(value: number);
  81072. get distfading(): number;
  81073. set distfading(value: number);
  81074. get saturation(): number;
  81075. set saturation(value: number);
  81076. /**
  81077. * Serializes this starfield procedural texture
  81078. * @returns a serialized starfield procedural texture object
  81079. */
  81080. serialize(): any;
  81081. /**
  81082. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81083. * @param parsedTexture defines parsed texture data
  81084. * @param scene defines the current scene
  81085. * @param rootUrl defines the root URL containing startfield procedural texture information
  81086. * @returns a parsed Starfield Procedural BABYLON.Texture
  81087. */
  81088. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81089. }
  81090. }
  81091. declare module BABYLON {
  81092. /** @hidden */
  81093. export var woodProceduralTexturePixelShader: {
  81094. name: string;
  81095. shader: string;
  81096. };
  81097. }
  81098. declare module BABYLON {
  81099. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81100. private _ampScale;
  81101. private _woodColor;
  81102. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81103. updateShaderUniforms(): void;
  81104. get ampScale(): number;
  81105. set ampScale(value: number);
  81106. get woodColor(): BABYLON.Color3;
  81107. set woodColor(value: BABYLON.Color3);
  81108. /**
  81109. * Serializes this wood procedural texture
  81110. * @returns a serialized wood procedural texture object
  81111. */
  81112. serialize(): any;
  81113. /**
  81114. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81115. * @param parsedTexture defines parsed texture data
  81116. * @param scene defines the current scene
  81117. * @param rootUrl defines the root URL containing wood procedural texture information
  81118. * @returns a parsed Wood Procedural BABYLON.Texture
  81119. */
  81120. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81121. }
  81122. }